-
Notifications
You must be signed in to change notification settings - Fork 384
On macOS, Pa_AbortStream() takes too long to abort the stream. #367
Description
(Please use the mailing list for support requests and general discussion. This is only for actual bugs.)
Describe the bug
on macOS, I found that Pa_AbortStream() could take as long as a few seconds to abort the stream, which behaves similarly to Pa_StopStream(). This is counter-intuitive against what the doc says about this API function:
/** Terminates audio processing immediately without waiting for pending
buffers to complete.
*
To Reproduce
In my case, it's a pretty straightforward output stream implementation in its own thread.
- sample rate: 48kHz
- buffer size: 2048
The callback consumes the buffer in any way or even does nothing.
Call Pa_AbortStream() in my main thread, the render callback ends normally,
but Pa_AbortStream() could block for a few seconds (up to 10+ secs) for unknown reasons,
which behaves almost the same way as Pa_StopStream(), i.e., no perceivable improvement on the blocking wait.
Expected behavior
Users shouldn't perceive any delay while trying to abort the stream. It should be literally "immediately".
For instance, if a user hits Ctrl-C on a running command-line program, which has a signal handler that tries to perform a special exit procedure in an orderly fashion, then the user shouldn't have to wait 10 seconds before the program quits due to aborting the stream.
Actual behavior
The blocking wait on the scale of a few seconds seems inevitable before the stream is aborted.
Desktop (please complete the following information):
- OS: macOS
- OS Version: 10.15.7
- PortAudio version: stable
Additional context
- Xcode 12.3
- The release build is slightly faster than the debug build for the said problem.