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

Side by Side Diff: media/audio/audio_output_resampler.cc

Issue 2268253002: UMA stats for browser/renderer audio rendering buffer size mismatch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new version of UMA histogram Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/audio_output_resampler.h" 5 #include "media/audio/audio_output_resampler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.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/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/metrics/sparse_histogram.h"
14 #include "base/numerics/safe_conversions.h" 15 #include "base/numerics/safe_conversions.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "media/audio/audio_output_proxy.h" 19 #include "media/audio/audio_output_proxy.h"
19 #include "media/audio/sample_rates.h" 20 #include "media/audio/sample_rates.h"
20 #include "media/base/audio_converter.h" 21 #include "media/base/audio_converter.h"
21 #include "media/base/limits.h" 22 #include "media/base/limits.h"
22 23
23 namespace media { 24 namespace media {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 UMA_HISTOGRAM_ENUMERATION( 129 UMA_HISTOGRAM_ENUMERATION(
129 "Media.FallbackHardwareAudioSamplesPerSecond", 130 "Media.FallbackHardwareAudioSamplesPerSecond",
130 asr, kAudioSampleRateMax + 1); 131 asr, kAudioSampleRateMax + 1);
131 } else { 132 } else {
132 UMA_HISTOGRAM_COUNTS( 133 UMA_HISTOGRAM_COUNTS(
133 "Media.FallbackHardwareAudioSamplesPerSecondUnexpected", 134 "Media.FallbackHardwareAudioSamplesPerSecondUnexpected",
134 output_params.sample_rate()); 135 output_params.sample_rate());
135 } 136 }
136 } 137 }
137 138
139 // Record UMA statistics for input/output rebuffering.
140 static void RecordRebufferingStats(const AudioParameters& input_params,
141 const AudioParameters& output_params) {
142 const int input_buffer_size = input_params.frames_per_buffer();
143 const int output_buffer_size = output_params.frames_per_buffer();
144 DCHECK_NE(0, input_buffer_size);
145 DCHECK_NE(0, output_buffer_size);
146
147 int value = 0;
Ilya Sherman 2016/08/27 06:38:45 I think it would be best to document the value her
o1ka 2016/08/29 15:52:17 I'm not sure if you mean copying the description f
148 if (input_buffer_size >= output_buffer_size) {
149 // 0 if input size is a multiply of output size; otherwise -1.
Ilya Sherman 2016/08/27 06:38:45 nit: s/multiply/multiple
o1ka 2016/08/29 15:52:17 Done.
150 value = (input_buffer_size % output_buffer_size) ? -1 : 0;
151 } else {
152 value = (output_buffer_size / input_buffer_size - 1) * 2;
153 if (output_buffer_size % input_buffer_size) {
Henrik Grunell 2016/08/29 15:26:15 Nit: (x % y != 0) is more readable. Same above. Yo
o1ka 2016/08/29 15:52:17 Acknowledged.
154 // One more callback is issued periodically.
155 value += 1;
156 }
157 }
Ilya Sherman 2016/08/27 06:38:45 The range [-1, 63] sounds like an acceptable range
o1ka 2016/08/29 15:52:17 Done.
158
159 switch (input_params.latency_tag()) {
160 case AudioLatency::LATENCY_EXACT_MS:
161 UMA_HISTOGRAM_SPARSE_SLOWLY(
162 "Media.Audio.Render.BufferSizeMismatch.LatencyExactMs", value);
163 return;
164 case AudioLatency::LATENCY_INTERACTIVE:
165 UMA_HISTOGRAM_SPARSE_SLOWLY(
166 "Media.Audio.Render.BufferSizeMismatch.LatencyInteractive", value);
167 return;
168 case AudioLatency::LATENCY_RTC:
169 UMA_HISTOGRAM_SPARSE_SLOWLY(
170 "Media.Audio.Render.BufferSizeMismatch.LatencyRtc", value);
171 return;
172 case AudioLatency::LATENCY_PLAYBACK:
173 UMA_HISTOGRAM_SPARSE_SLOWLY(
174 "Media.Audio.Render.BufferSizeMismatch.LatencyPlayback", value);
175 return;
176 default:
177 DLOG(WARNING) << "Latency tag is not set";
Henrik Grunell 2016/08/29 15:26:15 Nit: It seems to me DVLOG that is more appropriate
o1ka 2016/08/29 15:52:17 Done.
178 }
179 }
180
138 // Converts low latency based |output_params| into high latency appropriate 181 // Converts low latency based |output_params| into high latency appropriate
139 // output parameters in error situations. 182 // output parameters in error situations.
140 void AudioOutputResampler::SetupFallbackParams() { 183 void AudioOutputResampler::SetupFallbackParams() {
141 // Only Windows has a high latency output driver that is not the same as the low 184 // Only Windows has a high latency output driver that is not the same as the low
142 // latency path. 185 // latency path.
143 #if defined(OS_WIN) 186 #if defined(OS_WIN)
144 // Choose AudioParameters appropriate for opening the device in high latency 187 // Choose AudioParameters appropriate for opening the device in high latency
145 // mode. |kMinLowLatencyFrameSize| is arbitrarily based on Pepper Flash's 188 // mode. |kMinLowLatencyFrameSize| is arbitrarily based on Pepper Flash's
146 // MAXIMUM frame size for low latency. 189 // MAXIMUM frame size for low latency.
147 static const int kMinLowLatencyFrameSize = 2048; 190 static const int kMinLowLatencyFrameSize = 2048;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 390
348 OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params, 391 OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params,
349 const AudioParameters& output_params) 392 const AudioParameters& output_params)
350 : io_ratio_(static_cast<double>(input_params.GetBytesPerSecond()) / 393 : io_ratio_(static_cast<double>(input_params.GetBytesPerSecond()) /
351 output_params.GetBytesPerSecond()), 394 output_params.GetBytesPerSecond()),
352 source_callback_(nullptr), 395 source_callback_(nullptr),
353 input_bytes_per_frame_(input_params.GetBytesPerFrame()), 396 input_bytes_per_frame_(input_params.GetBytesPerFrame()),
354 audio_converter_(input_params, output_params, false), 397 audio_converter_(input_params, output_params, false),
355 error_occurred_(false), 398 error_occurred_(false),
356 input_buffer_size_(input_params.frames_per_buffer()), 399 input_buffer_size_(input_params.frames_per_buffer()),
357 output_buffer_size_(output_params.frames_per_buffer()) {} 400 output_buffer_size_(output_params.frames_per_buffer()) {
401 RecordRebufferingStats(input_params, output_params);
402 }
358 403
359 OnMoreDataConverter::~OnMoreDataConverter() { 404 OnMoreDataConverter::~OnMoreDataConverter() {
360 // Ensure Stop() has been called so we don't end up with an AudioOutputStream 405 // Ensure Stop() has been called so we don't end up with an AudioOutputStream
361 // calling back into OnMoreData() after destruction. 406 // calling back into OnMoreData() after destruction.
362 CHECK(!source_callback_); 407 CHECK(!source_callback_);
363 } 408 }
364 409
365 void OnMoreDataConverter::Start( 410 void OnMoreDataConverter::Start(
366 AudioOutputStream::AudioSourceCallback* callback) { 411 AudioOutputStream::AudioSourceCallback* callback) {
367 CHECK(!source_callback_); 412 CHECK(!source_callback_);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 dest->ZeroFramesPartial(frames, dest->frames() - frames); 456 dest->ZeroFramesPartial(frames, dest->frames() - frames);
412 return frames > 0 ? 1 : 0; 457 return frames > 0 ? 1 : 0;
413 } 458 }
414 459
415 void OnMoreDataConverter::OnError(AudioOutputStream* stream) { 460 void OnMoreDataConverter::OnError(AudioOutputStream* stream) {
416 error_occurred_ = true; 461 error_occurred_ = true;
417 source_callback_->OnError(stream); 462 source_callback_->OnError(stream);
418 } 463 }
419 464
420 } // namespace media 465 } // namespace media
OLDNEW
« no previous file with comments | « media/BUILD.gn ('k') | media/base/BUILD.gn » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698