From 8c6cee4e4dbe094b75dbf89754787a4f098434e8 Mon Sep 17 00:00:00 2001 From: Ken Cooke Date: Fri, 26 Jul 2019 12:45:21 -0700 Subject: [PATCH] Bypass WebRTC processing when not enabled. Note: WebRTC processing with all features disabled still holds locks and performs resampling in the callback. --- libraries/audio-client/src/AudioClient.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 2d21958f92..c16e297c28 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -1135,8 +1135,6 @@ void AudioClient::configureWebrtc() { config.level_estimation.enabled = false; _apm->ApplyConfig(config); - - qCDebug(audioclient) << "WebRTC enabled for acoustic echo cancellation."; } // rebuffer into 10ms chunks @@ -1207,7 +1205,7 @@ void AudioClient::processWebrtcNearEnd(int16_t* samples, int numFrames, int numC // process one chunk int error = _apm->ProcessStream(buffers, streamConfig, streamConfig, buffers); - if (error =! _apm->kNoError) { + if (error != _apm->kNoError) { qCWarning(audioclient) << "WebRTC ProcessStream() returned ERROR:" << error; } else { // modify samples in-place @@ -1396,8 +1394,10 @@ void AudioClient::handleMicAudioInput() { _inputRingBuffer.readSamples(inputAudioSamples.get(), inputSamplesRequired); #if defined(WEBRTC_ENABLED) - processWebrtcNearEnd(inputAudioSamples.get(), inputSamplesRequired / _inputFormat.channelCount(), - _inputFormat.channelCount(), _inputFormat.sampleRate()); + if (_isAECEnabled) { + processWebrtcNearEnd(inputAudioSamples.get(), inputSamplesRequired / _inputFormat.channelCount(), + _inputFormat.channelCount(), _inputFormat.sampleRate()); + } #endif // detect loudness and clipping on the raw input @@ -2326,7 +2326,9 @@ qint64 AudioClient::AudioOutputIODevice::readData(char * data, qint64 maxSize) { _audio->_audioLimiter.render(mixBuffer, scratchBuffer, framesPopped); #if defined(WEBRTC_ENABLED) - _audio->processWebrtcFarEnd(scratchBuffer, framesPopped, OUTPUT_CHANNEL_COUNT, _audio->_outputFormat.sampleRate()); + if (_audio->_isAECEnabled) { + _audio->processWebrtcFarEnd(scratchBuffer, framesPopped, OUTPUT_CHANNEL_COUNT, _audio->_outputFormat.sampleRate()); + } #endif // if required, upmix or downmix to deviceChannelCount