Chromium Code Reviews| Index: media/audio/audio_input_controller.cc |
| diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc |
| index c27e933c00fe407d0173c65c1e9cf80c91f07dc1..0b9bc0fc6ff383fdde1cf9df3c384b4c11f21e16 100644 |
| --- a/media/audio/audio_input_controller.cc |
| +++ b/media/audio/audio_input_controller.cc |
| @@ -10,13 +10,28 @@ |
| #include "base/threading/thread_restrictions.h" |
| #include "base/time/time.h" |
| #include "media/audio/audio_parameters.h" |
| -#include "media/base/limits.h" |
| #include "media/base/scoped_histogram_timer.h" |
| #include "media/base/user_input_monitor.h" |
| using base::TimeDelta; |
| namespace { |
| + |
| +// Logs if the user has enabled the microphone mute or not. This is normally |
| +// done by marking a checkbox in an audio-settings UI which is unique for each |
| +// platform. Elements in this enum should not be added, deleted or rearranged. |
| +enum MicrophoneMuteResult { |
| + MICROPHONE_IS_NOT_MUTED = 0, |
| + MICROPHONE_IS_MUTED = 1, |
| + MICROPHONE_MUTE_MAX = MICROPHONE_IS_NOT_MUTED |
|
tommi (sloooow) - chröme
2014/09/19 13:09:32
hmm... I think this should be MICROPHONE_IS_MUTED
henrika (OOO until Aug 14)
2014/09/19 14:57:43
Done.
|
| +}; |
| + |
| +void LogMicrophoneMuteResult(MicrophoneMuteResult result) { |
| + UMA_HISTOGRAM_ENUMERATION("Media.MicrophoneMuted", |
| + result, |
| + MICROPHONE_MUTE_MAX + 1); |
| +} |
| + |
| const int kMaxInputChannels = 3; |
| // TODO(henrika): remove usage of timers and add support for proper |
| @@ -577,6 +592,20 @@ 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 |
|
tommi (sloooow) - chröme
2014/09/19 13:09:32
do you know if this is the equivalent of a hardwar
henrika (OOO until Aug 14)
2014/09/19 14:57:42
I tried one USB headset with mute button and when
|
| + // 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 most likely hardware muted!"); |
|
tommi (sloooow) - chröme
2014/09/19 13:09:32
nit: "microphone muted" is probably enough
henrika (OOO until Aug 14)
2014/09/19 14:57:42
Done.
|
| + handler_->OnLog(this, log_string); |
| + } else { |
| + LogMicrophoneMuteResult(MICROPHONE_IS_NOT_MUTED); |
| + } |
| #endif |
| } |