diff --git a/src/modules/audio_coding/main/source/audio_coding_module_impl.cc b/src/modules/audio_coding/main/source/audio_coding_module_impl.cc index 7878210e9d..1d4514b4b9 100644 --- a/src/modules/audio_coding/main/source/audio_coding_module_impl.cc +++ b/src/modules/audio_coding/main/source/audio_coding_module_impl.cc @@ -902,10 +902,16 @@ with the previously registered codec"); _isFirstRED = true; } + // If packet size or number of channels has changed, we need to + // re-initialize the encoder. if(_sendCodecInst.pacsize != sendCodec.pacsize) { forceInit = true; } + if(_sendCodecInst.channels != sendCodec.channels) + { + forceInit = true; + } if(forceInit) { @@ -927,6 +933,7 @@ with the previously registered codec"); _sendCodecInst.plfreq = sendCodec.plfreq; _sendCodecInst.pacsize = sendCodec.pacsize; + _sendCodecInst.channels = sendCodec.channels; } // If the change of sampling frequency has been successful then diff --git a/src/modules/audio_coding/main/test/TestStereo.cpp b/src/modules/audio_coding/main/test/TestStereo.cpp index a8618f08ad..c39d412148 100644 --- a/src/modules/audio_coding/main/test/TestStereo.cpp +++ b/src/modules/audio_coding/main/test/TestStereo.cpp @@ -456,10 +456,14 @@ WebRtc_Word16 TestStereo::RegisterSendCodec(char side, CHECK_ERROR(AudioCodingModule::Codec(codecName, myCodecParam, samplingFreqHz)); myCodecParam.rate = rate; myCodecParam.pacsize = packSize; + // Start with register codec as mono, to test that changing to stereo works. + myCodecParam.channels = 1; + CHECK_ERROR(myACM->RegisterSendCodec(myCodecParam)); + // Register codec as stereo. myCodecParam.channels = 2; CHECK_ERROR(myACM->RegisterSendCodec(myCodecParam)); - // initialization was succesful + // Initialization was successful. return 0; }