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..4e9b5cdd245ce02f7f799078e575d5d454947c71 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,48 @@ 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_NE(0, input_buffer_size); |
+ DCHECK_NE(0, output_buffer_size); |
+ |
+ 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
|
+ if (input_buffer_size >= output_buffer_size) { |
+ // 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.
|
+ value = (input_buffer_size % output_buffer_size) ? -1 : 0; |
+ } else { |
+ value = (output_buffer_size / input_buffer_size - 1) * 2; |
+ 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.
|
+ // One more callback is issued periodically. |
+ value += 1; |
+ } |
+ } |
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.
|
+ |
+ 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: |
+ 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.
|
+ } |
+} |
+ |
// Converts low latency based |output_params| into high latency appropriate |
// output parameters in error situations. |
void AudioOutputResampler::SetupFallbackParams() { |
@@ -354,7 +397,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 |