diff --git a/webrtc/voice_engine/transmit_mixer.cc b/webrtc/voice_engine/transmit_mixer.cc index b9618c812b..e8b3365bee 100644 --- a/webrtc/voice_engine/transmit_mixer.cc +++ b/webrtc/voice_engine/transmit_mixer.cc @@ -494,7 +494,6 @@ void TransmitMixer::EncodeAndSend(const int voe_channels[], uint32_t TransmitMixer::CaptureLevel() const { - CriticalSectionScoped cs(&_critSect); return _captureLevel; } @@ -1341,11 +1340,10 @@ void TransmitMixer::ProcessAudio(int delay_ms, int clock_drift, assert(false); } - CriticalSectionScoped cs(&_critSect); - // Store new capture level. Only updated when analog AGC is enabled. _captureLevel = agc->stream_analog_level(); + CriticalSectionScoped cs(&_critSect); // Triggers a callback in OnPeriodicProcess(). _saturationWarning |= agc->stream_is_saturated(); } diff --git a/webrtc/voice_engine/transmit_mixer.h b/webrtc/voice_engine/transmit_mixer.h index 0f70312eaa..dc46cf702b 100644 --- a/webrtc/voice_engine/transmit_mixer.h +++ b/webrtc/voice_engine/transmit_mixer.h @@ -70,6 +70,7 @@ public: // channels for encoding and sending to the network. void EncodeAndSend(const int voe_channels[], int number_of_voe_channels); + // Must be called on the same thread as PrepareDemux(). uint32_t CaptureLevel() const; int32_t StopSend(); diff --git a/webrtc/voice_engine/voe_base_impl.cc b/webrtc/voice_engine/voe_base_impl.cc index 682a4a5af7..9434863882 100644 --- a/webrtc/voice_engine/voe_base_impl.cc +++ b/webrtc/voice_engine/voe_base_impl.cc @@ -1150,17 +1150,11 @@ int VoEBaseImpl::ProcessRecordedDataWithAPM( assert(_shared->transmit_mixer() != NULL); assert(_shared->audio_device() != NULL); - bool is_analog_agc(false); - if (_shared->audio_processing() && - _shared->audio_processing()->gain_control()->mode() == - GainControl::kAdaptiveAnalog) { - is_analog_agc = true; - } - - // Only deal with the volume in adaptive analog mode. uint32_t max_volume = 0; uint16_t current_voe_mic_level = 0; - if (is_analog_agc) { + // Check for zero to skip this calculation; the consumer may use this to + // indicate no volume is available. + if (current_volume != 0) { // Scale from ADM to VoE level range if (_shared->audio_device()->MaxMicrophoneVolume(&max_volume) == 0) { if (max_volume) { @@ -1209,9 +1203,6 @@ int VoEBaseImpl::ProcessRecordedDataWithAPM( number_of_voe_channels); } - if (!is_analog_agc) - return 0; - // Scale from VoE to ADM level range. uint32_t new_voe_mic_level = _shared->transmit_mixer()->CaptureLevel();