Minor voice engine improvements around AGC.
- Remove one unneeded lock in CaptureLevel(), as the call to this
method should always come on the same thread as PrepareDemux().
- Remove check on analog AGC before doing volume calculations. Saves a
bit of code. Instead check if the incoming volume is set to zero, which
is a potentially common occurrence as it indicates no volume is
available.
R=aluebs@webrtc.org, xians@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/6859004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5366 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/voice_engine/transmit_mixer.cc b/webrtc/voice_engine/transmit_mixer.cc
index b9618c8..e8b3365 100644
--- a/webrtc/voice_engine/transmit_mixer.cc
+++ b/webrtc/voice_engine/transmit_mixer.cc
@@ -494,7 +494,6 @@
uint32_t TransmitMixer::CaptureLevel() const
{
- CriticalSectionScoped cs(&_critSect);
return _captureLevel;
}
@@ -1341,11 +1340,10 @@
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 0f70312..dc46cf7 100644
--- a/webrtc/voice_engine/transmit_mixer.h
+++ b/webrtc/voice_engine/transmit_mixer.h
@@ -70,6 +70,7 @@
// 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 682a4a5..9434863 100644
--- a/webrtc/voice_engine/voe_base_impl.cc
+++ b/webrtc/voice_engine/voe_base_impl.cc
@@ -1150,17 +1150,11 @@
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 @@
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();