@@ -678,6 +678,7 @@ static int SDLCALL SDL_RunAudio(void *userdata)
678678 int data_len = 0 ;
679679 Uint8 * data ;
680680 Uint8 * device_buf_keepsafe = NULL ;
681+ Uint32 delay ;
681682
682683 SDL_assert (!device -> iscapture );
683684
@@ -761,7 +762,7 @@ static int SDLCALL SDL_RunAudio(void *userdata)
761762 SDL_assert ((got <= 0 ) || (got == device -> spec .size ));
762763
763764 if (data == NULL ) { /* device is having issues... */
764- const Uint32 delay = ((device -> spec .samples * 1000 ) / device -> spec .freq );
765+ delay = ((device -> spec .samples * 1000 ) / device -> spec .freq );
765766 SDL_Delay (delay ); /* wait for as long as this buffer would have played. Maybe device recovers later? */
766767 } else {
767768 if (got != device -> spec .size ) {
@@ -781,7 +782,7 @@ static int SDLCALL SDL_RunAudio(void *userdata)
781782 }
782783 } else if (data == device -> work_buffer ) {
783784 /* nothing to do; pause like we queued a buffer to play. */
784- const Uint32 delay = ((device -> spec .samples * 1000 ) / device -> spec .freq );
785+ delay = ((device -> spec .samples * 1000 ) / device -> spec .freq );
785786 SDL_Delay (delay );
786787 } else { /* writing directly to the device. */
787788 /* queue this buffer and wait for it to finish playing. */
@@ -791,7 +792,11 @@ static int SDLCALL SDL_RunAudio(void *userdata)
791792 }
792793
793794 /* Wait for the audio to drain. */
794- SDL_Delay (((device -> spec .samples * 1000 ) / device -> spec .freq ) * 2 );
795+ delay = ((device -> spec .samples * 1000 ) / device -> spec .freq ) * 2 ;
796+ if (delay > 100 ) {
797+ delay = 100 ;
798+ }
799+ SDL_Delay (delay );
795800
796801 current_audio .impl .ThreadDeinit (device );
797802
0 commit comments