From ce6c4dfba63d1ce0effe737c76a86beb9e7cbd62 Mon Sep 17 00:00:00 2001 From: rossb Date: Sun, 26 Dec 2010 06:43:58 +0000 Subject: [PATCH] disable dither conversion when host input format is 32 bit and user format is 24 bit. the converter for this is unimplemented anyway, and the host won't ever be sending us better than 24 bit data, so no need to dither it. --- src/common/pa_process.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/common/pa_process.c b/src/common/pa_process.c index 3830532..86995a7 100644 --- a/src/common/pa_process.c +++ b/src/common/pa_process.c @@ -137,6 +137,7 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp, PaError result = paNoError; PaError bytesPerSample; unsigned long tempInputBufferSize, tempOutputBufferSize; + PaStreamFlags tempInputStreamFlags; if( streamFlags & paNeverDropInput ) { @@ -257,8 +258,20 @@ PaError PaUtil_InitializeBufferProcessor( PaUtilBufferProcessor* bp, goto error; } + /* Under the assumption that no ADC in existence delivers better than 24bits resoultion, + we disable dithering when host input format is paInt32 and user format is paInt24, + since the host samples will just be padded with zeros anyway. */ + + tempInputStreamFlags = streamFlags; + if( !(tempInputStreamFlags & paDitherOff) /* dither is on */ + && (hostInputSampleFormat & paInt32) /* host input format is int32 */ + && (userInputSampleFormat & paInt24) /* user requested format is int24 */ ){ + + tempInputStreamFlags = tempInputStreamFlags | paDitherOff; + } + bp->inputConverter = - PaUtil_SelectConverter( hostInputSampleFormat, userInputSampleFormat, streamFlags ); + PaUtil_SelectConverter( hostInputSampleFormat, userInputSampleFormat, tempInputStreamFlags ); bp->inputZeroer = PaUtil_SelectZeroer( hostInputSampleFormat ); -- 2.43.0