Skip to content

Commit

Permalink
Fixed bug #18
Browse files Browse the repository at this point in the history
Reordered the audio thread loop so there's no initial wait.
  • Loading branch information
slouken committed Mar 21, 2006
1 parent 627d788 commit 4b93414
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/audio/SDL_audio.c
Expand Up @@ -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"));
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4b93414

Please sign in to comment.