-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
WASAPI can't initialize audio client: CoInitialize has not been called. #7478
Comments
Oh weird, let me see if I can reproduce it here. Is this opening the audio device without initializing the video subsystem? I'm wondering if we unintentionally relied on that to initialize COM. |
No, the video subsystem is necessarily initialized. The audio subsystem is initialized unless audio is explicitly disabled (in other words, it is initialized in this case). |
...are you opening an audio device from a background thread? It certainly seems like we are not calling WIN_CoInitialize() during device open, so that would likely trigger this issue. |
Yes. Concretely, I receive an audio stream from a socket from a demuxer thread. Once the stream starts, it opens its sinks (a decoder), which itself opens its sinks (an audio player). This is from there that I call It is called from there for several reasons:
|
Yes, we should call WIN_CoInitialize() during device opening and cleanup during device closing. It's safe to call this on the same thread, so it should be fine. |
Okay, just confirming. I'll add in a CoInitialize call, which should fix this. |
Otherwise this won't work if you open a device on a background thread. Fixes libsdl-org#7478.
#7489 is untested but should fix this for SDL2, but please close the audio device from the same thread you opened it, or it will cause a leak. For SDL3, I'm reworking how audio devices get opened, so hopefully this will be a non-issue there in any case. |
Thank you very much 👍 Will the CI generate a ready-to-use
Yes, opening and closing is from the same thread. 👌 |
Otherwise this won't work if you open a device on a background thread. Fixes #7478.
I don't believe it does at the moment. :( |
2.26.5 should have this fix, if you want to grab those binaries. |
No, I think it will only be in 2.28. |
Oh, you're right, sorry about that! |
I'm closing this under the assumption it's fixed in 2.28.0, which is coming shortly. Let's reopen this if there's still an issue, though. |
@icculus I confirm that SDL 2.28RC1 seems to fix the probem: Genymobile/scrcpy#3825 (comment) 🎉 |
Thank you for patiently waiting for binaries for so long, and then jumping right in to test them! |
Include the latest version of SDL in Windows releases. Fixes #3825 <#3825> Refs libsdl/#7478 <libsdl-org/SDL#7478>
I don't know if this is related, but sometimes, there is an error:
While with directsound it seems to work. See Genymobile/scrcpy#4111 (just for your information). |
Please open a separate issue if you'd like this tracked, we usually don't look at closed bug reports. |
The call to
SDL_OpenAudioDevice(NULL, 0, &desired, &obtained, 0)
fails with the following error:Maybe related: #5552 (but apparently it still fails in 2.26.3)
(source: Genymobile/scrcpy#3825)
The text was updated successfully, but these errors were encountered: