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..1b762999ef78a29710235c977ef5014746ecc408 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_MUTED = 0, |
| + MICROPHONE_IS_NOT_MUTED = 1, |
| + MICROPHONE_MUTE_MAX = MICROPHONE_IS_NOT_MUTED |
|
no longer working on chromium
2014/09/22 10:16:35
If you change MICROPHONE_MUTE_MAX = MICROPHONE_IS_
henrika (OOO until Aug 14)
2014/09/22 11:24:13
Found this style in other places in Chrome. Feels
no longer working on chromium
2014/09/23 08:17:58
I think the most common style is
enum MicrophoneMu
|
| +}; |
| + |
| +void LogMicrophoneMuteResult(MicrophoneMuteResult result) { |
| + UMA_HISTOGRAM_ENUMERATION("Media.MicrophoneMuted", |
|
no longer working on chromium
2014/09/22 10:16:35
what is the follow-up after we get the muted or un
henrika (OOO until Aug 14)
2014/09/22 11:24:13
The idea is that we shall learn how many users act
|
| + result, |
| + MICROPHONE_MUTE_MAX + 1); |
| +} |
| + |
| const int kMaxInputChannels = 3; |
| // TODO(henrika): remove usage of timers and add support for proper |
| @@ -577,6 +592,19 @@ 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 = "AIC::OnData: microphone is muted!"; |
| + handler_->OnLog(this, log_string); |
| + } else { |
| + LogMicrophoneMuteResult(MICROPHONE_IS_NOT_MUTED); |
| + } |
| #endif |
| } |