Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Let the music-finished hook start a new track without a skip in the a…
…udio.

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.
  • Loading branch information
icculus committed Jun 15, 2011
1 parent 10bc7e4 commit d632910
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions music.c
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit d632910

Please sign in to comment.