From 3c2a93d7c4856371deeb7defac9e12d49ff8a490 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Mon, 27 Jul 2020 21:20:25 -0400 Subject: [PATCH] Added a protection in the audio output loop to break out of the loop if the audio sink is not draining. This will prevent lockups in the event that the audio output device has failed. --- src/drivers/Qt/sdl-sound.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/drivers/Qt/sdl-sound.cpp b/src/drivers/Qt/sdl-sound.cpp index 28c263ba..d869fc49 100644 --- a/src/drivers/Qt/sdl-sound.cpp +++ b/src/drivers/Qt/sdl-sound.cpp @@ -195,11 +195,19 @@ WriteSound(int32 *buf, extern int EmulationPaused; if (EmulationPaused == 0) { + int waitCount = 0; + while(Count) { while(s_BufferIn == s_BufferSize) { - SDL_Delay(1); + SDL_Delay(1); waitCount++; + + if ( waitCount > 1000 ) + { + printf("Error: Sound sink is not draining... Breaking out of audio loop to prevent lockup.\n"); + return; + } } s_Buffer[s_BufferWrite] = *buf;