-
Notifications
You must be signed in to change notification settings - Fork 318
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
Pa_Initialize() interrupts other audio streams on Windows #858
Comments
This is not surprising. The way PortAudio initialization works is fundamentally flawed when ASIO is involved, and always has been. See #696. My suggestion would be stop building PortAudio with ASIO support, and instead use the ASIO API directly from your code if you absolutely require ASIO support. |
Though thinking about this a bit more, I find it a bit odd that you're describing a bug that is triggered specifically by exclusive mode being enabled on the default Windows audio device - I never heard of that particular failure mode before. Is this bug reproducible even with no ASIO drivers installed on the system? If not, can you pinpoint precisely which ASIO driver is causing it? |
I see. It's unfortunate that the issue is upstream, but your suggestion is understandable. Thanks for the quick response.
I'd imagine disabling exclusive mode--and thus having all audio streams only run in shared mode--incidentally prevents the conditions for the issue to happen, as no application can exclusively control the audio device and consequently kill other active audio streams, if improperly initialized/interfaced with.
I'm a complete amateur when it comes to low-level audio interfaces; that said, I don't believe I have any ASIO drivers installed, unless the default audio driver counts. In that case, I believe it would be the |
The thing is, that concept of "exclusive mode" is only relevant to the Windows Audio Engine. Not every audio code path goes through the Windows Audio Engine. WDM-KS doesn't, for example, and will therefore completely ignore that setting. I wouldn't expect a manufacturer-provided ASIO driver to go through the Windows Audio Engine. Instead, I would expect it to bypass the entire stack and talk to the hardware directly through some side channel. However, it is definitely true that the author of an ASIO driver technically doesn't have to bypass the Windows Audio Engine - they could simply use it like any other app (especially if they're lazy…).
There is no such thing as a "default ASIO driver". Windows doesn't come with any ASIO drivers. That said, I guess it's possible a manufacturer-provided audio driver that comes bundled with your computer (or perhaps even installed through Windows Update) could come with an ASIO driver that gets installed as a side effect of installing the Windows audio driver. You can remove ASIO drivers by removing subkeys from the
My main hypothesis at this point is that Realtek implemented that ASIO driver by simply making it use WASAPI Exclusive behind the scenes, and as a result it takes over exclusive mode when it's initialized. That would explain your symptoms. To be fair, implementing an ASIO driver that way is perfectly reasonable and Realtek is likely blameless here; it's PortAudio that's being unreasonable by attempting to load every single ASIO driver in the system in its initialization sequence, as explained in #696. |
I've removed the Realtek ASIO driver and installed the FlexASIO driver instead to test if the behaviour persists. I can confirm that the issue doesn't occur, which is great news. In the end, it comes down to the host ASIO driver(s)' implementation, as you mentioned previously, which is unfortunately unpredictable and outside the control of application developers. Would it be possible to extend Thanks for the detailed and informative replies, both here and in the other threads. |
So would I be correct to say that this issue is actually an issue in the Realtek ASIO driver and the problem is resolved? As for your suggestion, it is covered here: #10 |
Yes, correct. The Realtek ASIO driver turned out to be the root cause of this issue. I'll be closing this issue since the problem's origin has been identified and lies outside this project. That said, thanks for the progress on #10. Providing more granular control and the ability to selectively enable host APIs at run-time rather than build-time--depending on the host environment and the |
Describe the bug
Calling
Pa_Initialize()
to initialize PortAudio interrupts any currently playing audio streams momentarily on Windows if exclusive mode is enabled on the default sound device. Strangely, this issue only occurs if the PortAudio binary being used was compiled with ASIO, otherwise this bug does not occur.To Reproduce
Pa_Initialize()
Expected behavior
Other audio streams are uninterrupted while PortAudio is initializing.
Actual behavior
All other audio streams are interrupted while PortAudio is initializing, sometimes without recovery.
Desktop:
Additional context
An initial discussion of this issue was started on
python-sounddevice
, which can be seen here: spatialaudio/python-sounddevice#496The text was updated successfully, but these errors were encountered: