| Summary: | UWP/WinRT WASAPI Audio device creation is not complete when SDL_InitSubSystem returns | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Jeff Loiselle <jeff> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | flibitijibibo |
| Version: | 2.0.10 | Keywords: | target-2.0.12 |
| Hardware: | x86 | ||
| OS: | Windows 10 | ||
| Attachments: | EnumerationComplete handler | ||
|
Description
Jeff Loiselle
2020-02-18 04:05:24 UTC
This should probably wait for 2.0.13, but: I assumed initial device enumeration was synchronous (because surely the system already knows what it has), but apparently not. Likely: it already knows what it has, but sometimes the scheduler lets us move on before the enumeration thread has sent the whole list. Windows.Devices.Enumeration.DeviceWatcher has an EnumerationCompleted event that we aren't watching. https://docs.microsoft.com/en-us/uwp/api/windows.devices.enumeration.devicewatcher.enumerationcompleted So I think we could make a temporary semaphore in WASAPI_EnumerateEndpoints(), start enumeration and wait, and trigger that semaphore from the EnumerationCompleted event, causing WASAPI_EnumerateEndpoints() to destroy the semaphore and return, which would solve this issue, I suspect. It would be safe even if this turns out to be synchronous on some WinRT platforms, too. --ryan. Created attachment 4235 [details]
EnumerationComplete handler
Attached is a patch that adds a handler for EnumerationComplete, which activates a semaphore that EnumerateEndpoints now waits on before leaving the function. Confirmed to work on Windows 10 and Xbox.
This patch is now https://hg.libsdl.org/SDL/rev/0311c59d15f9, thanks! --ryan. |