Commit 75895532 authored by henrika's avatar henrika Committed by Commit bot

Adding media.MicrophoneVolume UMA stat.

BUG=405449,411380

Review URL: https://codereview.chromium.org/550933002

Cr-Commit-Position: refs/heads/master@{#293919}
parent ffa71385
......@@ -46,6 +46,10 @@ const int kPowerMeasurementTimeConstantMilliseconds = 10;
// Time in seconds between two successive measurements of audio power levels.
const int kPowerMonitorLogIntervalSeconds = 15;
// A warning will be logged when the microphone audio volume is below this
// threshold.
const int kLowLevelMicrophoneLevelPercent = 10;
#endif
}
......@@ -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%%", microphone_volume_percent);
if (microphone_volume_percent < kLowLevelMicrophoneLevelPercent)
log_string += " <=> low microphone level!";
handler_->OnLog(this, log_string);
#endif
}
......
......@@ -285,7 +285,7 @@ class MEDIA_EXPORT AudioInputController
void DoSetVolume(double volume);
void DoSetAutomaticGainControl(bool enabled);
void DoOnData(scoped_ptr<AudioBus> data);
void DoLogAudioLevel(float level_dbfs);
void DoLogAudioLevels(float level_dbfs, int microphone_volume_percent);
// Method to check if we get recorded data after a stream was started,
// and log the result to UMA.
......
......@@ -11483,6 +11483,14 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
<histogram name="Media.MicrophoneVolume" units="%">
<owner>henrika@chromium.org</owner>
<summary>
Level of the microphone volume measured in percent. This value can be larger
than 100% on Linux. Measured approximately four times per minute.
</summary>
</histogram>
<histogram name="Media.MSE.AudioCodec" enum="MSECodec">
<owner>acolwell@chromium.org</owner>
<summary>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment