Various bugfixes for music looping
authorStephane Peter <megastep@lokigames.com>
Sat, 30 Oct 1999 22:57:49 +0000
changeset 113939a99bf422
parent 10 2fbd0414a1fc
child 12 f38e14b566c8
Various bugfixes for music looping
music.c
     1.1 --- a/music.c	Sat Oct 30 00:21:34 1999 +0000
     1.2 +++ b/music.c	Sat Oct 30 22:57:49 1999 +0000
     1.3 @@ -116,13 +116,6 @@
     1.4  			lowlevel_halt(); /* This function sets music_playing to NULL */
     1.5  			return;
     1.6  		}	
     1.7 -		if ( music_playing && music_loops && !lowlevel_playing() ) {
     1.8 -			if ( -- music_loops ) {
     1.9 -				Mix_RewindMusic();
    1.10 -				if ( lowlevel_play(music_playing) < 0 )
    1.11 -					music_stopped = 1; /* Something went wrong */
    1.12 -			}
    1.13 -		}
    1.14  		if ( !music_stopped && music_playing->fading != MIX_NO_FADING ) {
    1.15  			Uint32 ticks = SDL_GetTicks() - music_playing->ticks_fade;
    1.16  			if( ticks > music_playing->fade_length ) {
    1.17 @@ -149,6 +142,16 @@
    1.18  				}
    1.19  			}
    1.20  		}
    1.21 +		if ( music_loops && !lowlevel_playing() ) {
    1.22 +			if ( -- music_loops ) {
    1.23 +				Mix_RewindMusic();
    1.24 +				if ( lowlevel_play(music_playing) < 0 ) {
    1.25 +					fprintf(stderr,"Warning: Music restart failed.\n");
    1.26 +					music_stopped = 1; /* Something went wrong */
    1.27 +					music_playing->fading = MIX_NO_FADING;
    1.28 +				}
    1.29 +			}
    1.30 +		}
    1.31  		switch (music_playing->type) {
    1.32  #ifdef CMD_MUSIC
    1.33  			case MUS_CMD:
    1.34 @@ -625,6 +628,7 @@
    1.35  	music_playing->fading = MIX_NO_FADING;
    1.36  	music_playing = 0;
    1.37  	music_active = 0;
    1.38 +	music_loops = 0;
    1.39  	music_stopped = 0;
    1.40  }
    1.41