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

Unified Diff: media/audio/audio_input_controller.cc

Issue 462813004: Add UMA stats for silence AudioInputController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 490c62b3c16df6794d1ff6d17d18147f9c759a2c..dee7412df9f95beeb21b2b38f88f42b2a6b98163 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -63,6 +63,10 @@ AudioInputController::AudioInputController(EventHandler* handler,
sync_writer_(sync_writer),
max_volume_(0.0),
user_input_monitor_(user_input_monitor),
+#if defined(AUDIO_POWER_MONITORING)
+ last_audio_level_was_silence_(false),
+ silence_counter_(0),
+#endif
prev_key_down_count_(0) {
DCHECK(creator_task_runner_.get());
}
@@ -203,6 +207,8 @@ void AudioInputController::DoCreate(AudioManager* audio_manager,
params.sample_rate(),
TimeDelta::FromMilliseconds(kPowerMeasurementTimeConstantMilliseconds)));
audio_params_ = params;
+ last_audio_level_was_silence_ = false;
+ silence_counter_ = 0;
#endif
// TODO(miu): See TODO at top of file. Until that's resolved, assume all
@@ -307,6 +313,14 @@ void AudioInputController::DoClose() {
if (user_input_monitor_)
user_input_monitor_->DisableKeyPressMonitoring();
+#if defined(AUDIO_POWER_MONITORING)
+ // Send UMA stats if we have enabled power monitoring.
+ if (audio_level_) {
+ UMA_HISTOGRAM_COUNTS_10000("Media.AudioInputControllerSilenceCount",
+ silence_counter_);
+ }
+#endif
+
state_ = CLOSED;
}
@@ -474,8 +488,14 @@ void AudioInputController::DoLogAudioLevel(float level_dbfs) {
std::string log_string = base::StringPrintf(
"AIC::OnData: average audio level=%.2f dBFS", level_dbfs);
static const float kSilenceThresholdDBFS = -72.24719896f;
- if (level_dbfs < kSilenceThresholdDBFS)
+ if (level_dbfs < kSilenceThresholdDBFS) {
log_string += " <=> no audio input!";
+ if (!last_audio_level_was_silence_)
+ ++silence_counter_;
+ last_audio_level_was_silence_ = true;
+ } else {
+ last_audio_level_was_silence_ = false;
+ }
handler_->OnLog(this, log_string);
#endif

Powered by Google App Engine
This is Rietveld 408576698