From 571b2f34d378441f4f3707b531f7175238f6c3da Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 31 Dec 2011 23:28:23 -0500 Subject: [PATCH] Backed out changeset 1eddea51f162 --- CHANGES | 2 -- music.c | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 31e372f9..71ff2686 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,4 @@ 1.2.12: -Sam Lantinga - Sat Dec 31 22:56:34 EST 2011 - * Fixed looping MIDI music Sam Lantinga - Sat Dec 31 19:11:59 EST 2011 * Fixed dropping audio in the FLAC audio decoding Sam Lantinga - Sat Dec 31 18:32:05 EST 2011 diff --git a/music.c b/music.c index 50c43d39..452aacf7 100644 --- a/music.c +++ b/music.c @@ -196,6 +196,7 @@ void Mix_HookMusicFinished(void (*music_finished)(void)) static int music_halt_or_loop (void) { /* Restart music if it has to loop */ + if (!music_internal_playing()) { /* Restart music if it has to loop at a high level */ @@ -251,6 +252,10 @@ void music_mixer(void *udata, Uint8 *stream, int len) } } + music_halt_or_loop(); + if (!music_internal_playing()) + return; + switch (music_playing->type) { #ifdef CMD_MUSIC case MUS_CMD: @@ -277,14 +282,14 @@ void music_mixer(void *udata, Uint8 *stream, int len) #ifdef USE_FLUIDSYNTH_MIDI if ( fluidsynth_ok ) { fluidsynth_playsome(music_playing->data.fluidsynthmidi, stream, len); - break; + goto skip; } #endif #ifdef USE_TIMIDITY_MIDI if ( timidity_ok ) { int samples = len / samplesize; Timidity_PlaySome(stream, samples); - break; + goto skip; } #endif break; @@ -314,12 +319,14 @@ void music_mixer(void *udata, Uint8 *stream, int len) /* Unknown music type?? */ break; } + } - /* Handle seamless music looping */ +skip: + /* Handle seamless music looping */ + if (left > 0 && left < len) { music_halt_or_loop(); - if (left > 0 && left < len && music_internal_playing()) { + if (music_internal_playing()) music_mixer(udata, stream+(len-left), left); - } } }