AudioTransportSource thread confusion


I might make a fool of my self now, but there is something I don’t understand with AudioTransportSource
I get it to play, stop, etc, and all seems well.
But when I call void AudioTransportSource::stop() it blocks the calling thread:

int n = 500;
while (--n >= 0 && ! stopped)
    Thread::sleep (2);

What I want to do is to have it stop, both on user input (like a button click) or to stop at a given time (counting samples in the processing callback)
Anyway it will block, if I call it from the message thread, it will lock the app for a while, if I call it from the processing thread, it will block audio.

Do I need to create my own thread, only for stopping the AudioTransportSource ? I’m guessing I have missed a critical point here :slight_smile:


Ok, figured it out. It was partly my bad for not calling processBlock after the stop().
It seems the stop command involves a fade during the next callback, and the sleep is there to make sure the changemessage is not sent before the fade is done. Not sure I like that solution, but I got other things to worry about. :wink: