From 508286661ae7ad8401ba6b548e42c3e0c6314017 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 31 Jan 2016 15:42:23 -0500 Subject: [PATCH] Bug1104: If one stereo channel is shorter, don't buzz or stop playback short... ... A better fix this time! --- src/AudioIO.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index 6ce02ca2d..4afc5384c 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -4222,10 +4222,17 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer, len = gAudioIO->mPlaybackBuffers[t]->Get((samplePtr)tempBufs[chanCnt], floatSample, (int)framesPerBuffer); + if (len < framesPerBuffer) + // Pad with zeroes to the end, in case of a short channel + memset((void*)&tempBufs[chanCnt][len], 0, + (framesPerBuffer - len) * sizeof(float)); + chanCnt++; } - // There should not be a difference of len in different loop passes... - // but anyway take a max. + + // PRL: Bug1104: + // There can be a difference of len in different loop passes if one channel + // of a stereo track ends before the other! Take a max! maxLen = std::max(maxLen, len); @@ -4257,6 +4264,9 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer, } #endif + // Last channel seen now + len = maxLen; + if( !cut && selected ) { len = em.RealtimeProcess(group, chanCnt, tempBufs, len);