Index: media/audio/audio_input_controller.cc |
diff --git a/media/audio/audio_input_controller.cc b/media/audio/audio_input_controller.cc |
index 5c8997e0875b0853d02152b2c2d1ab6531f487ef..24a6ec766d69ec95a94dc63e266436ce071326d8 100644 |
--- a/media/audio/audio_input_controller.cc |
+++ b/media/audio/audio_input_controller.cc |
@@ -26,6 +26,7 @@ namespace media { |
namespace { |
const int kMaxInputChannels = 3; |
+constexpr int kCheckMutedStateIntervalSeconds = 1; |
#if defined(AUDIO_POWER_MONITORING) |
// Time in seconds between two successive measurements of audio power levels. |
@@ -353,6 +354,15 @@ void AudioInputController::DoCreateForStream( |
// Finally, keep the stream pointer around, update the state and notify. |
stream_ = stream_to_control; |
handler_->OnCreated(this); |
+ |
+ // Check the current muted state and create a new repeating timer to keep that |
+ // updated. |
+ CheckMutedState(); |
+ check_muted_state_timer_.emplace(); |
+ check_muted_state_timer_->Start( |
+ FROM_HERE, base::TimeDelta::FromSeconds(kCheckMutedStateIntervalSeconds), |
+ this, &AudioInputController::CheckMutedState); |
+ DCHECK(check_muted_state_timer_->IsRunning()); |
} |
void AudioInputController::DoRecord() { |
@@ -382,6 +392,9 @@ void AudioInputController::DoClose() { |
if (!stream_) |
return; |
+ // Stop and destroy the muted check timer. |
+ check_muted_state_timer_.reset(); |
+ |
// Allow calling unconditionally and bail if we don't have a stream to close. |
if (audio_callback_) { |
stream_->Stop(); |
@@ -652,6 +665,17 @@ bool AudioInputController::CheckAudioPower(const AudioBus* source, |
#endif |
} |
+void AudioInputController::CheckMutedState() { |
+ DCHECK(task_runner_->BelongsToCurrentThread()); |
+ DCHECK(stream_); |
+ const bool new_state = stream_->IsMuted(); |
+ if (new_state != is_muted_) { |
+ is_muted_ = new_state; |
+ // Don't log this here, AudioInputRendererHost will log instead. |
Guido Urdaneta
2017/06/02 14:13:21
remove obsolete comment
ossu-chromium
2017/06/02 15:32:45
No, I added it so that anyone scouring this code,
|
+ handler_->OnMuted(this, is_muted_); |
+ } |
+} |
+ |
// static |
AudioInputController::StreamType AudioInputController::ParamsToStreamType( |
const AudioParameters& params) { |