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
This commit is contained in:
andrew@webrtc.org 2014-01-11 01:25:53 +00:00
parent 573a1b45b5
commit 023cc5abc7
3 changed files with 5 additions and 15 deletions

View File

@ -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();
}

View File

@ -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();

View File

@ -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();