Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wait for the portaudio finished callback to avoid sporadic deadlocks #14208

Open
wants to merge 1 commit into
base: 2.5
Choose a base branch
from

Conversation

m0dB
Copy link
Contributor

@m0dB m0dB commented Jan 20, 2025

This fixes #14055 . I describe the issue in detail in the bug report.

The fix consists of using Pa_SetStreamFinishedCallback to set a callback to wait for the stream to finish before continuing the main thread.

I have tested this by starting and stopping the devices programmatically in a loop. After 5000 iterations I still haven't had a deadlock, so I am confident the issue is fixed (without the fix I would get a deadlock every ~50 iterations).

Btw, there was this warning in the code (I have removed it):

        // BIG FAT WARNING: Pa_AbortStream() will kill threads while they're
        // waiting on a mutex, which will leave the mutex in an screwy
        // state. Don't use it!

This might be the same problem as described in #14055, and it is possible that with this fix we could also use Pa_AbortStream, instead of using the paAbort return value from the callback. But I didn't want to change the code more than necessary, and only add the wait condition, which is simple and safe.

@m0dB m0dB changed the title wait for the portaudio finished callback to avoid spurious deadlocks wait for the portaudio finished callback to avoid sporadic deadlocks Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant