| 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
|
|
|