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..4c2e6e2b68618322a1f7064a6b7fb22b422400ea 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(); |
| + DCHECK(input_buffer_size); |
| + DCHECK(output_buffer_size); |
| + int value = (output_buffer_size - input_buffer_size) * 1000 / |
| + std::max(input_buffer_size, output_buffer_size); |
|
Henrik Grunell
2016/08/23 15:53:19
I believe you had it the other way around (i.e. mi
o1ka
2016/08/23 16:20:56
Right, it's a misprint, thanks for catching!
|
| + |
| + 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: |
| + UMA_HISTOGRAM_SPARSE_SLOWLY( |
|
Henrik Grunell
2016/08/23 15:53:19
This should never happen, right? Maybe NOTREACHED(
o1ka
2016/08/23 16:20:56
Why not? It can be the case in the future, and it'
Henrik Grunell
2016/08/24 12:47:15
It could be missed when adding a new type. Better
|
| + "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 |