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

Unified Diff: media/audio/audio_input_controller.cc

Issue 550933002: Adding media.MicrophoneVolume UMA stat (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds warning if mic level is below 10% of max Created 6 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/audio_input_controller.cc
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc
index 6308ead59d10ed71de1c6f50587980bfcc20adbf..b05bff6291304189646f5e84c0a6b6c0024f05e8 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -32,6 +32,10 @@ const int kTimerResetIntervalSeconds = 1;
// from 1 second to 5 seconds.
const int kTimerInitialIntervalSeconds = 5;
+// A warning will be logged when the microphone audio volume is below this
+// threshold.
+const int kLowLevelMicrophoneLevelInPercent = 10;
Henrik Grunell 2014/09/09 08:11:31 Nit: Remove "In".
henrika (OOO until Aug 14) 2014/09/09 08:52:30 Done.
+
#if defined(AUDIO_POWER_MONITORING)
// Time constant for AudioPowerMonitor.
// The utilized smoothing factor (alpha) in the exponential filter is given
@@ -510,12 +514,16 @@ void AudioInputController::OnData(AudioInputStream* stream,
// Possible range is given by [-inf, 0] dBFS.
std::pair<float, bool> result = audio_level_->ReadCurrentPowerAndClip();
+ // Add current microphone volume to log and UMA histogram.
+ const int mic_volume_percent = static_cast<int>(100.0 * volume);
+
// Use event handler on the audio thread to relay a message to the ARIH
// in content which does the actual logging on the IO thread.
- task_runner_->PostTask(
- FROM_HERE,
- base::Bind(
- &AudioInputController::DoLogAudioLevel, this, result.first));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&AudioInputController::DoLogAudioLevels,
+ this,
+ result.first,
+ mic_volume_percent));
last_audio_level_log_time_ = base::TimeTicks::Now();
@@ -547,7 +555,8 @@ void AudioInputController::DoOnData(scoped_ptr<AudioBus> data) {
handler_->OnData(this, data.get());
}
-void AudioInputController::DoLogAudioLevel(float level_dbfs) {
+void AudioInputController::DoLogAudioLevels(float level_dbfs,
+ int microphone_volume_percent) {
#if defined(AUDIO_POWER_MONITORING)
DCHECK(task_runner_->BelongsToCurrentThread());
if (!handler_)
@@ -561,6 +570,13 @@ void AudioInputController::DoLogAudioLevel(float level_dbfs) {
handler_->OnLog(this, log_string);
UpdateSilenceState(level_dbfs < kSilenceThresholdDBFS);
+
+ UMA_HISTOGRAM_PERCENTAGE("Media.MicrophoneVolume", microphone_volume_percent);
+ log_string = base::StringPrintf(
+ "AIC::OnData: microphone volume=%d percent", microphone_volume_percent);
Henrik Grunell 2014/09/09 08:11:31 Nit: Replace "percent" with "%" in the string. Mai
henrika (OOO until Aug 14) 2014/09/09 08:52:30 Done.
+ if (microphone_volume_percent < kLowLevelMicrophoneLevelInPercent)
+ log_string += " <=> low microphone level!";
tommi (sloooow) - chröme 2014/09/08 18:38:40 nit: ":" instead of <=> Can we log the actual valu
Henrik Grunell 2014/09/09 08:11:31 But the actual value is just 1/100 of the % value.
henrika (OOO until Aug 14) 2014/09/09 08:52:30 Done.
henrika (OOO until Aug 14) 2014/09/09 08:52:30 It is logged. Note that I add an extra warning to
+ handler_->OnLog(this, log_string);
#endif
}

Powered by Google App Engine
This is Rietveld 408576698