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

Unified Diff: media/audio/audio_input_controller.cc

Issue 645923002: Add support for audio input mute detection on all platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 6 years, 2 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/android/opensles_input.cc ('k') | media/audio/audio_io.h » ('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 72239f0d9c30efbdc80290988e787cee57e1b531..3bd14f19d1541f9ec780efe9830b565446214ed1 100644
--- a/media/audio/audio_input_controller.cc
+++ b/media/audio/audio_input_controller.cc
@@ -583,11 +583,24 @@ void AudioInputController::DoLogAudioLevels(float level_dbfs,
if (!handler_)
return;
+ // Detect if the user has enabled hardware mute by pressing the mute
+ // button in audio settings for the selected microphone.
+ const bool microphone_is_muted = stream_->IsMuted();
+ if (microphone_is_muted) {
+ LogMicrophoneMuteResult(MICROPHONE_IS_MUTED);
+ handler_->OnLog(this, "AIC::OnData: microphone is muted!");
+ // Return early if microphone is muted. No need to adding logs and UMA stats
+ // of audio levels if we know that the micropone is muted.
+ return;
+ }
+
+ LogMicrophoneMuteResult(MICROPHONE_IS_NOT_MUTED);
+
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)
- log_string += " <=> no audio input!";
+ log_string += " <=> low audio input level!";
handler_->OnLog(this, log_string);
UpdateSilenceState(level_dbfs < kSilenceThresholdDBFS);
@@ -598,20 +611,6 @@ void AudioInputController::DoLogAudioLevels(float level_dbfs,
if (microphone_volume_percent < kLowLevelMicrophoneLevelPercent)
log_string += " <=> low microphone level!";
handler_->OnLog(this, log_string);
-
- // Try to detect if the user has enabled hardware mute by pressing the mute
- // button in audio settings for the selected microphone. The idea here is to
- // detect when all input samples are zeros but the actual volume slider is
- // larger than zero. It should correspond to a hardware mute state.
- if (level_dbfs == -std::numeric_limits<float>::infinity() &&
- microphone_volume_percent > 0) {
- LogMicrophoneMuteResult(MICROPHONE_IS_MUTED);
- log_string = base::StringPrintf(
- "AIC::OnData: microphone is muted!");
- handler_->OnLog(this, log_string);
- } else {
- LogMicrophoneMuteResult(MICROPHONE_IS_NOT_MUTED);
- }
#endif
}
« no previous file with comments | « media/audio/android/opensles_input.cc ('k') | media/audio/audio_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698