Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Various bugfixes for music looping
  • Loading branch information
Stephane Peter committed Oct 30, 1999
1 parent 0968985 commit c435e01
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions music.c
Expand Up @@ -116,13 +116,6 @@ void music_mixer(void *udata, Uint8 *stream, int len)
lowlevel_halt(); /* This function sets music_playing to NULL */
return;
}
if ( music_playing && music_loops && !lowlevel_playing() ) {
if ( -- music_loops ) {
Mix_RewindMusic();
if ( lowlevel_play(music_playing) < 0 )
music_stopped = 1; /* Something went wrong */
}
}
if ( !music_stopped && music_playing->fading != MIX_NO_FADING ) {
Uint32 ticks = SDL_GetTicks() - music_playing->ticks_fade;
if( ticks > music_playing->fade_length ) {
Expand All @@ -149,6 +142,16 @@ void music_mixer(void *udata, Uint8 *stream, int len)
}
}
}
if ( music_loops && !lowlevel_playing() ) {
if ( -- music_loops ) {
Mix_RewindMusic();
if ( lowlevel_play(music_playing) < 0 ) {
fprintf(stderr,"Warning: Music restart failed.\n");
music_stopped = 1; /* Something went wrong */
music_playing->fading = MIX_NO_FADING;
}
}
}
switch (music_playing->type) {
#ifdef CMD_MUSIC
case MUS_CMD:
Expand Down Expand Up @@ -625,6 +628,7 @@ static void lowlevel_halt(void)
music_playing->fading = MIX_NO_FADING;
music_playing = 0;
music_active = 0;
music_loops = 0;
music_stopped = 0;
}

Expand Down

0 comments on commit c435e01

Please sign in to comment.