Update of /cvsroot/pure-data/pd/portaudio/pa_common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8219/pa_common
Modified Files: Tag: devel_0_38 pa_allocation.c pa_converters.c pa_dither.c pa_front.c pa_process.c pa_process.h portaudio.h Log Message: updating to latest portaudio snapshot
Index: pa_allocation.c =================================================================== RCS file: /cvsroot/pure-data/pd/portaudio/pa_common/pa_allocation.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** pa_allocation.c 6 Sep 2004 21:03:01 -0000 1.3 --- pa_allocation.c 28 Jun 2005 16:30:33 -0000 1.3.4.1 *************** *** 185,194 **** if( current->buffer == buffer ) { ! previous->next = current->next;
current->buffer = 0; current->next = group->spareLinks; group->spareLinks = current; } previous = current; current = current->next; --- 185,204 ---- if( current->buffer == buffer ) { ! if( previous ) ! { ! previous->next = current->next; ! } ! else ! { ! group->allocations = current->next; ! }
current->buffer = 0; current->next = group->spareLinks; group->spareLinks = current; + + break; } + previous = current; current = current->next;
Index: pa_process.h =================================================================== RCS file: /cvsroot/pure-data/pd/portaudio/pa_common/pa_process.h,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** pa_process.h 6 Sep 2004 20:44:38 -0000 1.3 --- pa_process.h 28 Jun 2005 16:30:33 -0000 1.3.4.1 *************** *** 280,286 ****
unsigned long hostInputFrameCount[2]; ! PaUtilChannelDescriptor *hostInputChannels[2]; unsigned long hostOutputFrameCount[2]; ! PaUtilChannelDescriptor *hostOutputChannels[2];
PaUtilTriangularDitherGenerator ditherGenerator; --- 280,294 ----
unsigned long hostInputFrameCount[2]; ! PaUtilChannelDescriptor *hostInputChannels[2]; /**< pointers to arrays of channel descriptors. ! pointers are NULL for half-duplex output processing. ! hostInputChannels[i].data is NULL when the caller ! calls PaUtil_SetNoInput() ! */ unsigned long hostOutputFrameCount[2]; ! PaUtilChannelDescriptor *hostOutputChannels[2]; /**< pointers to arrays of channel descriptors. ! pointers are NULL for half-duplex input processing. ! hostOutputChannels[i].data is NULL when the caller ! calls PaUtil_SetNoOutput() ! */
PaUtilTriangularDitherGenerator ditherGenerator; *************** *** 541,545 ****
! /** Provide the buffer processor with a pointer to an number of interleaved host output channels.
--- 549,553 ----
! /** Provide the buffer processor with a pointer to a number of interleaved host output channels.
*************** *** 624,628 **** but any audio that was generated by previous stream callbacks will be copied to the output buffer(s). You can check whether the buffer processor's internal ! buffer is empty by calling PaUtil_IsBufferProcessorOuputEmpty.
If the stream callback is called its result is stored in *callbackResult. If --- 632,636 ---- but any audio that was generated by previous stream callbacks will be copied to the output buffer(s). You can check whether the buffer processor's internal ! buffer is empty by calling PaUtil_IsBufferProcessorOutputEmpty.
If the stream callback is called its result is stored in *callbackResult. If *************** *** 651,655 **** data. */ ! int PaUtil_IsBufferProcessorOuputEmpty( PaUtilBufferProcessor* bufferProcessor );
/*@}*/ --- 659,663 ---- data. */ ! int PaUtil_IsBufferProcessorOutputEmpty( PaUtilBufferProcessor* bufferProcessor );
/*@}*/
Index: pa_dither.c =================================================================== RCS file: /cvsroot/pure-data/pd/portaudio/pa_common/pa_dither.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** pa_dither.c 6 Sep 2004 20:44:38 -0000 1.3 --- pa_dither.c 28 Jun 2005 16:30:33 -0000 1.3.4.1 *************** *** 36,39 **** --- 36,40 ----
#include "pa_dither.h" + #include "pa_types.h"
#define PA_DITHER_BITS_ (15) *************** *** 60,64 **** * Also shift an extra bit for the high pass filter. */ ! #define DITHER_SHIFT_ ((32 - PA_DITHER_BITS_) + 1) current = (((signed long)state->randSeed1)>>DITHER_SHIFT_) + (((signed long)state->randSeed2)>>DITHER_SHIFT_); --- 61,65 ---- * Also shift an extra bit for the high pass filter. */ ! #define DITHER_SHIFT_ ((SIZEOF_LONG*8 - PA_DITHER_BITS_) + 1) current = (((signed long)state->randSeed1)>>DITHER_SHIFT_) + (((signed long)state->randSeed2)>>DITHER_SHIFT_); *************** *** 87,91 **** * Also shift an extra bit for the high pass filter. */ ! #define DITHER_SHIFT_ ((32 - PA_DITHER_BITS_) + 1) current = (((signed long)state->randSeed1)>>DITHER_SHIFT_) + (((signed long)state->randSeed2)>>DITHER_SHIFT_); --- 88,92 ---- * Also shift an extra bit for the high pass filter. */ ! #define DITHER_SHIFT_ ((SIZEOF_LONG*8 - PA_DITHER_BITS_) + 1) current = (((signed long)state->randSeed1)>>DITHER_SHIFT_) + (((signed long)state->randSeed2)>>DITHER_SHIFT_);
Index: portaudio.h =================================================================== RCS file: /cvsroot/pure-data/pd/portaudio/pa_common/portaudio.h,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** portaudio.h 6 Sep 2004 20:44:38 -0000 1.3 --- portaudio.h 28 Jun 2005 16:30:33 -0000 1.3.4.1 *************** *** 1,2 **** --- 1,3 ---- + #ifndef PORTAUDIO_H #define PORTAUDIO_H *************** *** 223,227 **** paALSA=8, paAL=9, ! paBeOS=10 } PaHostApiTypeId;
--- 224,230 ---- paALSA=8, paAL=9, ! paBeOS=10, ! paWDMKS=11, ! paJACK=12 } PaHostApiTypeId;
*************** *** 361,365 **** used in the inputDevice parameter to Pa_OpenStream().
! @return The default input device index for the defualt host API, or paNoDevice if no default input device is available or an error was encountered. */ --- 364,368 ---- used in the inputDevice parameter to Pa_OpenStream().
! @return The default input device index for the default host API, or paNoDevice if no default input device is available or an error was encountered. */ *************** *** 487,495 **** a_ReadStream() or Pa_WriteStream(). It may be any of the formats described by the PaSampleFormat enumeration. - FIXME: wrt below, what are we guaranteeing these days, if anything? - PortAudio guarantees support for - the device's native formats (nativeSampleFormats in the device info record) - and additionally 16 and 32 bit integer and 32 bit floating point formats. - Support for other formats is implementation defined. */ PaSampleFormat sampleFormat; --- 490,493 ---- *************** *** 718,722 **** @return The stream callback should return one of the values in the ! PaStreamCallbackResult enumeration. To ensure that the callback is continues to be called, it should return paContinue (0). Either paComplete or paAbort can be returned to finish stream processing, after either of these values is --- 716,720 ---- @return The stream callback should return one of the values in the ! PaStreamCallbackResult enumeration. To ensure that the callback continues to be called, it should return paContinue (0). Either paComplete or paAbort can be returned to finish stream processing, after either of these values is *************** *** 825,833 **** @param sampleFormat The sample format of both the input and output buffers provided to the callback or passed to and from Pa_ReadStream and Pa_WriteStream. ! sampleFormat may be any of the formats described by the PaSampleFormat enumeration ! (see above). ! FIXME: the following may need to be rewritten - PortAudio guarantees support for ! the device's native formats (nativeSampleFormats in the device info record) ! and additionally 16 and 32 bit integer and 32 bit float
@param sampleRate Same as Pa_OpenStream parameter of the same name. --- 823,828 ---- @param sampleFormat The sample format of both the input and output buffers provided to the callback or passed to and from Pa_ReadStream and Pa_WriteStream. ! sampleFormat may be any of the formats described by the PaSampleFormat ! enumeration.
@param sampleRate Same as Pa_OpenStream parameter of the same name.
Index: pa_converters.c =================================================================== RCS file: /cvsroot/pure-data/pd/portaudio/pa_common/pa_converters.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** pa_converters.c 6 Sep 2004 21:03:01 -0000 1.3 --- pa_converters.c 28 Jun 2005 16:30:33 -0000 1.3.4.1 *************** *** 53,56 **** --- 53,57 ---- #include "pa_dither.h" #include "pa_endianness.h" + #include "pa_types.h"
*************** *** 1660,1665 **** unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ) { ! unsigned short *src = (unsigned short*)sourceBuffer; ! unsigned short *dest = (unsigned short*)destinationBuffer;
(void) ditherGenerator; /* unused parameter */ --- 1661,1666 ---- unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ) { ! PaUint16 *src = (PaUint16 *)sourceBuffer; ! PaUint16 *dest = (PaUint16 *)destinationBuffer;
(void) ditherGenerator; /* unused parameter */ *************** *** 1704,1709 **** unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ) { ! unsigned long *dest = (unsigned long*)destinationBuffer; ! unsigned long *src = (unsigned long*)sourceBuffer;
(void) ditherGenerator; /* unused parameter */ --- 1705,1710 ---- unsigned int count, struct PaUtilTriangularDitherGenerator *ditherGenerator ) { ! PaUint32 *dest = (PaUint32 *)destinationBuffer; ! PaUint32 *src = (PaUint32 *)sourceBuffer;
(void) ditherGenerator; /* unused parameter */ *************** *** 1869,1873 **** unsigned int count ) { ! unsigned short *dest = (unsigned short*)destinationBuffer;
while( count-- ) --- 1870,1874 ---- unsigned int count ) { ! PaUint16 *dest = (PaUint16 *)destinationBuffer;
while( count-- ) *************** *** 1901,1905 **** unsigned int count ) { ! unsigned long *dest = (unsigned long*)destinationBuffer;
while( count-- ) --- 1902,1906 ---- unsigned int count ) { ! PaUint32 *dest = (PaUint32 *)destinationBuffer;
while( count-- )
Index: pa_process.c =================================================================== RCS file: /cvsroot/pure-data/pd/portaudio/pa_common/pa_process.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** pa_process.c 6 Sep 2004 20:44:38 -0000 1.3 --- pa_process.c 28 Jun 2005 16:30:33 -0000 1.3.4.1 *************** *** 146,152 **** bp->hostBufferSizeMode = hostBufferSizeMode;
! bp->hostInputChannels[0] = 0; ! bp->hostOutputChannels[0] = 0; ! if( framesPerUserBuffer == 0 ) /* streamCallback will accept any buffer size */ { --- 146,152 ---- bp->hostBufferSizeMode = hostBufferSizeMode;
! bp->hostInputChannels[0] = bp->hostInputChannels[1] = 0; ! bp->hostOutputChannels[0] = bp->hostOutputChannels[1] = 0; ! if( framesPerUserBuffer == 0 ) /* streamCallback will accept any buffer size */ { *************** *** 819,864 ****
/* convert output data (user -> host) */ ! if( bp->outputChannelCount != 0 ) { ! if( !bp->hostOutputChannels[0][0].data ) { ! /* do nothing, this are no host output buffers */ } ! else { ! /* ! could use more elaborate logic here and sometimes process ! buffers in-place. ! */ ! ! srcBytePtr = (unsigned char *)bp->tempOutputBuffer; ! ! if( bp->userOutputIsInterleaved ) ! { ! srcSampleStrideSamples = bp->outputChannelCount; ! srcChannelStrideBytes = bp->bytesPerUserOutputSample; ! } ! else /* user output is not interleaved */ ! { ! srcSampleStrideSamples = 1; ! srcChannelStrideBytes = frameCount * bp->bytesPerUserOutputSample; ! }
! for( i=0; i<bp->outputChannelCount; ++i ) ! { ! bp->outputConverter( hostOutputChannels[i].data, ! hostOutputChannels[i].stride, ! srcBytePtr, srcSampleStrideSamples, ! frameCount, &bp->ditherGenerator );
! srcBytePtr += srcChannelStrideBytes; /* skip to next source channel */
! /* advance dest ptr for next iteration */ ! hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) + ! frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample; ! } } } ! framesProcessed += frameCount;
--- 819,858 ----
/* convert output data (user -> host) */ ! ! if( bp->outputChannelCount != 0 && bp->hostOutputChannels[0][0].data ) { ! /* ! could use more elaborate logic here and sometimes process ! buffers in-place. ! */ ! ! srcBytePtr = (unsigned char *)bp->tempOutputBuffer; ! ! if( bp->userOutputIsInterleaved ) { ! srcSampleStrideSamples = bp->outputChannelCount; ! srcChannelStrideBytes = bp->bytesPerUserOutputSample; } ! else /* user output is not interleaved */ { ! srcSampleStrideSamples = 1; ! srcChannelStrideBytes = frameCount * bp->bytesPerUserOutputSample; ! }
! for( i=0; i<bp->outputChannelCount; ++i ) ! { ! bp->outputConverter( hostOutputChannels[i].data, ! hostOutputChannels[i].stride, ! srcBytePtr, srcSampleStrideSamples, ! frameCount, &bp->ditherGenerator );
! srcBytePtr += srcChannelStrideBytes; /* skip to next source channel */
! /* advance dest ptr for next iteration */ ! hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) + ! frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample; } } ! framesProcessed += frameCount;
*************** *** 871,880 **** if( framesToGo > 0 ) { ! /* zero any remaining frames. There will only be remaining frames if the callback has returned paComplete or paAbort */
frameCount = framesToGo;
! if( bp->hostOutputChannels[0][0].data ) { for( i=0; i<bp->outputChannelCount; ++i ) --- 865,874 ---- if( framesToGo > 0 ) { ! /* zero any remaining frames output. There will only be remaining frames if the callback has returned paComplete or paAbort */
frameCount = framesToGo;
! if( bp->outputChannelCount != 0 && bp->hostOutputChannels[0][0].data ) { for( i=0; i<bp->outputChannelCount; ++i ) *************** *** 1134,1137 **** --- 1128,1204 ---- }
+ /* CopyTempOutputBuffersToHostOutputBuffers is called from AdaptingProcess to copy frames from + tempOutputBuffer to hostOutputChannels. This includes data conversion + and interleaving. + */ + static void CopyTempOutputBuffersToHostOutputBuffers( PaUtilBufferProcessor *bp) + { + unsigned long maxFramesToCopy; + PaUtilChannelDescriptor *hostOutputChannels; + unsigned int frameCount; + unsigned char *srcBytePtr; + unsigned int srcSampleStrideSamples; /* stride from one sample to the next within a channel, in samples */ + unsigned int srcChannelStrideBytes; /* stride from one channel to the next, in bytes */ + unsigned int i; + + /* copy frames from user to host output buffers */ + while( bp->framesInTempOutputBuffer > 0 && + ((bp->hostOutputFrameCount[0] + bp->hostOutputFrameCount[1]) > 0) ) + { + maxFramesToCopy = bp->framesInTempOutputBuffer; + + /* select the output buffer set (1st or 2nd) */ + if( bp->hostOutputFrameCount[0] > 0 ) + { + hostOutputChannels = bp->hostOutputChannels[0]; + frameCount = PA_MIN_( bp->hostOutputFrameCount[0], maxFramesToCopy ); + } + else + { + hostOutputChannels = bp->hostOutputChannels[1]; + frameCount = PA_MIN_( bp->hostOutputFrameCount[1], maxFramesToCopy ); + } + + if( bp->userOutputIsInterleaved ) + { + srcBytePtr = ((unsigned char*)bp->tempOutputBuffer) + + bp->bytesPerUserOutputSample * bp->outputChannelCount * + (bp->framesPerUserBuffer - bp->framesInTempOutputBuffer); + + srcSampleStrideSamples = bp->outputChannelCount; + srcChannelStrideBytes = bp->bytesPerUserOutputSample; + } + else /* user output is not interleaved */ + { + srcBytePtr = ((unsigned char*)bp->tempOutputBuffer) + + bp->bytesPerUserOutputSample * + (bp->framesPerUserBuffer - bp->framesInTempOutputBuffer); + + srcSampleStrideSamples = 1; + srcChannelStrideBytes = bp->framesPerUserBuffer * bp->bytesPerUserOutputSample; + } + + for( i=0; i<bp->outputChannelCount; ++i ) + { + bp->outputConverter( hostOutputChannels[i].data, + hostOutputChannels[i].stride, + srcBytePtr, srcSampleStrideSamples, + frameCount, &bp->ditherGenerator ); + + srcBytePtr += srcChannelStrideBytes; /* skip to next source channel */ + + /* advance dest ptr for next iteration */ + hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) + + frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample; + } + + if( bp->hostOutputFrameCount[0] > 0 ) + bp->hostOutputFrameCount[0] -= frameCount; + else + bp->hostOutputFrameCount[1] -= frameCount; + + bp->framesInTempOutputBuffer -= frameCount; + } + }
/* *************** *** 1155,1161 **** PaUtilChannelDescriptor *hostInputChannels, *hostOutputChannels; unsigned int frameCount; ! unsigned char *srcBytePtr, *destBytePtr; ! unsigned int srcSampleStrideSamples; /* stride from one sample to the next within a channel, in samples */ ! unsigned int srcChannelStrideBytes; /* stride from one channel to the next, in bytes */ unsigned int destSampleStrideSamples; /* stride from one sample to the next within a channel, in samples */ unsigned int destChannelStrideBytes; /* stride from one channel to the next, in bytes */ --- 1222,1226 ---- PaUtilChannelDescriptor *hostInputChannels, *hostOutputChannels; unsigned int frameCount; ! unsigned char *destBytePtr; unsigned int destSampleStrideSamples; /* stride from one sample to the next within a channel, in samples */ unsigned int destChannelStrideBytes; /* stride from one channel to the next, in bytes */ *************** *** 1170,1233 **** endProcessingMinFrameCount = (bp->framesPerUserBuffer - 1);
! while( framesAvailable > endProcessingMinFrameCount ) ! { ! /* copy frames from user to host output buffers */ ! while( bp->framesInTempOutputBuffer > 0 && ! ((bp->hostOutputFrameCount[0] + bp->hostOutputFrameCount[1]) > 0) ) ! { ! maxFramesToCopy = bp->framesInTempOutputBuffer; ! ! /* select the output buffer set (1st or 2nd) */ ! if( bp->hostOutputFrameCount[0] > 0 ) ! { ! hostOutputChannels = bp->hostOutputChannels[0]; ! frameCount = PA_MIN_( bp->hostOutputFrameCount[0], maxFramesToCopy ); ! } ! else ! { ! hostOutputChannels = bp->hostOutputChannels[1]; ! frameCount = PA_MIN_( bp->hostOutputFrameCount[1], maxFramesToCopy ); ! } ! ! if( bp->userOutputIsInterleaved ) ! { ! srcBytePtr = ((unsigned char*)bp->tempOutputBuffer) + ! bp->bytesPerUserOutputSample * bp->outputChannelCount * ! (bp->framesPerUserBuffer - bp->framesInTempOutputBuffer); ! ! srcSampleStrideSamples = bp->outputChannelCount; ! srcChannelStrideBytes = bp->bytesPerUserOutputSample; ! } ! else /* user output is not interleaved */ ! { ! srcBytePtr = ((unsigned char*)bp->tempOutputBuffer) + ! bp->bytesPerUserOutputSample * ! (bp->framesPerUserBuffer - bp->framesInTempOutputBuffer); ! ! srcSampleStrideSamples = 1; ! srcChannelStrideBytes = bp->framesPerUserBuffer * bp->bytesPerUserOutputSample; ! } ! ! for( i=0; i<bp->outputChannelCount; ++i ) ! { ! bp->outputConverter( hostOutputChannels[i].data, ! hostOutputChannels[i].stride, ! srcBytePtr, srcSampleStrideSamples, ! frameCount, &bp->ditherGenerator ); ! ! srcBytePtr += srcChannelStrideBytes; /* skip to next source channel */ ! ! /* advance dest ptr for next iteration */ ! hostOutputChannels[i].data = ((unsigned char*)hostOutputChannels[i].data) + ! frameCount * hostOutputChannels[i].stride * bp->bytesPerHostOutputSample; ! } ! ! if( bp->hostOutputFrameCount[0] > 0 ) ! bp->hostOutputFrameCount[0] -= frameCount; ! else ! bp->hostOutputFrameCount[1] -= frameCount;
! bp->framesInTempOutputBuffer -= frameCount; ! }
if( bp->framesInTempOutputBuffer == 0 && *streamCallbackResult != paContinue ) --- 1235,1243 ---- endProcessingMinFrameCount = (bp->framesPerUserBuffer - 1);
! /* Fill host output with remaining frames in user output (tempOutputBuffer) */ ! CopyTempOutputBuffersToHostOutputBuffers( bp );
! while( framesAvailable > endProcessingMinFrameCount ) ! {
if( bp->framesInTempOutputBuffer == 0 && *streamCallbackResult != paContinue ) *************** *** 1385,1388 **** --- 1395,1404 ---- } } + + /* copy frames from user (tempOutputBuffer) to host output buffers (hostOutputChannels) + Means to process the user output provided by the callback. Has to be called after + each callback. */ + CopyTempOutputBuffersToHostOutputBuffers( bp ); + }
*************** *** 1563,1567 ****
! int PaUtil_IsBufferProcessorOuputEmpty( PaUtilBufferProcessor* bp ) { return (bp->framesInTempOutputBuffer) ? 0 : 1; --- 1579,1583 ----
! int PaUtil_IsBufferProcessorOutputEmpty( PaUtilBufferProcessor* bp ) { return (bp->framesInTempOutputBuffer) ? 0 : 1;
Index: pa_front.c =================================================================== RCS file: /cvsroot/pure-data/pd/portaudio/pa_common/pa_front.c,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** pa_front.c 6 Sep 2004 20:44:38 -0000 1.3 --- pa_front.c 28 Jun 2005 16:30:33 -0000 1.3.4.1 *************** *** 99,102 **** --- 99,103 ---- #include "pa_util.h" #include "pa_endianness.h" + #include "pa_types.h" #include "pa_hostapi.h" #include "pa_stream.h" *************** *** 375,378 **** --- 376,380 ---- else { + PA_VALIDATE_TYPE_SIZES; PA_VALIDATE_ENDIANNESS;
*************** *** 788,792 **** PaHostApiIndex hostApi; PaDeviceIndex result; ! #ifdef PA_LOG_API_CALLS PaUtil_DebugPrint("Pa_GetDefaultOutputDevice called.\n" ); --- 790,794 ---- PaHostApiIndex hostApi; PaDeviceIndex result; ! #ifdef PA_LOG_API_CALLS PaUtil_DebugPrint("Pa_GetDefaultOutputDevice called.\n" );