From 0e0390dc33cc751e23e799b38354005072bc2bdc Mon Sep 17 00:00:00 2001 From: "tina.legrand@webrtc.org" Date: Thu, 15 Mar 2012 11:23:51 +0000 Subject: [PATCH] Flush NetEQ when receiving payload type switches between mono and stereo. TEST=voe_cmd_test Review URL: https://webrtc-codereview.appspot.com/448004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1893 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/modules/audio_coding/main/source/acm_neteq.cc | 2 +- .../audio_coding/main/source/audio_coding_module_impl.cc | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/audio_coding/main/source/acm_neteq.cc b/src/modules/audio_coding/main/source/acm_neteq.cc index be25918aef..69942bda1f 100644 --- a/src/modules/audio_coding/main/source/acm_neteq.cc +++ b/src/modules/audio_coding/main/source/acm_neteq.cc @@ -669,7 +669,7 @@ ACMNetEQ::RecOut( // Check for errors that can be recovered from: // RECOUT_ERROR_SAMPLEUNDERRUN = 2003 - int errorCode = WebRtcNetEQ_GetErrorCode(_inst[0]); + int errorCode = WebRtcNetEQ_GetErrorCode(_inst[1]); if(errorCode != 2003) { // Cannot recover; return an error 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 5f60ce965a..85950c8604 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 @@ -1842,6 +1842,13 @@ AudioCodingModuleImpl::IncomingPacket( _codecs[i]->UpdateDecoderSampFreq(i); _netEq.SetReceivedStereo(_stereoReceive[i]); + // If we have a change in expected number of channels, + // flush packet buffers in NetEQ. + if ((_stereoReceive[i] && (_expected_channels == 1)) || + (!_stereoReceive[i] && (_expected_channels == 2))) { + _netEq.FlushBuffers(); + } + // Store number of channels we expect to receive for the // current payload type. if (_stereoReceive[i]) {