Chromium Code Reviews| Index: media/audio/audio_output_resampler.cc |
| diff --git a/media/audio/audio_output_resampler.cc b/media/audio/audio_output_resampler.cc |
| index 54afbe99fde86847835977ddbc4cebd6180c8013..2b70abf5aac63ecf1a03fe5ee990a5ff01127242 100644 |
| --- a/media/audio/audio_output_resampler.cc |
| +++ b/media/audio/audio_output_resampler.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/compiler_specific.h" |
| #include "base/macros.h" |
| #include "base/metrics/histogram.h" |
| +#include "base/metrics/sparse_histogram.h" |
| #include "base/numerics/safe_conversions.h" |
| #include "base/single_thread_task_runner.h" |
| #include "base/trace_event/trace_event.h" |
| @@ -135,6 +136,39 @@ static void RecordFallbackStats(const AudioParameters& output_params) { |
| } |
| } |
| +// Record UMA statistics for input/output rebuffering. |
| +static void RecordRebufferingStats(const AudioParameters& input_params, |
| + const AudioParameters& output_params) { |
| + const int& input_buffer_size = input_params.frames_per_buffer(); |
| + const int& output_buffer_size = output_params.frames_per_buffer(); |
|
Ilya Sherman
2016/08/24 22:20:23
nit: An int is generally going to be smaller or eq
o1ka
2016/08/25 11:48:34
It's extending lifetime of a temporary rather than
|
| + DCHECK(input_buffer_size); |
| + DCHECK(output_buffer_size); |
| + int value = (output_buffer_size - input_buffer_size) * 1000 / |
| + std::min(input_buffer_size, output_buffer_size); |
|
Ilya Sherman
2016/08/24 22:20:23
What is the possible range for these values? It's
o1ka
2016/08/25 11:48:34
For both buffer sizes the range is between 128 and
Ilya Sherman
2016/08/26 00:35:34
I think you are trying to pack too much into a sin
|
| + |
| + switch (input_params.latency_tag()) { |
| + case AudioLatency::LATENCY_EXACT_MS: |
| + UMA_HISTOGRAM_SPARSE_SLOWLY( |
| + "Media.Audio.Render.BufferSizeMismatch.LatencyExactMs", value); |
| + return; |
| + case AudioLatency::LATENCY_INTERACTIVE: |
| + UMA_HISTOGRAM_SPARSE_SLOWLY( |
| + "Media.Audio.Render.BufferSizeMismatch.LatencyInteractive", value); |
| + return; |
| + case AudioLatency::LATENCY_RTC: |
| + UMA_HISTOGRAM_SPARSE_SLOWLY( |
| + "Media.Audio.Render.BufferSizeMismatch.LatencyRtc", value); |
| + return; |
| + case AudioLatency::LATENCY_PLAYBACK: |
| + UMA_HISTOGRAM_SPARSE_SLOWLY( |
| + "Media.Audio.Render.BufferSizeMismatch.LatencyPlayback", value); |
| + return; |
| + default: |
|
Ilya Sherman
2016/08/24 22:20:23
Please explicitly list all possible cases. AFAICT
o1ka
2016/08/25 11:48:34
Agree. Done
|
| + UMA_HISTOGRAM_SPARSE_SLOWLY( |
| + "Media.Audio.Render.BufferSizeMismatch.LatencyOther", value); |
| + } |
| +} |
| + |
| // Converts low latency based |output_params| into high latency appropriate |
| // output parameters in error situations. |
| void AudioOutputResampler::SetupFallbackParams() { |
| @@ -354,7 +388,9 @@ OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params, |
| audio_converter_(input_params, output_params, false), |
| error_occurred_(false), |
| input_buffer_size_(input_params.frames_per_buffer()), |
| - output_buffer_size_(output_params.frames_per_buffer()) {} |
| + output_buffer_size_(output_params.frames_per_buffer()) { |
| + RecordRebufferingStats(input_params, output_params); |
| +} |
| OnMoreDataConverter::~OnMoreDataConverter() { |
| // Ensure Stop() has been called so we don't end up with an AudioOutputStream |