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.

This commit is contained in:
Matthew Budd 2020-07-27 21:20:25 -04:00
parent 3528adea30
commit 3c2a93d7c4
1 changed files with 9 additions and 1 deletions

View File

@ -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;