From 4b934147050596a4d59d195f7c63774556c375a9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 21 Mar 2006 06:45:47 +0000 Subject: [PATCH] Fixed bug #18 Reordered the audio thread loop so there's no initial wait. --- src/audio/SDL_audio.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 9e3eae1cd..2eabb220f 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -174,11 +174,6 @@ int SDL_RunAudio(void *audiop) 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 @@ int SDL_RunAudio(void *audiop) /* 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 @@ int SDL_RunAudio(void *audiop) /* 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);