# HG changeset patch # User Sam Lantinga # Date 1142923547 0 # Node ID 1d487a3fab41f23879cc7d47f5613e9c62211a3c # Parent c724c4a997594979404cf8532deebc2eb4e5ddd8 Fixed bug #18 Reordered the audio thread loop so there's no initial wait. diff -r c724c4a99759 -r 1d487a3fab41 src/audio/SDL_audio.c --- a/src/audio/SDL_audio.c Tue Mar 21 00:56:10 2006 +0000 +++ b/src/audio/SDL_audio.c Tue Mar 21 06:45:47 2006 +0000 @@ -174,11 +174,6 @@ stream_len = audio->spec.size; } - stream = audio->GetAudioBuf(audio); - if ( stream == NULL ) { - stream = audio->fake_stream; - } - #if SDL_AUDIO_DRIVER_AHI SDL_mutexV(audio->mixer_lock); D(bug("Entering audio loop...\n")); @@ -208,16 +203,6 @@ /* Loop, filling the audio buffers */ while ( audio->enabled ) { - /* Wait for new current buffer to finish playing */ - if ( stream == audio->fake_stream ) { - SDL_Delay((audio->spec.samples*1000)/audio->spec.freq); - } else { -#if SDL_AUDIO_DRIVER_AHI - if ( started > 1 ) -#endif - audio->WaitAudio(audio); - } - /* Fill the current buffer with sound */ if ( audio->convert.needed ) { if ( audio->convert.buf ) { @@ -253,12 +238,16 @@ /* Ready current buffer for play and change current buffer */ if ( stream != audio->fake_stream ) { audio->PlayAudio(audio); -#if SDL_AUDIO_DRIVER_AHI -/* AmigaOS don't have to wait the first time audio is played! */ - started++; -#endif + } + + /* Wait for an audio buffer to become available */ + if ( stream == audio->fake_stream ) { + SDL_Delay((audio->spec.samples*1000)/audio->spec.freq); + } else { + audio->WaitAudio(audio); } } + /* Wait for the audio to drain.. */ if ( audio->WaitDone ) { audio->WaitDone(audio);