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

Stephen Sinclair sinclair at music.mcgill.ca
Tue Mar 20 12:39:39 PDT 2012


On Tue, Mar 20, 2012 at 12:30 PM, Carlos Luna <clunaz at hotmail.com> wrote:
> Hi. My problem is as follows:
>
> I have a couple of objects in my app. One object is an audio engine. That
> object has an object of type RtAudio and handles interaction with it.
> The callback function for RtAudio is in some other object.
>
> In my audio engine destructor, I call the corresponding functions to stop
> the stream before deleting the RtAudio object.
> When RtAudio calls  "void RtApiDs :: stopStream()" (I´m using Direct Sound
> here), the program executes up to:
>
>  WaitForSingleObject( handle->condition, INFINITE );  // block until
> signaled
>
> And then stops there, apparently waiting for something to happen. Meanwhile,
> the callback function still get called and nothing else happens.
>
> Any ideas what could be wrong?
>
> I´m using Windows XP, VC2008, using Direct Sound with my Asus 1000HA
> internal sound system.

I believe what is supposed to happen is that the RtAudio callback
continues to run but without calling the user callback, until a
counter (drainCounter) exceeds the number of buffers, at which time it
calls SetEvent() on that condition.
You'll probably have to trace through and see why either drainCounter
is not incremented, or otherwise why it's never getting to the
SetEvent() call.  How many times does the callback get called after
stopStream()?

Maybe it would be more robust to have a 2-second timeout or something
instead of using INFINITE for this wait, but it would be good to
determine why it's deadlocking.

Steve



More information about the Stk mailing list