PortAudio/portaudio

DirectSound Host API does not join its streaming thread correctly

dechamps opened this issue · 0 comments

In Pa_StopStream() the DirectSound Host API waits for the streaming thread to signal a processingThreadCompleted event and then assumes the thread is done when that happens:

if( WaitForSingleObject( stream->processingThreadCompleted, 30*100 ) == WAIT_TIMEOUT )

This is almost correct, but not quite. By the time the event is signaled, the thread is about to exit, but it has not exited yet.

This means that by the time Pa_StopStream() returns, the thread could still be running. If the application decides to unload the PortAudio DLL by that point, hilarity could ensue.

The correct way to do this is to wait on the thread handle itself, which is both safer and simpler.

I already have a fix for this in #922.