| Summary: | Infinite wait in SDL_CloseAudioDevice using winmm audio driver | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Kieran Yee <k_yee22> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | k_yee22, philipp.wiesemann |
| Version: | HG 2.1 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 10 | ||
| Attachments: | Short program to demonstrate the problem | ||
SDL_CloseAudioDevice() waits for the audio thread to finish. This thread spins in WINMM_WaitDone() because the shutdown was requested before the playback was started. This bug should be fixed when we stopped letting the audio targets be in charge of draining their own buffers on exit: https://hg.libsdl.org/SDL/rev/d6427519ca66 (Please feel free to reopen this bug if this is still a problem though!) --ryan. |
Created attachment 2554 [details] Short program to demonstrate the problem Tested compiling with both Visual Studio and MinGW-w64, using SDL2 compiled from fresh (rev 10222) sources, as well as 2.0.4 sources. The sample program will reproduce the problem, but the gist of it is: - Make sure SDL is using the winmm audio driver (export/set SDL_AUDIODRIVER=winmm) - Open an audio device - Immediately close that audio device SDL_CloseAudioDevice will never return. Only occurs when using the winmm audio driver. Adding a delay of any length between the two steps using SDL_Delay will "solve" the problem. I think this happens because of the audio device being placed in shutdown before the child thread gets to run? Will continue investigating.