oss: fixed compile for systems missing 'pthread_cancel' series of functions, this allows to compile PortAudio under Android platform with OSS as audio host back-end
This commit is contained in:
parent
c8414a679e
commit
01f740b882
2 changed files with 59 additions and 3 deletions
|
|
@ -185,7 +185,7 @@ typedef struct PaOssStream
|
|||
double sampleRate;
|
||||
|
||||
int callbackMode;
|
||||
int callbackStop, callbackAbort;
|
||||
volatile int callbackStop, callbackAbort;
|
||||
|
||||
PaOssStreamComponent *capture, *playback;
|
||||
unsigned long pollTimeout;
|
||||
|
|
@ -1317,7 +1317,17 @@ static PaError PaOssStream_WaitForFrames( PaOssStream *stream, unsigned long *fr
|
|||
|
||||
while( pollPlayback || pollCapture )
|
||||
{
|
||||
#ifdef PTHREAD_CANCELED
|
||||
pthread_testcancel();
|
||||
#else
|
||||
/* avoid indefinite waiting on thread not supporting cancelation */
|
||||
if( stream->callbackStop || stream->callbackAbort )
|
||||
{
|
||||
PA_DEBUG(( "Cancelling PaOssStream_WaitForFrames\n" ));
|
||||
(*frames) = 0;
|
||||
return paNoError;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* select may modify the timeout parameter */
|
||||
selectTimeval.tv_usec = timeout;
|
||||
|
|
@ -1341,8 +1351,17 @@ static PaError PaOssStream_WaitForFrames( PaOssStream *stream, unsigned long *fr
|
|||
ENSURE_( -1, paUnanticipatedHostError );
|
||||
}
|
||||
*/
|
||||
#ifdef PTHREAD_CANCELED
|
||||
pthread_testcancel();
|
||||
|
||||
#else
|
||||
/* avoid indefinite waiting on thread not supporting cancelation */
|
||||
if( stream->callbackStop || stream->callbackAbort )
|
||||
{
|
||||
PA_DEBUG(( "Cancelling PaOssStream_WaitForFrames\n" ));
|
||||
(*frames) = 0;
|
||||
return paNoError;
|
||||
}
|
||||
#endif
|
||||
if( pollCapture )
|
||||
{
|
||||
if( FD_ISSET( captureFd, &readFds ) )
|
||||
|
|
@ -1603,8 +1622,15 @@ static void *PaOSS_AudioThreadProc( void *userData )
|
|||
|
||||
while( 1 )
|
||||
{
|
||||
#ifdef PTHREAD_CANCELED
|
||||
pthread_testcancel();
|
||||
|
||||
#else
|
||||
if( stream->callbackAbort ) /* avoid indefinite waiting on thread not supporting cancelation */
|
||||
{
|
||||
PA_DEBUG(( "Aborting callback thread\n" ));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
if( stream->callbackStop && callbackResult == paContinue )
|
||||
{
|
||||
PA_DEBUG(( "Setting callbackResult to paComplete\n" ));
|
||||
|
|
@ -1631,8 +1657,21 @@ static void *PaOSS_AudioThreadProc( void *userData )
|
|||
{
|
||||
unsigned long frames = framesAvail;
|
||||
|
||||
#ifdef PTHREAD_CANCELED
|
||||
pthread_testcancel();
|
||||
#else
|
||||
if( stream->callbackStop )
|
||||
{
|
||||
PA_DEBUG(( "Setting callbackResult to paComplete\n" ));
|
||||
callbackResult = paComplete;
|
||||
}
|
||||
|
||||
if( stream->callbackAbort ) /* avoid indefinite waiting on thread not supporting cancelation */
|
||||
{
|
||||
PA_DEBUG(( "Aborting callback thread\n" ));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
PaUtil_BeginCpuLoadMeasurement( &stream->cpuLoadMeasurer );
|
||||
|
||||
/* Read data */
|
||||
|
|
|
|||
Loading…
Reference in a new issue