From a89ab965f214288523205afc445e17c38437856d Mon Sep 17 00:00:00 2001 From: "henrik.lundin" Date: Wed, 18 May 2016 08:52:45 -0700 Subject: [PATCH] Enable muted state by default in VoE This change turns muted state on by default in VoiceEngine, but not for NetEq or AudioCodingModule when used stand-alone. The expected effect is that voice channels that have not received any packets for some time should reduce their CPU usage. This should have a noticeable effect on endpoints with many incoming streams, but where only a few have packets incoming at any given time (i.e., where an intermediate server filters out the majority of the streams). BUG=webrtc:5606 NOTRY=True Review-Url: https://codereview.webrtc.org/1987143003 Cr-Commit-Position: refs/heads/master@{#12797} --- webrtc/voice_engine/channel.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index abc843aef3..c2b9542053 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -496,7 +496,13 @@ MixerParticipant::AudioFrameInfo Channel::GetAudioFrameWithMuted( // irrelevant. return MixerParticipant::AudioFrameInfo::kError; } - RTC_DCHECK(!muted); + + if (muted) { + // TODO(henrik.lundin): We should be able to do better than this. But we + // will have to go through all the cases below where the audio samples may + // be used, and handle the muted case in some way. + audioFrame->Mute(); + } if (_RxVadDetection) { UpdateRxVadDetection(*audioFrame); @@ -567,6 +573,7 @@ MixerParticipant::AudioFrameInfo Channel::GetAudioFrameWithMuted( // Mix decoded PCM output with file if file mixing is enabled if (state.output_file_playing) { MixAudioWithFile(*audioFrame, audioFrame->sample_rate_hz_); + muted = false; // We may have added non-zero samples. } // External media @@ -591,6 +598,7 @@ MixerParticipant::AudioFrameInfo Channel::GetAudioFrameWithMuted( } // Measure audio level (0-9) + // TODO(henrik.lundin) Use the |muted| information here too. _outputAudioLevel.ComputeLevel(*audioFrame); if (capture_start_rtp_time_stamp_ < 0 && audioFrame->timestamp_ != 0) { @@ -816,7 +824,7 @@ Channel::Channel(int32_t channelId, } acm_config.neteq_config.enable_fast_accelerate = config.Get().enabled; - acm_config.neteq_config.enable_muted_state = false; + acm_config.neteq_config.enable_muted_state = true; audio_coding_.reset(AudioCodingModule::Create(acm_config)); _outputAudioLevel.Clear();