[PD-cvs] pd/portaudio/pa_unix pa_unix_util.c,1.3,1.3.4.1

Tim Blechmann timblech at users.sourceforge.net
Tue Jun 28 18:30:38 CEST 2005


Update of /cvsroot/pure-data/pd/portaudio/pa_unix
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8219/pa_unix

Modified Files:
      Tag: devel_0_38
	pa_unix_util.c 
Log Message:
updating to latest portaudio snapshot

Index: pa_unix_util.c
===================================================================
RCS file: /cvsroot/pure-data/pd/portaudio/pa_unix/pa_unix_util.c,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -C2 -d -r1.3 -r1.3.4.1
*** pa_unix_util.c	6 Sep 2004 20:44:41 -0000	1.3
--- pa_unix_util.c	28 Jun 2005 16:30:36 -0000	1.3.4.1
***************
*** 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 );
+ }
+ */





More information about the Pd-cvs mailing list