From 5583cd452bd222cf6eaadbf4400b78c14620e510 Mon Sep 17 00:00:00 2001 From: gineera Date: Mon, 18 Nov 2013 11:42:27 +0000 Subject: [PATCH] Pa_process: Fix input channel adaption by not skipping the input conversion when the host and user number-of-channels are not equal. The bug manifested when recording mono from a stereo-only device (eg with Alsa hw: devices on some sound-cards), and was reported by the Mixxx team -see https://bugs.launchpad.net/mixxx/+bug/900364. (In the long-term, some refactoring may be preferable.) Also fixed copy-paste typos in comments. --- src/common/pa_process.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/pa_process.c b/src/common/pa_process.c index 1009602..b1b5642 100644 --- a/src/common/pa_process.c +++ b/src/common/pa_process.c @@ -743,8 +743,10 @@ static unsigned long NonAdaptingProcess( PaUtilBufferProcessor *bp, destSampleStrideSamples = bp->inputChannelCount; destChannelStrideBytes = bp->bytesPerUserInputSample; - /* process host buffer directly, or use temp buffer if formats differ or host buffer non-interleaved */ - if( bp->userInputSampleFormatIsEqualToHost && bp->hostInputIsInterleaved && bp->hostInputChannels[0][0].data) + /* process host buffer directly, or use temp buffer if formats differ or host buffer non-interleaved, + * or if the number of channels differs between the host (set in stride) and the user */ + if( bp->userInputSampleFormatIsEqualToHost && bp->hostInputIsInterleaved + && bp->hostInputChannels[0][0].data && bp->inputChannelCount == hostInputChannels[0].stride ) { userInput = hostInputChannels[0].data; destBytePtr = (unsigned char *)hostInputChannels[0].data; @@ -1683,9 +1685,9 @@ unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bp, hostInputChannels[i].stride, framesToCopy, &bp->ditherGenerator ); - destBytePtr += destChannelStrideBytes; /* skip to next source channel */ + destBytePtr += destChannelStrideBytes; /* skip to next dest channel */ - /* advance dest ptr for next iteration */ + /* advance source ptr for next iteration */ hostInputChannels[i].data = ((unsigned char*)hostInputChannels[i].data) + framesToCopy * hostInputChannels[i].stride * bp->bytesPerHostInputSample; } @@ -1715,7 +1717,7 @@ unsigned long PaUtil_CopyInput( PaUtilBufferProcessor* bp, destBytePtr += bp->bytesPerUserInputSample * framesToCopy; nonInterleavedDestPtrs[i] = destBytePtr; - /* advance dest ptr for next iteration */ + /* advance source ptr for next iteration */ hostInputChannels[i].data = ((unsigned char*)hostInputChannels[i].data) + framesToCopy * hostInputChannels[i].stride * bp->bytesPerHostInputSample; } -- 2.43.0