From e1cf376aa6eaf1e99cba1d6e93c4dd68ddcf8dd5 Mon Sep 17 00:00:00 2001 From: rossb Date: Fri, 13 Mar 2009 16:31:28 +0000 Subject: [PATCH] fixed bug in asio blocking i/o stream initialization which would cause crash (bad ptr). enabled timeout code in read/writestream. patch from sven fischer --- src/hostapi/asio/pa_asio.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/hostapi/asio/pa_asio.cpp b/src/hostapi/asio/pa_asio.cpp index da010f5..24790dd 100644 --- a/src/hostapi/asio/pa_asio.cpp +++ b/src/hostapi/asio/pa_asio.cpp @@ -2055,7 +2055,7 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi, { /* Blocking i/o is implemented by running callback mode, using a special blocking i/o callback. */ streamCallback = BlockingIoPaCallback; /* Setup PA to use the ASIO blocking i/o callback. */ - userData = &stream; /* The callback user data will be the PA ASIO stream. */ + userData = &theAsioStream; /* The callback user data will be the PA ASIO stream. */ PaUtil_InitializeStreamRepresentation( &stream->streamRepresentation, &asioHostApi->blockingStreamInterface, streamCallback, userData ); } @@ -3470,11 +3470,8 @@ static PaError ReadStream( PaStream *s , /* If block processing has stopped, abort! */ if( blockingState->stopFlag ) { return result = paStreamIsStopped; } - /* if a timeout is encountered, continue, perhaps we should give up eventually */ - continue; - /* To give up eventually, we may increase the time out - period and return an error if it fails anyway. */ - /* retrun result = paTimedOut; */ + /* If a timeout is encountered, give up eventually. */ + return result = paTimedOut; } } /* Now, the ring buffer contains the required amount of data @@ -3644,11 +3641,9 @@ static PaError WriteStream( PaStream *s , /* If block processing has stopped, abort! */ if( blockingState->stopFlag ) { return result = paStreamIsStopped; } - /* if a timeout is encountered, continue, perhaps we should give up eventually */ - continue; - /* To give up eventually, we may increase the time out - period and return an error if it fails anyway. */ - /* retrun result = paTimedOut; */ + + /* If a timeout is encountered, give up eventually. */ + return result = paTimedOut; } } /* Now, the ring buffer contains the required amount of free -- 2.43.0