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

Side by Side 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: xians@ 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/audio_input_controller.h" 5 #include "media/audio/audio_input_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 592
593 UpdateSilenceState(level_dbfs < kSilenceThresholdDBFS); 593 UpdateSilenceState(level_dbfs < kSilenceThresholdDBFS);
594 594
595 UMA_HISTOGRAM_PERCENTAGE("Media.MicrophoneVolume", microphone_volume_percent); 595 UMA_HISTOGRAM_PERCENTAGE("Media.MicrophoneVolume", microphone_volume_percent);
596 log_string = base::StringPrintf( 596 log_string = base::StringPrintf(
597 "AIC::OnData: microphone volume=%d%%", microphone_volume_percent); 597 "AIC::OnData: microphone volume=%d%%", microphone_volume_percent);
598 if (microphone_volume_percent < kLowLevelMicrophoneLevelPercent) 598 if (microphone_volume_percent < kLowLevelMicrophoneLevelPercent)
599 log_string += " <=> low microphone level!"; 599 log_string += " <=> low microphone level!";
600 handler_->OnLog(this, log_string); 600 handler_->OnLog(this, log_string);
601 601
602 DVLOG(1) << "IsMuted: " << stream_->IsMuted();
603
602 // Try to detect if the user has enabled hardware mute by pressing the mute 604 // Try to detect if the user has enabled hardware mute by pressing the mute
603 // button in audio settings for the selected microphone. The idea here is to 605 // button in audio settings for the selected microphone. The idea here is to
604 // detect when all input samples are zeros but the actual volume slider is 606 // detect when all input samples are zeros but the actual volume slider is
605 // larger than zero. It should correspond to a hardware mute state. 607 // larger than zero. It should correspond to a hardware mute state.
606 if (level_dbfs == -std::numeric_limits<float>::infinity() && 608 if (level_dbfs == -std::numeric_limits<float>::infinity() &&
607 microphone_volume_percent > 0) { 609 microphone_volume_percent > 0) {
608 LogMicrophoneMuteResult(MICROPHONE_IS_MUTED); 610 LogMicrophoneMuteResult(MICROPHONE_IS_MUTED);
609 log_string = base::StringPrintf( 611 log_string = base::StringPrintf(
610 "AIC::OnData: microphone is muted!"); 612 "AIC::OnData: microphone is muted!");
611 handler_->OnLog(this, log_string); 613 handler_->OnLog(this, log_string);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 } 669 }
668 670
669 void AudioInputController::LogSilenceState(SilenceState value) { 671 void AudioInputController::LogSilenceState(SilenceState value) {
670 UMA_HISTOGRAM_ENUMERATION("Media.AudioInputControllerSessionSilenceReport", 672 UMA_HISTOGRAM_ENUMERATION("Media.AudioInputControllerSessionSilenceReport",
671 value, 673 value,
672 SILENCE_STATE_MAX + 1); 674 SILENCE_STATE_MAX + 1);
673 } 675 }
674 #endif 676 #endif
675 677
676 } // namespace media 678 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698