mirror of https://github.com/encounter/SDL.git
Fixed bug 4605 - WASAPI_WaitDevice hang
Matt Brocklehurst 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 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.
This commit is contained in:
parent
82af42761e
commit
8a37848de9
|
@ -312,8 +312,8 @@ static void
|
||||||
WASAPI_WaitDevice(_THIS)
|
WASAPI_WaitDevice(_THIS)
|
||||||
{
|
{
|
||||||
while (RecoverWasapiIfLost(this) && this->hidden->client && this->hidden->event) {
|
while (RecoverWasapiIfLost(this) && this->hidden->client && this->hidden->event) {
|
||||||
/*SDL_Log("WAITDEVICE");*/
|
DWORD waitResult = WaitForSingleObjectEx(this->hidden->event, 200, FALSE);
|
||||||
if (WaitForSingleObjectEx(this->hidden->event, INFINITE, FALSE) == WAIT_OBJECT_0) {
|
if (waitResult == WAIT_OBJECT_0) {
|
||||||
const UINT32 maxpadding = this->spec.samples;
|
const UINT32 maxpadding = this->spec.samples;
|
||||||
UINT32 padding = 0;
|
UINT32 padding = 0;
|
||||||
if (!WasapiFailed(this, IAudioClient_GetCurrentPadding(this->hidden->client, &padding))) {
|
if (!WasapiFailed(this, IAudioClient_GetCurrentPadding(this->hidden->client, &padding))) {
|
||||||
|
@ -322,7 +322,7 @@ WASAPI_WaitDevice(_THIS)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (waitResult != WAIT_TIMEOUT) {
|
||||||
/*SDL_Log("WASAPI FAILED EVENT!");*/
|
/*SDL_Log("WASAPI FAILED EVENT!");*/
|
||||||
IAudioClient_Stop(this->hidden->client);
|
IAudioClient_Stop(this->hidden->client);
|
||||||
SDL_OpenedAudioDeviceDisconnected(this);
|
SDL_OpenedAudioDeviceDisconnected(this);
|
||||||
|
|
Loading…
Reference in New Issue