| Summary: | WASAPI_WaitDevice hang | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Matt Brocklehurst <matt.brocklehurst> |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | blocker | ||
| Priority: | P2 | Keywords: | target-2.0.10 |
| Version: | HG 2.1 | ||
| Hardware: | x86 | ||
| OS: | Windows 7 | ||
Tagging a bunch of bugs with "target-2.0.10" so we have a clear list of things to address before a 2.0.10 release. Please note that "addressing" one of these bugs might mean deciding to defer on it until after 2.0.10, or resolving it as WONTFIX, etc. This is just here to tell us we should look at it carefully, and soon. If you have new information or feedback on this issue, this is a good time to add it to the conversation, as we're likely to be paying attention to this specific report in the next few days/weeks. Thanks! --ryan. Patch added, thanks! https://hg.libsdl.org/SDL/rev/bfd1b2fc6e2f |
Hi We've noticed that if you are playing audio on Windows via the WASAPI interface and you unplug and reconnect the device a few times the program hangs. We've debugged the problem down to static void WASAPI_WaitDevice(_THIS) { ... snip ... if (WaitForSingleObjectEx(this->hidden->event, INFINITE, FALSE) == WAIT_OBJECT_0) { ... snip ... } This WaitForSingleObjectEx does not havbe a time out defined, so it hangs there forever. Our suggested fix we found was to include a time out of say 200mSec DWORD eventRet = WaitForSingleObjectEx(this->hidden->event, 200, FALSE); if (eventRet == WAIT_OBJECT_0) { const UINT32 maxpadding = this->spec.samples; UINT32 padding = 0; if (!WasapiFailed(this, IAudioClient_GetCurrentPadding(this->hidden->client, &padding))) { /*SDL_Log("WASAPI EVENT! padding=%u maxpadding=%u", (unsigned int)padding, (unsigned int)maxpadding);*/ if (padding <= maxpadding) { break; } } } else if (eventRet != WAIT_TIMEOUT) { /*SDL_Log("WASAPI FAILED EVENT!");*/ IAudioClient_Stop(this->hidden->client); SDL_OpenedAudioDeviceDisconnected(this); } We have done quite a bit of testing with this fix in place on various hardware configurations and it seems to have resolved the issue. Many thanks in advance Regards Matt Brocklehurst, Inspired Gaming.