From 0e28566247b7b6ea893d9394c1ac0ab74612fde1 Mon Sep 17 00:00:00 2001 From: "andrew@webrtc.org" Date: Wed, 29 Feb 2012 17:00:56 +0000 Subject: [PATCH] Only reset AudioProcessing if number of channels has changed. Calling SetSendCodec() would always reset AudioProcessing. BUG= TEST=voe_auto_test Review URL: https://webrtc-codereview.appspot.com/417002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1799 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/source/voe_codec_impl.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/voice_engine/main/source/voe_codec_impl.cc b/src/voice_engine/main/source/voe_codec_impl.cc index 66a2370504..6b308cc395 100644 --- a/src/voice_engine/main/source/voe_codec_impl.cc +++ b/src/voice_engine/main/source/voe_codec_impl.cc @@ -193,13 +193,20 @@ int VoECodecImpl::SetSendCodec(int channel, const CodecInst& codec) // This will happen with a stereo codec and a device which doesn't support // stereo. AudioCoding should probably do the faking; look into how to // handle this case properly. - if (_audioProcessingModulePtr->set_num_channels( - _audioProcessingModulePtr->num_input_channels(), - maxNumChannels) != 0) + // + // Check if the number of channels has changed to avoid an unnecessary + // reset. + // TODO(andrew): look at handling this logic in AudioProcessing. + if (_audioProcessingModulePtr->num_output_channels() != maxNumChannels) { - _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceError, - "Init() failed to set APM channels for the send audio stream"); - return -1; + if (_audioProcessingModulePtr->set_num_channels( + _audioProcessingModulePtr->num_input_channels(), + maxNumChannels) != 0) + { + _engineStatistics.SetLastError(VE_SOUNDCARD_ERROR, kTraceError, + "Init() failed to set APM channels for the send audio stream"); + return -1; + } } return 0;