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

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: Code review + rebase. 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
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_input_controller.cc
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc
index 4753fe027714d04c6ceb4515a3b7187aa0d7d28b..bcd9c7281e61d1ff3b3b66b73cf59f717c33296a 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -84,6 +84,9 @@ AudioInputController::AudioInputController(EventHandler* handler,
sync_writer_(sync_writer),
max_volume_(0.0),
user_input_monitor_(user_input_monitor),
+#if defined(AUDIO_POWER_MONITORING)
+ silence_state_(SILENCE_STATE_NO_MEASUREMENT),
+#endif
prev_key_down_count_(0) {
DCHECK(creator_task_runner_.get());
}
@@ -225,6 +228,7 @@ void AudioInputController::DoCreate(AudioManager* audio_manager,
params.sample_rate(),
TimeDelta::FromMilliseconds(kPowerMeasurementTimeConstantMilliseconds)));
audio_params_ = params;
+ silence_state_ = SILENCE_STATE_NO_MEASUREMENT;
#endif
// TODO(miu): See TODO at top of file. Until that's resolved, assume all
@@ -324,6 +328,13 @@ 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_) {
+ LogSilenceState(silence_state_);
+ }
+#endif
+
state_ = CLOSED;
}
@@ -492,8 +503,24 @@ 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 (silence_state_ == SILENCE_STATE_NO_MEASUREMENT)
+ silence_state_ = SILENCE_STATE_ONLY_SILENCE;
+ else if (silence_state_ == SILENCE_STATE_ONLY_AUDIO)
+ silence_state_ = SILENCE_STATE_AUDIO_AND_SILENCE;
+ else
+ DCHECK(silence_state_ == SILENCE_STATE_ONLY_SILENCE ||
+ silence_state_ == SILENCE_STATE_AUDIO_AND_SILENCE);
+ } else {
+ if (silence_state_ == SILENCE_STATE_NO_MEASUREMENT)
+ silence_state_ = SILENCE_STATE_ONLY_AUDIO;
+ else if (silence_state_ == SILENCE_STATE_ONLY_SILENCE)
+ silence_state_ = SILENCE_STATE_AUDIO_AND_SILENCE;
+ else
+ DCHECK(silence_state_ == SILENCE_STATE_ONLY_AUDIO ||
+ silence_state_ == SILENCE_STATE_AUDIO_AND_SILENCE);
+ }
handler_->OnLog(this, log_string);
#endif
@@ -527,4 +554,12 @@ bool AudioInputController::GetDataIsActive() {
return (base::subtle::Acquire_Load(&data_is_active_) != false);
}
+#if defined(AUDIO_POWER_MONITORING)
+void AudioInputController::LogSilenceState(SilenceState value) {
+ UMA_HISTOGRAM_ENUMERATION("Media.AudioInputControllerSessionSilenceReport",
+ value,
+ SILENCE_STATE_MAX + 1);
+}
+#endif
+
} // namespace media
« no previous file with comments | « media/audio/audio_input_controller.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698