From d6329109afaced20a7461298f8018ab5620d6911 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 15 Jun 2011 03:41:31 -0400 Subject: [PATCH] Let the music-finished hook start a new track without a skip in the audio. Previously, there'd be no more music mixed until the next SDL audio callback fired. Now if the hook (re)starts a track, it'll start mixing right away, into whatever space is left in the callback where the hook was called. This is useful if you have an mp3 that, after one playthrough, is replaced with a looping mp3 that contains the rest of the song on repeat. No more gap between the two. --- music.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/music.c b/music.c index 30cef34f..a8a66a7a 100644 --- a/music.c +++ b/music.c @@ -253,10 +253,10 @@ void music_mixer(void *udata, Uint8 *stream, int len) } } - if (music_halt_or_loop() == 0) + music_halt_or_loop(); + if (!music_internal_playing()) return; - - + switch (music_playing->type) { #ifdef CMD_MUSIC case MUS_CMD: @@ -324,8 +324,10 @@ void music_mixer(void *udata, Uint8 *stream, int len) skip: /* Handle seamless music looping */ - if (left > 0 && left < len && music_halt_or_loop()) { - music_mixer(udata, stream+(len-left), left); + if (left > 0 && left < len) { + music_halt_or_loop(); + if (music_internal_playing()) + music_mixer(udata, stream+(len-left), left); } }