Mercurial > sdl-ios-xcode
changeset 1562:1d487a3fab41
Fixed bug #18
Reordered the audio thread loop so there's no initial wait.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 21 Mar 2006 06:45:47 +0000 |
parents | c724c4a99759 |
children | b054590b967a |
files | src/audio/SDL_audio.c |
diffstat | 1 files changed, 8 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- 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);