AudioTransportSource::stop()


#1

Hello Jules,

I’m trying to play several audio files thru AudioTransportSource. Some are in loop, some are playing, some are in stop etc…
But when I stop one of them that was playing, there’s some kind of freeze happening, with all tracks being muted.
I guess it could be related to the Thread::sleep (2); bellow ?

[code]void AudioTransportSource::stop()
{
if (playing)
{
{
const ScopedLock sl (callbackLock);
playing = false;
}

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

    sendChangeMessage();
}

}[/code]
Any workaround ?

Salvator


#2

Well that method blocks until the audio thread has stopped playing, there’s nothing wrong with the way it’s written… If you’re getting a deadlock, then your audio thread must be blocked waiting for something. Surely it’s obvious to see what’s happening in your debugger?


#3

I was calling stop() from within the audio processing chain.
Using a ChangeListener and ChangeMessage to trigger stop() works fine, so I’ll just use that, since I’m not concerned about sample precision here.

Salvator


#4

It is important to keep calling the transportSource.getNextAudioBlock(...) method even when the transportSource is not playing.

Not calling it right after a stop will cause a 1s freeze of the thread per sound to stop. In my situation I am playing 80 audio files...