Update of /cvsroot/pure-data/pd/portaudio/pa_unix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1508/pd/portaudio/pa_unix
Modified Files: pa_unix_hostapis.c pa_unix_util.c Log Message: Remembered to update all the edited files. Should now be in sync... will have to test it though.
Index: pa_unix_util.c =================================================================== RCS file: /cvsroot/pure-data/pd/portaudio/pa_unix/pa_unix_util.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pa_unix_util.c 18 May 2005 04:28:44 -0000 1.8 --- pa_unix_util.c 30 May 2005 03:04:12 -0000 1.9 *************** *** 32,41 ****
#include <unistd.h> #include <stdlib.h> #include <sys/time.h>
#include "pa_util.h" !
/* --- 32,44 ----
+ #include <pthread.h> #include <unistd.h> #include <stdlib.h> #include <sys/time.h> + #include <assert.h> + #include <string.h> /* For memset */
#include "pa_util.h" ! #include "pa_unix_util.h"
/* *************** *** 107,110 **** struct timeval tv; gettimeofday( &tv, NULL ); ! return (PaTime) tv.tv_usec / 1000000 + (PaTime) tv.tv_sec; } --- 110,175 ---- struct timeval tv; gettimeofday( &tv, NULL ); ! return (PaTime) tv.tv_usec / 1000000. + tv.tv_sec; ! } ! ! PaError PaUtil_InitializeThreading( PaUtilThreading *threading ) ! { ! (void) paUtilErr_; ! return paNoError; } + + void PaUtil_TerminateThreading( PaUtilThreading *threading ) + { + } + + PaError PaUtil_StartThreading( PaUtilThreading *threading, void *(*threadRoutine)(void *), void *data ) + { + pthread_create( &threading->callbackThread, NULL, threadRoutine, data ); + return paNoError; + } + + PaError PaUtil_CancelThreading( PaUtilThreading *threading, int wait, PaError *exitResult ) + { + PaError result = paNoError; + void *pret; + + if( exitResult ) + *exitResult = paNoError; + + /* Only kill the thread if it isn't in the process of stopping (flushing adaptation buffers) */ + if( !wait ) + pthread_cancel( threading->callbackThread ); /* XXX: Safe to call this if the thread has exited on its own? */ + pthread_join( threading->callbackThread, &pret ); + + #ifdef PTHREAD_CANCELED + if( pret && PTHREAD_CANCELED != pret ) + #else + /* !wait means the thread may have been canceled */ + if( pret && wait ) + #endif + { + if( exitResult ) + *exitResult = *(PaError *) pret; + free( pret ); + } + + return result; + } + + /* + static void *CanaryFunc( void *userData ) + { + const unsigned intervalMsec = 1000; + PaUtilThreading *th = (PaUtilThreading *) userData; + + while( 1 ) + { + th->canaryTime = PaUtil_GetTime(); + + pthread_testcancel(); + Pa_Sleep( intervalMsec ); + } + + pthread_exit( NULL ); + } + */