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

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: Adding XML part 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..9fc9adb2d882c0b3e79e0d40b950bd5bcbff5e4e 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -510,12 +510,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.
+ int mic_volume_percent = static_cast<int>(100.0 * volume);
no longer working on chromium 2014/09/08 13:36:34 why can't we log it as a float?
henrika (OOO until Aug 14) 2014/09/08 13:50:57 It seems to be the preferred style to use int here
no longer working on chromium 2014/09/09 08:21:11 Acknowledged.
+
// 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 +551,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 +566,11 @@ 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);
+ handler_->OnLog(this, log_string);
#endif
}

Powered by Google App Engine
This is Rietveld 408576698