Does AudioTransportSource block the audio thread on stop?


I have an AudioTransportSource that is part of a graph with other stuff going on.
When I stop the playback, the audio output is left hanging for about 2 seconds, then after this delay the remaining data left in the audioBuffer is able to play the tail.

I found that this bit of code is causing this, and I can’t understand what use it has. Why decrement n, and why is it assigned a value of 500 ? Why block the audio thread ?

I’m tempted to derive my own class from this one and remove this code but I suppose it’s here for a reason, isn’t it ?
Or maybe I should be using something other than AudioTransportSource for playing back audio tracks in a graph ?

void AudioTransportSource::stop()
    if (playing)
        playing = false;

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


Just realised this has been answered several times: