[Scopeapp-cvs]scopeapp/src/portaudio/pa_common pa_convert.c,1.1,1.2 pa_host.h,1.1,1.2 pa_lib.c,1.1,1
Status: Alpha
Brought to you by:
narge
From: <sco...@li...> - 2003-04-23 06:24:51
|
Update of /cvsroot/scopeapp/scopeapp/src/portaudio/pa_common In directory sc8-pr-cvs1:/tmp/cvs-serv13792/pa_common Modified Files: pa_convert.c pa_host.h pa_lib.c pa_trace.c pa_trace.h portaudio.h Log Message: Update portaudio to v18-patch (checked out 23/04/03) Index: pa_convert.c =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/portaudio/pa_common/pa_convert.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pa_convert.c 5 Dec 2002 14:46:42 -0000 1.1 --- pa_convert.c 23 Apr 2003 06:24:17 -0000 1.2 *************** *** 1,402 **** ! /* ! * pa_conversions.c ! * portaudio ! * ! * Created by Phil Burk on Mon Mar 18 2002. ! * ! */ ! #include <stdio.h> ! ! #include "portaudio.h" ! #include "pa_host.h" ! ! #define CLIP( val, min, max ) { val = ((val) < (min)) ? min : (((val) < (max)) ? (max) : (val)); } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int16( ! float *sourceBuffer, int sourceStride, ! short *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! short samp = (short) (*sourceBuffer * (32767.0f)); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int16_Clip( ! float *sourceBuffer, int sourceStride, ! short *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! long samp = (long) (*sourceBuffer * (32767.0f)); ! CLIP( samp, -0x8000, 0x7FFF ); ! *targetBuffer = (short) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int16_ClipDither( ! float *sourceBuffer, int sourceStride, ! short *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! // use smaller scaler to prevent overflow when we add the dither ! float dither = PaConvert_TriangularDither() * PA_DITHER_SCALE; ! float dithered = (*sourceBuffer * (32766.0f)) + dither; ! long samp = (long) dithered; ! CLIP( samp, -0x8000, 0x7FFF ); ! *targetBuffer = (short) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int16_Dither( ! float *sourceBuffer, int sourceStride, ! short *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! // use smaller scaler to prevent overflow when we add the dither ! float dither = PaConvert_TriangularDither() * PA_DITHER_SCALE; ! float dithered = (*sourceBuffer * (32766.0f)) + dither; ! *targetBuffer = (short) dithered; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! ! /*************************************************************************/ ! static void PaConvert_Int16_Float32( ! short *sourceBuffer, int sourceStride, ! float *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! float samp = *sourceBuffer * (1.0f / 32768.0f); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int8( ! float *sourceBuffer, int sourceStride, ! char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! char samp = (char) (*sourceBuffer * (127.0)); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int8_Clip( ! float *sourceBuffer, int sourceStride, ! char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! long samp = *sourceBuffer * 127.0f; ! CLIP( samp, -0x80, 0x7F ); ! *targetBuffer = (char) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int8_ClipDither( ! float *sourceBuffer, int sourceStride, ! char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! // use smaller scaler to prevent overflow when we add the dither ! float dither = PaConvert_TriangularDither() * PA_DITHER_SCALE; ! float dithered = (*sourceBuffer * (126.0f)) + dither; ! long samp = (long) dithered; ! CLIP( samp, -0x80, 0x7F ); ! *targetBuffer = (char) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int8_Dither( ! float *sourceBuffer, int sourceStride, ! char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! // use smaller scaler to prevent overflow when we add the dither ! float dither = PaConvert_TriangularDither() * PA_DITHER_SCALE; //FIXME ! float dithered = (*sourceBuffer * (126.0f)) + dither; ! long samp = (long) dithered; ! *targetBuffer = (char) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Int8_Float32( ! char *sourceBuffer, int sourceStride, ! float *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! float samp = *sourceBuffer * (1.0f / 128.0f); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_UInt8( ! float *sourceBuffer, int sourceStride, ! unsigned char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! unsigned char samp = 128 + (unsigned char) (*sourceBuffer * (127.0)); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_UInt8_Float32( ! unsigned char *sourceBuffer, int sourceStride, ! float *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! float samp = (*sourceBuffer - 128) * (1.0f / 128.0f); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static PortAudioConverter *PaConvert_SelectProc( PaSampleFormat sourceFormat, ! PaSampleFormat targetFormat, int ifClip, int ifDither ) ! { ! PortAudioConverter *proc = NULL; ! switch( sourceFormat ) ! { ! case paUInt8: ! switch( targetFormat ) ! { ! case paFloat32: ! proc = (PortAudioConverter *) PaConvert_UInt8_Float32; ! break; ! default: ! break; ! } ! break; ! case paInt8: ! switch( targetFormat ) ! { ! case paFloat32: ! proc = (PortAudioConverter *) PaConvert_Int8_Float32; ! break; ! default: ! break; ! } ! break; ! case paInt16: ! switch( targetFormat ) ! { ! case paFloat32: ! proc = (PortAudioConverter *) PaConvert_Int16_Float32; ! break; ! default: ! break; ! } ! break; ! case paFloat32: ! switch( targetFormat ) ! { ! case paUInt8: ! proc = (PortAudioConverter *) PaConvert_Float32_UInt8; ! break; ! case paInt8: ! if( ifClip && ifDither ) proc = (PortAudioConverter *) PaConvert_Float32_Int8_ClipDither; ! else if( ifClip ) proc = (PortAudioConverter *) PaConvert_Float32_Int8_Clip; ! else if( ifDither ) proc = (PortAudioConverter *) PaConvert_Float32_Int8_Dither; ! else proc = (PortAudioConverter *) PaConvert_Float32_Int8; ! break; ! case paInt16: ! if( ifClip && ifDither ) proc = (PortAudioConverter *) PaConvert_Float32_Int16_ClipDither; ! else if( ifClip ) proc = (PortAudioConverter *) PaConvert_Float32_Int16_Clip; ! else if( ifDither ) proc = (PortAudioConverter *) PaConvert_Float32_Int16_Dither; ! else proc = (PortAudioConverter *) PaConvert_Float32_Int16; ! break; ! default: ! break; ! } ! break; ! default: ! break; ! } ! return proc; ! ! } ! ! /*************************************************************************/ ! PaError PaConvert_SetupInput( internalPortAudioStream *past, ! PaSampleFormat nativeInputSampleFormat ) ! { ! past->past_NativeInputSampleFormat = nativeInputSampleFormat; ! past->past_InputConversionSourceStride = 1; ! past->past_InputConversionTargetStride = 1; ! ! if( nativeInputSampleFormat != past->past_InputSampleFormat ) ! { ! int ifDither = (past->past_Flags & paDitherOff) == 0; ! past->past_InputConversionProc = PaConvert_SelectProc( nativeInputSampleFormat, ! past->past_InputSampleFormat, 0, ifDither ); ! if( past->past_InputConversionProc == NULL ) return paSampleFormatNotSupported; ! } ! else ! { ! past->past_InputConversionProc = NULL; /* no conversion necessary */ ! } ! ! return paNoError; ! } ! ! /*************************************************************************/ ! PaError PaConvert_SetupOutput( internalPortAudioStream *past, ! PaSampleFormat nativeOutputSampleFormat ) ! { ! ! past->past_NativeOutputSampleFormat = nativeOutputSampleFormat; ! past->past_OutputConversionSourceStride = 1; ! past->past_OutputConversionTargetStride = 1; ! ! if( nativeOutputSampleFormat != past->past_OutputSampleFormat ) ! { ! int ifDither = (past->past_Flags & paDitherOff) == 0; ! int ifClip = (past->past_Flags & paClipOff) == 0; ! ! past->past_OutputConversionProc = PaConvert_SelectProc( past->past_OutputSampleFormat, ! nativeOutputSampleFormat, ifClip, ifDither ); ! if( past->past_OutputConversionProc == NULL ) return paSampleFormatNotSupported; ! } ! else ! { ! past->past_OutputConversionProc = NULL; /* no conversion necessary */ ! } ! ! return paNoError; ! } ! ! /************************************************************************* ! ** Called by host code. ! ** Convert input from native format to user format, ! ** call user code, ! ** then convert output to native format. ! ** Returns result from user callback. ! */ ! long PaConvert_Process( internalPortAudioStream *past, ! void *nativeInputBuffer, ! void *nativeOutputBuffer ) ! { ! int userResult; ! void *inputBuffer = NULL; ! void *outputBuffer = NULL; ! ! /* Get native input data. */ ! if( (past->past_NumInputChannels > 0) && (nativeInputBuffer != NULL) ) ! { ! if( past->past_InputSampleFormat == past->past_NativeInputSampleFormat ) ! { ! /* Already in native format so just read directly from native buffer. */ ! inputBuffer = nativeInputBuffer; ! } ! else ! { ! inputBuffer = past->past_InputBuffer; ! /* Convert input data to user format. */ ! (*past->past_InputConversionProc)(nativeInputBuffer, past->past_InputConversionSourceStride, ! inputBuffer, past->past_InputConversionTargetStride, ! past->past_FramesPerUserBuffer * past->past_NumInputChannels ); ! } ! } ! ! /* Are we doing output? */ ! if( (past->past_NumOutputChannels > 0) && (nativeOutputBuffer != NULL) ) ! { ! outputBuffer = (past->past_OutputConversionProc == NULL) ? ! nativeOutputBuffer : past->past_OutputBuffer; ! } ! /* ! AddTraceMessage("Pa_CallConvertInt16: inputBuffer = ", (int) inputBuffer ); ! AddTraceMessage("Pa_CallConvertInt16: outputBuffer = ", (int) outputBuffer ); ! */ ! /* Call user callback routine. */ ! userResult = past->past_Callback( ! inputBuffer, ! outputBuffer, ! past->past_FramesPerUserBuffer, ! past->past_FrameCount, ! past->past_UserData ); ! ! /* Advance frame counter for timestamp. */ ! past->past_FrameCount += past->past_FramesPerUserBuffer; // FIXME - should this be in here? ! ! /* Convert to native format if necessary. */ ! if( (past->past_OutputConversionProc != NULL ) && (outputBuffer != NULL) ) ! { ! (*past->past_OutputConversionProc)( outputBuffer, past->past_OutputConversionSourceStride, ! nativeOutputBuffer, past->past_OutputConversionTargetStride, ! past->past_FramesPerUserBuffer * past->past_NumOutputChannels ); ! } ! ! return userResult; ! } --- 1,470 ---- ! /* ! * pa_conversions.c ! * portaudio ! * ! * Created by Phil Burk on Mon Mar 18 2002. ! * ! */ ! #include <stdio.h> ! ! #include "portaudio.h" ! #include "pa_host.h" ! ! #define CLIP( val, min, max ) { val = ((val) < (min)) ? min : (((val) < (max)) ? (max) : (val)); } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int16( ! float *sourceBuffer, int sourceStride, ! short *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! short samp = (short) (*sourceBuffer * (32767.0f)); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int16_Clip( ! float *sourceBuffer, int sourceStride, ! short *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! long samp = (long) (*sourceBuffer * (32767.0f)); ! CLIP( samp, -0x8000, 0x7FFF ); ! *targetBuffer = (short) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int16_ClipDither( ! float *sourceBuffer, int sourceStride, ! short *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! // use smaller scaler to prevent overflow when we add the dither ! float dither = PaConvert_TriangularDither() * PA_DITHER_SCALE; ! float dithered = (*sourceBuffer * (32766.0f)) + dither; ! long samp = (long) dithered; ! CLIP( samp, -0x8000, 0x7FFF ); ! *targetBuffer = (short) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int16_Dither( ! float *sourceBuffer, int sourceStride, ! short *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! // use smaller scaler to prevent overflow when we add the dither ! float dither = PaConvert_TriangularDither() * PA_DITHER_SCALE; ! float dithered = (*sourceBuffer * (32766.0f)) + dither; ! *targetBuffer = (short) dithered; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! ! /*************************************************************************/ ! static void PaConvert_Int16_Float32( ! short *sourceBuffer, int sourceStride, ! float *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! float samp = *sourceBuffer * (1.0f / 32768.0f); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int8( ! float *sourceBuffer, int sourceStride, ! char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! char samp = (char) (*sourceBuffer * (127.0)); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int8_Clip( ! float *sourceBuffer, int sourceStride, ! char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! long samp = (long) (*sourceBuffer * 127.0f); ! CLIP( samp, -0x80, 0x7F ); ! *targetBuffer = (char) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int8_ClipDither( ! float *sourceBuffer, int sourceStride, ! char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! // use smaller scaler to prevent overflow when we add the dither ! float dither = PaConvert_TriangularDither() * PA_DITHER_SCALE; ! float dithered = (*sourceBuffer * (126.0f)) + dither; ! long samp = (long) dithered; ! CLIP( samp, -0x80, 0x7F ); ! *targetBuffer = (char) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int8_Dither( ! float *sourceBuffer, int sourceStride, ! char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! // use smaller scaler to prevent overflow when we add the dither ! float dither = PaConvert_TriangularDither() * PA_DITHER_SCALE; //FIXME ! float dithered = (*sourceBuffer * (126.0f)) + dither; ! long samp = (long) dithered; ! *targetBuffer = (char) samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Int8_Float32( ! char *sourceBuffer, int sourceStride, ! float *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! float samp = *sourceBuffer * (1.0f / 128.0f); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_UInt8( ! float *sourceBuffer, int sourceStride, ! unsigned char *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! unsigned char samp = (unsigned char)(128 + (*sourceBuffer * (127.0))); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_UInt8_Float32( ! unsigned char *sourceBuffer, int sourceStride, ! float *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! float samp = (*sourceBuffer - 128) * (1.0f / 128.0f); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int32( ! float *sourceBuffer, int sourceStride, ! long *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! int samp = (int) (*sourceBuffer * 0x7FFFFFFF); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Float32_Int32_Clip( ! float *sourceBuffer, int sourceStride, ! long *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! int samp; ! float fs = *sourceBuffer; ! CLIP( fs, -1.0f, 0.999999f ); ! samp = (int) (*sourceBuffer * 0x7FFFFFFF); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static void PaConvert_Int32_Float32( ! long *sourceBuffer, int sourceStride, ! float *targetBuffer, int targetStride, ! int numSamples ) ! { ! int i; ! for( i=0; i<numSamples; i++ ) ! { ! float samp = *sourceBuffer * (1.0f / 0x7FFFFFFF); ! *targetBuffer = samp; ! sourceBuffer += sourceStride; ! targetBuffer += targetStride; ! } ! } ! ! /*************************************************************************/ ! static PortAudioConverter *PaConvert_SelectProc( PaSampleFormat sourceFormat, ! PaSampleFormat targetFormat, int ifClip, int ifDither ) ! { ! PortAudioConverter *proc = NULL; ! switch( sourceFormat ) ! { ! case paUInt8: ! switch( targetFormat ) ! { ! case paFloat32: ! proc = (PortAudioConverter *) PaConvert_UInt8_Float32; ! break; ! default: ! break; ! } ! break; ! case paInt8: ! switch( targetFormat ) ! { ! case paFloat32: ! proc = (PortAudioConverter *) PaConvert_Int8_Float32; ! break; ! default: ! break; ! } ! break; ! case paInt16: ! switch( targetFormat ) ! { ! case paFloat32: ! proc = (PortAudioConverter *) PaConvert_Int16_Float32; ! break; ! default: ! break; ! } ! break; ! ! case paInt32: ! switch( targetFormat ) ! { ! case paFloat32: ! proc = (PortAudioConverter *) PaConvert_Int32_Float32; ! break; ! default: ! break; ! } ! break; ! ! case paFloat32: ! switch( targetFormat ) ! { ! case paUInt8: ! proc = (PortAudioConverter *) PaConvert_Float32_UInt8; ! break; ! case paInt8: ! if( ifClip && ifDither ) proc = (PortAudioConverter *) PaConvert_Float32_Int8_ClipDither; ! else if( ifClip ) proc = (PortAudioConverter *) PaConvert_Float32_Int8_Clip; ! else if( ifDither ) proc = (PortAudioConverter *) PaConvert_Float32_Int8_Dither; ! else proc = (PortAudioConverter *) PaConvert_Float32_Int8; ! break; ! case paInt16: ! if( ifClip && ifDither ) proc = (PortAudioConverter *) PaConvert_Float32_Int16_ClipDither; ! else if( ifClip ) proc = (PortAudioConverter *) PaConvert_Float32_Int16_Clip; ! else if( ifDither ) proc = (PortAudioConverter *) PaConvert_Float32_Int16_Dither; ! else proc = (PortAudioConverter *) PaConvert_Float32_Int16; ! break; ! case paInt32: ! /* Don't bother dithering a 32 bit integer! */ ! if( ifClip ) proc = (PortAudioConverter *) PaConvert_Float32_Int32_Clip; ! else proc = (PortAudioConverter *) PaConvert_Float32_Int32; ! break; ! default: ! break; ! } ! break; ! default: ! break; ! } ! return proc; ! ! } ! ! /*************************************************************************/ ! PaError PaConvert_SetupInput( internalPortAudioStream *past, ! PaSampleFormat nativeInputSampleFormat ) ! { ! past->past_NativeInputSampleFormat = nativeInputSampleFormat; ! past->past_InputConversionSourceStride = 1; ! past->past_InputConversionTargetStride = 1; ! ! if( nativeInputSampleFormat != past->past_InputSampleFormat ) ! { ! int ifDither = (past->past_Flags & paDitherOff) == 0; ! past->past_InputConversionProc = PaConvert_SelectProc( nativeInputSampleFormat, ! past->past_InputSampleFormat, 0, ifDither ); ! if( past->past_InputConversionProc == NULL ) return paSampleFormatNotSupported; ! } ! else ! { ! past->past_InputConversionProc = NULL; /* no conversion necessary */ ! } ! ! return paNoError; ! } ! ! /*************************************************************************/ ! PaError PaConvert_SetupOutput( internalPortAudioStream *past, ! PaSampleFormat nativeOutputSampleFormat ) ! { ! ! past->past_NativeOutputSampleFormat = nativeOutputSampleFormat; ! past->past_OutputConversionSourceStride = 1; ! past->past_OutputConversionTargetStride = 1; ! ! if( nativeOutputSampleFormat != past->past_OutputSampleFormat ) ! { ! int ifDither = (past->past_Flags & paDitherOff) == 0; ! int ifClip = (past->past_Flags & paClipOff) == 0; ! ! past->past_OutputConversionProc = PaConvert_SelectProc( past->past_OutputSampleFormat, ! nativeOutputSampleFormat, ifClip, ifDither ); ! if( past->past_OutputConversionProc == NULL ) return paSampleFormatNotSupported; ! } ! else ! { ! past->past_OutputConversionProc = NULL; /* no conversion necessary */ ! } ! ! return paNoError; ! } ! ! /************************************************************************* ! ** Called by host code. ! ** Convert input from native format to user format, ! ** call user code, ! ** then convert output to native format. ! ** Returns result from user callback. ! */ ! long PaConvert_Process( internalPortAudioStream *past, ! void *nativeInputBuffer, ! void *nativeOutputBuffer ) ! { ! int userResult; ! void *inputBuffer = NULL; ! void *outputBuffer = NULL; ! ! /* Get native input data. */ ! if( (past->past_NumInputChannels > 0) && (nativeInputBuffer != NULL) ) ! { ! if( past->past_InputSampleFormat == past->past_NativeInputSampleFormat ) ! { ! /* Already in native format so just read directly from native buffer. */ ! inputBuffer = nativeInputBuffer; ! } ! else ! { ! inputBuffer = past->past_InputBuffer; ! /* Convert input data to user format. */ ! (*past->past_InputConversionProc)(nativeInputBuffer, past->past_InputConversionSourceStride, ! inputBuffer, past->past_InputConversionTargetStride, ! past->past_FramesPerUserBuffer * past->past_NumInputChannels ); ! } ! } ! ! /* Are we doing output? */ ! if( (past->past_NumOutputChannels > 0) && (nativeOutputBuffer != NULL) ) ! { ! outputBuffer = (past->past_OutputConversionProc == NULL) ? ! nativeOutputBuffer : past->past_OutputBuffer; ! } ! /* ! AddTraceMessage("Pa_CallConvertInt16: inputBuffer = ", (int) inputBuffer ); ! AddTraceMessage("Pa_CallConvertInt16: outputBuffer = ", (int) outputBuffer ); ! */ ! /* Call user callback routine. */ ! userResult = past->past_Callback( ! inputBuffer, ! outputBuffer, ! past->past_FramesPerUserBuffer, ! past->past_FrameCount, ! past->past_UserData ); ! ! /* Advance frame counter for timestamp. */ ! past->past_FrameCount += past->past_FramesPerUserBuffer; // FIXME - should this be in here? ! ! /* Convert to native format if necessary. */ ! if( (past->past_OutputConversionProc != NULL ) && (outputBuffer != NULL) ) ! { ! (*past->past_OutputConversionProc)( outputBuffer, past->past_OutputConversionSourceStride, ! nativeOutputBuffer, past->past_OutputConversionTargetStride, ! past->past_FramesPerUserBuffer * past->past_NumOutputChannels ); ! } ! ! return userResult; ! } Index: pa_host.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/portaudio/pa_common/pa_host.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pa_host.h 5 Dec 2002 14:46:43 -0000 1.1 --- pa_host.h 23 Apr 2003 06:24:17 -0000 1.2 *************** *** 1,185 **** ! #ifndef PA_HOST_H ! #define PA_HOST_H ! ! /* ! * $Id$ ! * Host dependant internal API for PortAudio ! * ! * Author: Phil Burk <phi...@so...> ! * ! * PortAudio Portable Real-Time Audio Library ! * Latest Version at: http://www.softsynth.com/portaudio/ ! * DirectSound and Macintosh Implementation ! * Copyright (c) 1999-2000 Phil Burk ! * ! * Permission is hereby granted, free of charge, to any person obtaining ! * a copy of this software and associated documentation files ! * (the "Software"), to deal in the Software without restriction, ! * including without limitation the rights to use, copy, modify, merge, ! * publish, distribute, sublicense, and/or sell copies of the Software, ! * and to permit persons to whom the Software is furnished to do so, ! * subject to the following conditions: ! * ! * The above copyright notice and this permission notice shall be ! * included in all copies or substantial portions of the Software. ! * ! * Any person wishing to distribute modifications to the Software is ! * requested to send the modifications to the original developer so that ! * they can be incorporated into the canonical version. ! * ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ! * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ! * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ! * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF ! * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ! * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ! * ! */ ! ! #include "portaudio.h" ! ! #ifdef __cplusplus ! extern "C" ! { ! #endif /* __cplusplus */ ! ! #ifndef SUPPORT_AUDIO_CAPTURE ! #define SUPPORT_AUDIO_CAPTURE (1) ! #endif ! ! #ifndef int32 ! typedef long int32; ! #endif ! #ifndef uint32 ! typedef unsigned long uint32; ! #endif ! #ifndef int16 ! typedef short int16; ! #endif ! #ifndef uint16 ! typedef unsigned short uint16; ! #endif ! ! /* Used to convert between various sample formats. */ ! typedef void (PortAudioConverter)( ! void *inputBuffer, int inputStride, ! void *outputBuffer, int outputStride, ! int numSamples ); ! ! #define PA_MAGIC (0x18273645) ! ! /************************************************************************************/ ! /****************** Structures ******************************************************/ ! /************************************************************************************/ ! ! typedef struct internalPortAudioStream ! { ! uint32 past_Magic; /* ID for struct to catch bugs. */ ! /* User specified information. */ ! uint32 past_FramesPerUserBuffer; ! uint32 past_NumUserBuffers; ! double past_SampleRate; /* Closest supported sample rate. */ ! int past_NumInputChannels; ! int past_NumOutputChannels; ! PaDeviceID past_InputDeviceID; ! PaDeviceID past_OutputDeviceID; ! PaSampleFormat past_NativeInputSampleFormat; ! PaSampleFormat past_InputSampleFormat; ! PaSampleFormat past_NativeOutputSampleFormat; ! PaSampleFormat past_OutputSampleFormat; ! void *past_DeviceData; ! PortAudioCallback *past_Callback; ! void *past_UserData; ! uint32 past_Flags; ! /* Flags for communicating between foreground and background. */ ! volatile int past_IsActive; /* Background is still playing. */ ! volatile int past_StopSoon; /* Background should keep playing when buffers empty. */ ! volatile int past_StopNow; /* Background should stop playing now. */ ! /* These buffers are used when the native format does not match the user format. */ ! void *past_InputBuffer; ! uint32 past_InputBufferSize; ! void *past_OutputBuffer; ! uint32 past_OutputBufferSize; ! /* Measurements */ ! uint32 past_NumCallbacks; ! PaTimestamp past_FrameCount; /* Frames output to buffer. */ ! /* For measuring CPU utilization. */ ! double past_AverageInsideCount; ! double past_AverageTotalCount; ! double past_Usage; ! int past_IfLastExitValid; ! /* Format Conversion */ ! /* These are setup by PaConversion_Setup() */ ! PortAudioConverter *past_InputConversionProc; ! int past_InputConversionSourceStride; ! int past_InputConversionTargetStride; ! PortAudioConverter *past_OutputConversionProc; ! int past_OutputConversionSourceStride; ! int past_OutputConversionTargetStride; ! } ! internalPortAudioStream; ! ! /************************************************************************************/ ! /******** These functions must be provided by a platform implementation. ************/ ! /************************************************************************************/ ! ! PaError PaHost_Init( void ); ! PaError PaHost_Term( void ); ! ! PaError PaHost_OpenStream( internalPortAudioStream *past ); ! PaError PaHost_CloseStream( internalPortAudioStream *past ); ! ! PaError PaHost_StartOutput( internalPortAudioStream *past ); ! PaError PaHost_StopOutput( internalPortAudioStream *past, int abort ); ! PaError PaHost_StartInput( internalPortAudioStream *past ); ! PaError PaHost_StopInput( internalPortAudioStream *past, int abort ); ! PaError PaHost_StartEngine( internalPortAudioStream *past ); ! PaError PaHost_StopEngine( internalPortAudioStream *past, int abort ); ! PaError PaHost_StreamActive( internalPortAudioStream *past ); ! ! void *PaHost_AllocateFastMemory( long numBytes ); ! void PaHost_FreeFastMemory( void *addr, long numBytes ); ! ! /* This only called if PA_VALIDATE_RATE IS CALLED. */ ! PaError PaHost_ValidateSampleRate( PaDeviceID id, double requestedFrameRate, ! double *closestFrameRatePtr ); ! ! /**********************************************************************/ ! /************ Common Utility Routines provided by PA ******************/ ! /**********************************************************************/ ! ! /* PaHost_IsInitialized() returns non-zero if PA is initialized, 0 otherwise */ ! int PaHost_IsInitialized( void ); ! ! internalPortAudioStream* PaHost_GetStreamRepresentation( PortAudioStream *stream ); ! ! int PaHost_FindClosestTableEntry( double allowableError, const double *rateTable, ! int numRates, double frameRate ); ! ! long Pa_CallConvertInt16( internalPortAudioStream *past, ! short *nativeInputBuffer, ! short *nativeOutputBuffer ); ! ! /* Calculate 2 LSB dither signal with a triangular distribution. ! ** Ranged properly for adding to a 32 bit 1.31 fixed point value prior to >>15. ! ** Range of output is +/- 65535 ! ** Multiply by PA_DITHER_SCALE to get a float between -2.0 and 2.0. */ ! #define PA_DITHER_BITS (15) ! #define PA_DITHER_SCALE (1.0f / ((1<<PA_DITHER_BITS)-1)) ! long PaConvert_TriangularDither( void ); ! ! PaError PaConvert_SetupInput( internalPortAudioStream *past, ! PaSampleFormat nativeInputSampleFormat ); ! ! PaError PaConvert_SetupOutput( internalPortAudioStream *past, ! PaSampleFormat nativeOutputSampleFormat ); ! ! long PaConvert_Process( internalPortAudioStream *past, ! void *nativeInputBuffer, ! void *nativeOutputBuffer ); ! ! #ifdef __cplusplus ! } ! #endif /* __cplusplus */ ! #endif /* PA_HOST_H */ --- 1,189 ---- ! #ifndef PA_HOST_H ! #define PA_HOST_H ! ! /* ! * $Id$ ! * Host dependant internal API for PortAudio ! * ! * Author: Phil Burk <phi...@so...> ! * ! * PortAudio Portable Real-Time Audio Library ! * Latest Version at: http://www.softsynth.com/portaudio/ ! * DirectSound and Macintosh Implementation ! * Copyright (c) 1999-2000 Phil Burk ! * ! * Permission is hereby granted, free of charge, to any person obtaining ! * a copy of this software and associated documentation files ! * (the "Software"), to deal in the Software without restriction, ! * including without limitation the rights to use, copy, modify, merge, ! * publish, distribute, sublicense, and/or sell copies of the Software, ! * and to permit persons to whom the Software is furnished to do so, ! * subject to the following conditions: ! * ! * The above copyright notice and this permission notice shall be ! * included in all copies or substantial portions of the Software. ! * ! * Any person wishing to distribute modifications to the Software is ! * requested to send the modifications to the original developer so that ! * they can be incorporated into the canonical version. ! * ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ! * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ! * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ! * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF ! * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ! * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ! * ! */ ! ! #include "portaudio.h" ! ! #ifdef __cplusplus ! extern "C" ! { ! #endif /* __cplusplus */ ! ! #ifndef SUPPORT_AUDIO_CAPTURE ! #define SUPPORT_AUDIO_CAPTURE (1) ! #endif ! ! #ifndef int32 ! typedef long int32; ! #endif ! #ifndef uint32 ! typedef unsigned long uint32; ! #endif ! #ifndef int16 ! typedef short int16; ! #endif ! #ifndef uint16 ! typedef unsigned short uint16; ! #endif ! ! /* Used to convert between various sample formats. */ ! typedef void (PortAudioConverter)( ! void *inputBuffer, int inputStride, ! void *outputBuffer, int outputStride, ! int numSamples ); ! ! #define PA_MAGIC (0x18273645) ! ! /************************************************************************************/ ! /****************** Structures ******************************************************/ ! /************************************************************************************/ ! ! typedef struct internalPortAudioStream ! { ! uint32 past_Magic; /* ID for struct to catch bugs. */ ! ! /* Begin user specified information. */ ! uint32 past_FramesPerUserBuffer; ! uint32 past_NumUserBuffers; ! double past_SampleRate; /* Closest supported sample rate. */ ! int past_NumInputChannels; ! int past_NumOutputChannels; ! PaDeviceID past_InputDeviceID; ! PaDeviceID past_OutputDeviceID; ! PaSampleFormat past_InputSampleFormat; ! PaSampleFormat past_OutputSampleFormat; ! PortAudioCallback *past_Callback; ! void *past_UserData; ! uint32 past_Flags; ! /* End user specified information. */ ! ! void *past_DeviceData; ! PaSampleFormat past_NativeOutputSampleFormat; ! PaSampleFormat past_NativeInputSampleFormat; ! ! /* Flags for communicating between foreground and background. */ ! volatile int past_IsActive; /* Background is still playing. */ ! volatile int past_StopSoon; /* Background should keep playing when buffers empty. */ ! volatile int past_StopNow; /* Background should stop playing now. */ ! /* These buffers are used when the native format does not match the user format. */ ! void *past_InputBuffer; ! uint32 past_InputBufferSize; /* Size in bytes of the input buffer. */ ! void *past_OutputBuffer; ! uint32 past_OutputBufferSize; ! /* Measurements */ ! uint32 past_NumCallbacks; ! PaTimestamp past_FrameCount; /* Frames output to buffer. */ ! /* For measuring CPU utilization. */ ! double past_AverageInsideCount; ! double past_AverageTotalCount; ! double past_Usage; ! int past_IfLastExitValid; ! /* Format Conversion */ ! /* These are setup by PaConversion_Setup() */ ! PortAudioConverter *past_InputConversionProc; ! int past_InputConversionSourceStride; ! int past_InputConversionTargetStride; ! PortAudioConverter *past_OutputConversionProc; ! int past_OutputConversionSourceStride; ! int past_OutputConversionTargetStride; ! } ! internalPortAudioStream; ! ! /************************************************************************************/ ! /******** These functions must be provided by a platform implementation. ************/ ! /************************************************************************************/ ! ! PaError PaHost_Init( void ); ! PaError PaHost_Term( void ); ! ! PaError PaHost_OpenStream( internalPortAudioStream *past ); ! PaError PaHost_CloseStream( internalPortAudioStream *past ); ! ! PaError PaHost_StartOutput( internalPortAudioStream *past ); ! PaError PaHost_StopOutput( internalPortAudioStream *past, int abort ); ! PaError PaHost_StartInput( internalPortAudioStream *past ); ! PaError PaHost_StopInput( internalPortAudioStream *past, int abort ); ! PaError PaHost_StartEngine( internalPortAudioStream *past ); ! PaError PaHost_StopEngine( internalPortAudioStream *past, int abort ); ! PaError PaHost_StreamActive( internalPortAudioStream *past ); ! ! void *PaHost_AllocateFastMemory( long numBytes ); ! void PaHost_FreeFastMemory( void *addr, long numBytes ); ! ! /* This only called if PA_VALIDATE_RATE IS CALLED. */ ! PaError PaHost_ValidateSampleRate( PaDeviceID id, double requestedFrameRate, ! double *closestFrameRatePtr ); ! ! /**********************************************************************/ ! /************ Common Utility Routines provided by PA ******************/ ! /**********************************************************************/ ! ! /* PaHost_IsInitialized() returns non-zero if PA is initialized, 0 otherwise */ ! int PaHost_IsInitialized( void ); ! ! internalPortAudioStream* PaHost_GetStreamRepresentation( PortAudioStream *stream ); ! ! int PaHost_FindClosestTableEntry( double allowableError, const double *rateTable, ! int numRates, double frameRate ); ! ! long Pa_CallConvertInt16( internalPortAudioStream *past, ! short *nativeInputBuffer, ! short *nativeOutputBuffer ); ! ! /* Calculate 2 LSB dither signal with a triangular distribution. ! ** Ranged properly for adding to a 32 bit 1.31 fixed point value prior to >>15. ! ** Range of output is +/- 65535 ! ** Multiply by PA_DITHER_SCALE to get a float between -2.0 and 2.0. */ ! #define PA_DITHER_BITS (15) ! #define PA_DITHER_SCALE (1.0f / ((1<<PA_DITHER_BITS)-1)) ! long PaConvert_TriangularDither( void ); ! ! PaError PaConvert_SetupInput( internalPortAudioStream *past, ! PaSampleFormat nativeInputSampleFormat ); ! ! PaError PaConvert_SetupOutput( internalPortAudioStream *past, ! PaSampleFormat nativeOutputSampleFormat ); ! ! long PaConvert_Process( internalPortAudioStream *past, ! void *nativeInputBuffer, ! void *nativeOutputBuffer ); ! ! #ifdef __cplusplus ! } ! #endif /* __cplusplus */ ! #endif /* PA_HOST_H */ Index: pa_lib.c =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/portaudio/pa_common/pa_lib.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pa_lib.c 5 Dec 2002 14:46:43 -0000 1.1 --- pa_lib.c 23 Apr 2003 06:24:17 -0000 1.2 *************** *** 1,806 **** ! /* ! * $Id$ ! * Portable Audio I/O Library ! * Host Independant Layer ! * ! * Based on the Open Source API proposed by Ross Bencina ! * Copyright (c) 1999-2000 Phil Burk ! * ! * Permission is hereby granted, free of charge, to any person obtaining ! * a copy of this software and associated documentation files [...1583 lines suppressed...] ! break; ! ! case paPackedInt24: ! size = 3; ! break; ! ! case paFloat32: ! case paInt32: ! case paInt24: ! size = 4; ! break; ! ! default: ! size = paSampleFormatNotSupported; ! break; ! } ! return (PaError) size; ! } ! ! Index: pa_trace.c =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/portaudio/pa_common/pa_trace.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pa_trace.c 5 Dec 2002 14:46:43 -0000 1.1 --- pa_trace.c 23 Apr 2003 06:24:17 -0000 1.2 *************** *** 1,83 **** ! /* ! * $Id$ ! * Portable Audio I/O Library Trace Facility ! * Store trace information in real-time for later printing. ! * ! * Based on the Open Source API proposed by Ross Bencina ! * Copyright (c) 1999-2000 Phil Burk ! * ! * Permission is hereby granted, free of charge, to any person obtaining ! * a copy of this software and associated documentation files ! * (the "Software"), to deal in the Software without restriction, ! * including without limitation the rights to use, copy, modify, merge, ! * publish, distribute, sublicense, and/or sell copies of the Software, ! * and to permit persons to whom the Software is furnished to do so, ! * subject to the following conditions: ! * ! * The above copyright notice and this permission notice shall be ! * included in all copies or substantial portions of the Software. ! * ! * Any person wishing to distribute modifications to the Software is ! * requested to send the modifications to the original developer so that ! * they can be incorporated into the canonical version. ! * ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ! * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ! * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ! * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF ! * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ! * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ! */ ! ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include "pa_trace.h" ! ! #if TRACE_REALTIME_EVENTS ! ! static char *traceTextArray[MAX_TRACE_RECORDS]; ! static int traceIntArray[MAX_TRACE_RECORDS]; ! static int traceIndex = 0; ! static int traceBlock = 0; ! ! /*********************************************************************/ ! void ResetTraceMessages() ! { ! traceIndex = 0; ! } ! ! /*********************************************************************/ ! void DumpTraceMessages() ! { ! int i; ! int numDump = (traceIndex < MAX_TRACE_RECORDS) ? traceIndex : MAX_TRACE_RECORDS; ! ! printf("DumpTraceMessages: traceIndex = %d\n", traceIndex ); ! for( i=0; i<numDump; i++ ) ! { ! printf("%3d: %s = 0x%08X\n", ! i, traceTextArray[i], traceIntArray[i] ); ! } ! ResetTraceMessages(); ! fflush(stdout); ! } ! ! /*********************************************************************/ ! void AddTraceMessage( char *msg, int data ) ! { ! if( (traceIndex == MAX_TRACE_RECORDS) && (traceBlock == 0) ) ! { ! traceBlock = 1; ! /* DumpTraceMessages(); */ ! } ! else if( traceIndex < MAX_TRACE_RECORDS ) ! { ! traceTextArray[traceIndex] = msg; ! traceIntArray[traceIndex] = data; ! traceIndex++; ! } ! } ! ! #endif --- 1,83 ---- ! /* ! * $Id$ ! * Portable Audio I/O Library Trace Facility ! * Store trace information in real-time for later printing. ! * ! * Based on the Open Source API proposed by Ross Bencina ! * Copyright (c) 1999-2000 Phil Burk ! * ! * Permission is hereby granted, free of charge, to any person obtaining ! * a copy of this software and associated documentation files ! * (the "Software"), to deal in the Software without restriction, ! * including without limitation the rights to use, copy, modify, merge, ! * publish, distribute, sublicense, and/or sell copies of the Software, ! * and to permit persons to whom the Software is furnished to do so, ! * subject to the following conditions: ! * ! * The above copyright notice and this permission notice shall be ! * included in all copies or substantial portions of the Software. ! * ! * Any person wishing to distribute modifications to the Software is ! * requested to send the modifications to the original developer so that ! * they can be incorporated into the canonical version. ! * ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ! * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ! * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ! * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF ! * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ! * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ! */ ! ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include "pa_trace.h" ! ! #if TRACE_REALTIME_EVENTS ! ! static char *traceTextArray[MAX_TRACE_RECORDS]; ! static int traceIntArray[MAX_TRACE_RECORDS]; ! static int traceIndex = 0; ! static int traceBlock = 0; ! ! /*********************************************************************/ ! void ResetTraceMessages() ! { ! traceIndex = 0; ! } ! ! /*********************************************************************/ ! void DumpTraceMessages() ! { ! int i; ! int numDump = (traceIndex < MAX_TRACE_RECORDS) ? traceIndex : MAX_TRACE_RECORDS; ! ! printf("DumpTraceMessages: traceIndex = %d\n", traceIndex ); ! for( i=0; i<numDump; i++ ) ! { ! printf("%3d: %s = 0x%08X\n", ! i, traceTextArray[i], traceIntArray[i] ); ! } ! ResetTraceMessages(); ! fflush(stdout); ! } ! ! /*********************************************************************/ ! void AddTraceMessage( char *msg, int data ) ! { ! if( (traceIndex == MAX_TRACE_RECORDS) && (traceBlock == 0) ) ! { ! traceBlock = 1; ! /* DumpTraceMessages(); */ ! } ! else if( traceIndex < MAX_TRACE_RECORDS ) ! { ! traceTextArray[traceIndex] = msg; ! traceIntArray[traceIndex] = data; ! traceIndex++; ! } ! } ! ! #endif Index: pa_trace.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/portaudio/pa_common/pa_trace.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pa_trace.h 5 Dec 2002 14:46:43 -0000 1.1 --- pa_trace.h 23 Apr 2003 06:24:17 -0000 1.2 *************** *** 1,67 **** ! #ifndef PA_TRACE_H ! #define PA_TRACE_H ! /* ! * $Id$ ! * Portable Audio I/O Library Trace Facility ! * Store trace information in real-time for later printing. ! * ! * Based on the Open Source API proposed by Ross Bencina ! * Copyright (c) 1999-2000 Phil Burk ! * ! * Permission is hereby granted, free of charge, to any person obtaining ! * a copy of this software and associated documentation files ! * (the "Software"), to deal in the Software without restriction, ! * including without limitation the rights to use, copy, modify, merge, ! * publish, distribute, sublicense, and/or sell copies of the Software, ! * and to permit persons to whom the Software is furnished to do so, ! * subject to the following conditions: ! * ! * The above copyright notice and this permission notice shall be ! * included in all copies or substantial portions of the Software. ! * ! * Any person wishing to distribute modifications to the Software is ! * requested to send the modifications to the original developer so that ! * they can be incorporated into the canonical version. ! * ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ! * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ! * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ! * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF ! * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ! * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ! */ ! ! ! #define TRACE_REALTIME_EVENTS (0) /* Keep log of various real-time events. */ ! #define MAX_TRACE_RECORDS (2048) ! ! #ifdef __cplusplus ! extern "C" ! { ! #endif /* __cplusplus */ ! ! ! /************************************************************************************/ ! /****************** Prototypes ******************************************************/ ! /************************************************************************************/ ! ! #if TRACE_REALTIME_EVENTS ! ! void DumpTraceMessages(); ! void ResetTraceMessages(); ! void AddTraceMessage( char *msg, int data ); ! ! #else ! ! #define AddTraceMessage(msg,data) /* noop */ ! #define ResetTraceMessages() /* noop */ ! #define DumpTraceMessages() /* noop */ ! ! #endif ! ! #ifdef __cplusplus ! } ! #endif /* __cplusplus */ ! ! #endif /* PA_TRACE_H */ --- 1,67 ---- ! #ifndef PA_TRACE_H ! #define PA_TRACE_H ! /* ! * $Id$ ! * Portable Audio I/O Library Trace Facility ! * Store trace information in real-time for later printing. ! * ! * Based on the Open Source API proposed by Ross Bencina ! * Copyright (c) 1999-2000 Phil Burk ! * ! * Permission is hereby granted, free of charge, to any person obtaining ! * a copy of this software and associated documentation files ! * (the "Software"), to deal in the Software without restriction, ! * including without limitation the rights to use, copy, modify, merge, ! * publish, distribute, sublicense, and/or sell copies of the Software, ! * and to permit persons to whom the Software is furnished to do so, ! * subject to the following conditions: ! * ! * The above copyright notice and this permission notice shall be ! * included in all copies or substantial portions of the Software. ! * ! * Any person wishing to distribute modifications to the Software is ! * requested to send the modifications to the original developer so that ! * they can be incorporated into the canonical version. ! * ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ! * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. ! * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ! * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF ! * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ! * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ! */ ! ! ! #define TRACE_REALTIME_EVENTS (0) /* Keep log of various real-time events. */ ! #define MAX_TRACE_RECORDS (2048) ! ! #ifdef __cplusplus ! extern "C" ! { ! #endif /* __cplusplus */ ! ! ! /************************************************************************************/ ! /****************** Prototypes ******************************************************/ ! /************************************************************************************/ ! ! #if TRACE_REALTIME_EVENTS ! ! void DumpTraceMessages(); ! void ResetTraceMessages(); ! void AddTraceMessage( char *msg, int data ); ! ! #else ! ! #define AddTraceMessage(msg,data) /* noop */ ! #define ResetTraceMessages() /* noop */ ! #define DumpTraceMessages() /* noop */ ! ! #endif ! ! #ifdef __cplusplus ! } ! #endif /* __cplusplus */ ! ! #endif /* PA_TRACE_H */ Index: portaudio.h =================================================================== RCS file: /cvsroot/scopeapp/scopeapp/src/portaudio/pa_common/portaudio.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** portaudio.h 5 Dec 2002 14:46:43 -0000 1.1 --- portaudio.h 23 Apr 2003 06:24:17 -0000 1.2 *************** *** 1,463 **** ! #ifndef PORT_AUDIO_H ! #define PORT_AUDIO_H ! ! #ifdef __cplusplus ! extern "C" ! { ! #endif /* __cplusplus */ ! ! /* ! * $Id$ ! * PortAudio Portable Real-Time Audio Library ! * PortAudio API Header File ! * Latest version available at: http://www.audiomulch.com/portaudio/ ! * ! * Copyright (c) 1999-2000 Ross Bencina and Phil Burk ! * ! * Permission is hereby granted, free of charge, to any person obtaining ! * a copy of this software and associated documentation files ! * (the "Software"), to deal in the Software without restriction, ! * including without limitation the rights to use, copy, modify, merge, ! * publish, distribute, sublicense, and/or sell copies of the Software, ! * and to permit persons to whom the Software is furnished to do so, ! * subject to the following conditions: ! * ! * The above copyright notice and this permission notice shall be ! * included in all copies or substantial portions of the Software. ! * ! * Any person wishing to distribute modifications to the So... [truncated message content] |