Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: media/audio/mac/audio_auhal_mac.cc

Issue 2023943002: Revert of Forward output glitch information from stream WebRTC log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_auhal_mac_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/mac/audio_auhal_mac.h" 5 #include "media/audio/mac/audio_auhal_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/mac/mac_logging.h" 12 #include "base/mac/mac_logging.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/strings/stringprintf.h"
15 #include "base/time/time.h" 14 #include "base/time/time.h"
16 #include "base/trace_event/trace_event.h" 15 #include "base/trace_event/trace_event.h"
17 #include "media/audio/mac/audio_manager_mac.h" 16 #include "media/audio/mac/audio_manager_mac.h"
18 #include "media/base/audio_pull_fifo.h" 17 #include "media/base/audio_pull_fifo.h"
19 18
20 namespace media { 19 namespace media {
21 20
22 static void WrapBufferList(AudioBufferList* buffer_list, 21 static void WrapBufferList(AudioBufferList* buffer_list,
23 AudioBus* bus, 22 AudioBus* bus,
24 int frames) { 23 int frames) {
25 DCHECK(buffer_list); 24 DCHECK(buffer_list);
26 DCHECK(bus); 25 DCHECK(bus);
27 const int channels = bus->channels(); 26 const int channels = bus->channels();
28 const int buffer_list_channels = buffer_list->mNumberBuffers; 27 const int buffer_list_channels = buffer_list->mNumberBuffers;
29 CHECK_EQ(channels, buffer_list_channels); 28 CHECK_EQ(channels, buffer_list_channels);
30 29
31 // Copy pointers from AudioBufferList. 30 // Copy pointers from AudioBufferList.
32 for (int i = 0; i < channels; ++i) { 31 for (int i = 0; i < channels; ++i) {
33 bus->SetChannelData( 32 bus->SetChannelData(
34 i, static_cast<float*>(buffer_list->mBuffers[i].mData)); 33 i, static_cast<float*>(buffer_list->mBuffers[i].mData));
35 } 34 }
36 35
37 // Finally set the actual length. 36 // Finally set the actual length.
38 bus->set_frames(frames); 37 bus->set_frames(frames);
39 } 38 }
40 39
41 AUHALStream::AUHALStream(AudioManagerMac* manager, 40 AUHALStream::AUHALStream(AudioManagerMac* manager,
42 const AudioParameters& params, 41 const AudioParameters& params,
43 AudioDeviceID device, 42 AudioDeviceID device)
44 const AudioManager::LogCallback& log_callback)
45 : manager_(manager), 43 : manager_(manager),
46 params_(params), 44 params_(params),
47 output_channels_(params_.channels()), 45 output_channels_(params_.channels()),
48 number_of_frames_(params_.frames_per_buffer()), 46 number_of_frames_(params_.frames_per_buffer()),
49 number_of_frames_requested_(0), 47 number_of_frames_requested_(0),
50 source_(NULL), 48 source_(NULL),
51 device_(device), 49 device_(device),
52 audio_unit_(0), 50 audio_unit_(0),
53 volume_(1), 51 volume_(1),
54 hardware_latency_frames_(0), 52 hardware_latency_frames_(0),
55 stopped_(true), 53 stopped_(true),
56 current_hardware_pending_bytes_(0), 54 current_hardware_pending_bytes_(0),
57 current_lost_frames_(0), 55 current_lost_frames_(0),
58 last_sample_time_(0.0), 56 last_sample_time_(0.0),
59 last_number_of_frames_(0), 57 last_number_of_frames_(0),
60 total_lost_frames_(0), 58 total_lost_frames_(0),
61 largest_glitch_frames_(0), 59 largest_glitch_frames_(0),
62 glitches_detected_(0), 60 glitches_detected_(0) {
63 log_callback_(log_callback) {
64 // We must have a manager. 61 // We must have a manager.
65 DCHECK(manager_); 62 DCHECK(manager_);
66 63
67 DVLOG(1) << "ctor"; 64 DVLOG(1) << "ctor";
68 DVLOG(1) << "device ID: 0x" << std::hex << device; 65 DVLOG(1) << "device ID: 0x" << std::hex << device;
69 DVLOG(1) << "buffer size: " << number_of_frames_; 66 DVLOG(1) << "buffer size: " << number_of_frames_;
70 DVLOG(1) << "output channels: " << output_channels_; 67 DVLOG(1) << "output channels: " << output_channels_;
71 DVLOG(1) << "sample rate: " << params_.sample_rate(); 68 DVLOG(1) << "sample rate: " << params_.sample_rate();
72 } 69 }
73 70
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 return; // No stats gathered to report. 383 return; // No stats gathered to report.
387 384
388 // A value of 0 indicates that we got the buffer size we asked for. 385 // A value of 0 indicates that we got the buffer size we asked for.
389 UMA_HISTOGRAM_COUNTS("Media.Audio.Render.FramesRequested", 386 UMA_HISTOGRAM_COUNTS("Media.Audio.Render.FramesRequested",
390 number_of_frames_requested_); 387 number_of_frames_requested_);
391 // Even if there aren't any glitches, we want to record it to get a feel for 388 // Even if there aren't any glitches, we want to record it to get a feel for
392 // how often we get no glitches vs the alternative. 389 // how often we get no glitches vs the alternative.
393 UMA_HISTOGRAM_CUSTOM_COUNTS("Media.Audio.Render.Glitches", glitches_detected_, 390 UMA_HISTOGRAM_CUSTOM_COUNTS("Media.Audio.Render.Glitches", glitches_detected_,
394 0, 999999, 100); 391 0, 999999, 100);
395 392
396 auto lost_frames_ms = (total_lost_frames_ * 1000) / params_.sample_rate();
397 std::string log_message = base::StringPrintf(
398 "AU out: Total glitches=%d. Total frames lost=%d (%d ms).",
399 glitches_detected_, total_lost_frames_, lost_frames_ms);
400 log_callback_.Run(log_message);
401
402 if (glitches_detected_ != 0) { 393 if (glitches_detected_ != 0) {
394 auto lost_frames_ms = (total_lost_frames_ * 1000) / params_.sample_rate();
403 UMA_HISTOGRAM_COUNTS("Media.Audio.Render.LostFramesInMs", lost_frames_ms); 395 UMA_HISTOGRAM_COUNTS("Media.Audio.Render.LostFramesInMs", lost_frames_ms);
404 auto largest_glitch_ms = 396 auto largest_glitch_ms =
405 (largest_glitch_frames_ * 1000) / params_.sample_rate(); 397 (largest_glitch_frames_ * 1000) / params_.sample_rate();
406 UMA_HISTOGRAM_COUNTS("Media.Audio.Render.LargestGlitchMs", 398 UMA_HISTOGRAM_COUNTS("Media.Audio.Render.LargestGlitchMs",
407 largest_glitch_ms); 399 largest_glitch_ms);
408 DLOG(WARNING) << log_message; 400 DLOG(WARNING) << "Total glitches=" << glitches_detected_
401 << ". Total frames lost=" << total_lost_frames_ << " ("
402 << lost_frames_ms;
409 } 403 }
410 404
411 number_of_frames_requested_ = 0; 405 number_of_frames_requested_ = 0;
412 glitches_detected_ = 0; 406 glitches_detected_ = 0;
413 last_sample_time_ = 0; 407 last_sample_time_ = 0;
414 last_number_of_frames_ = 0; 408 last_number_of_frames_ = 0;
415 total_lost_frames_ = 0; 409 total_lost_frames_ = 0;
416 largest_glitch_frames_ = 0; 410 largest_glitch_frames_ = 0;
417 } 411 }
418 412
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 OSStatus result = AudioUnitUninitialize(audio_unit_); 548 OSStatus result = AudioUnitUninitialize(audio_unit_);
555 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 549 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
556 << "AudioUnitUninitialize() failed."; 550 << "AudioUnitUninitialize() failed.";
557 result = AudioComponentInstanceDispose(audio_unit_); 551 result = AudioComponentInstanceDispose(audio_unit_);
558 OSSTATUS_DLOG_IF(ERROR, result != noErr, result) 552 OSSTATUS_DLOG_IF(ERROR, result != noErr, result)
559 << "AudioComponentInstanceDispose() failed."; 553 << "AudioComponentInstanceDispose() failed.";
560 audio_unit_ = 0; 554 audio_unit_ = 0;
561 } 555 }
562 556
563 } // namespace media 557 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/mac/audio_auhal_mac.h ('k') | media/audio/mac/audio_auhal_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698