[Stk] RtAudio - Problems when stopping stream (WaitForSingleObject)

Carlos Luna clunaz at hotmail.com
Wed Mar 21 11:33:48 PDT 2012


I think I know where the problem is:
(In RtAudio.cpp file)
In void RtApiDs :: stopStream(), in line 4485, there is this:
.....if ( handle->drainCounter == 0 ) {      handle->drainCounter = 2;... WaitForSingleObject( handle->condition, INFINITE );  // block until signaled...}.....
Then, in line 4639 ( void RtApiDs :: callbackEvent() ) there is this:
if ( handle->drainCounter == 2 ) {      //      MUTEX_UNLOCK( &stream_.mutex );      abortStream();      return;    }....
So stopStream() sets drainCounter to 2, and waits until signaled ( WaitForSingleObject(...) ).
callbackEvent()  then checks if drainCounter == 2 and if that´s the case, it aborts the stream. BUT, just before 4639, there is this:
handle->drainCounter = callback( stream_.userBuffer[0], stream_.userBuffer[1],                                     stream_.bufferSize, streamTime, status, info->userData );
And my callback always returns 0. So if stopStream() sets drainCounter to 2 and the user callback returns (resetting drainCounter to 0) before callbackEvent() has the oportunity to notice that drainCounter had been set to 2, the stream will be never aborted (because it will be only if drainCounter == 2).
Hope this makes sense.
Carlos

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ccrma-mail.stanford.edu/pipermail/stk/attachments/20120321/0a09f6ef/attachment.html 


More information about the Stk mailing list