music.c
changeset 528 bc0dfe8ae026
parent 527 1eddea51f162
child 529 9ca74f21d466
     1.1 --- a/music.c	Sat Dec 31 23:00:03 2011 -0500
     1.2 +++ b/music.c	Sat Dec 31 23:28:23 2011 -0500
     1.3 @@ -196,6 +196,7 @@
     1.4  static int music_halt_or_loop (void)
     1.5  {
     1.6  	/* Restart music if it has to loop */
     1.7 +	
     1.8  	if (!music_internal_playing()) 
     1.9  	{
    1.10  		/* Restart music if it has to loop at a high level */
    1.11 @@ -251,6 +252,10 @@
    1.12  			}
    1.13  		}
    1.14  		
    1.15 +		music_halt_or_loop();
    1.16 +		if (!music_internal_playing())
    1.17 +			return;
    1.18 +
    1.19  		switch (music_playing->type) {
    1.20  #ifdef CMD_MUSIC
    1.21  			case MUS_CMD:
    1.22 @@ -277,14 +282,14 @@
    1.23  #ifdef USE_FLUIDSYNTH_MIDI
    1.24  				if ( fluidsynth_ok ) {
    1.25  					fluidsynth_playsome(music_playing->data.fluidsynthmidi, stream, len);
    1.26 -					break;
    1.27 +					goto skip;
    1.28  				}
    1.29  #endif
    1.30  #ifdef USE_TIMIDITY_MIDI
    1.31  				if ( timidity_ok ) {
    1.32  					int samples = len / samplesize;
    1.33    					Timidity_PlaySome(stream, samples);
    1.34 -					break;
    1.35 +					goto skip;
    1.36  				}
    1.37  #endif
    1.38  				break;
    1.39 @@ -314,12 +319,14 @@
    1.40  				/* Unknown music type?? */
    1.41  				break;
    1.42  		}
    1.43 +	}
    1.44  
    1.45 -		/* Handle seamless music looping */
    1.46 +skip:
    1.47 +	/* Handle seamless music looping */
    1.48 +	if (left > 0 && left < len) {
    1.49  		music_halt_or_loop();
    1.50 -		if (left > 0 && left < len && music_internal_playing()) {
    1.51 +		if (music_internal_playing())
    1.52  			music_mixer(udata, stream+(len-left), left);
    1.53 -		}
    1.54  	}
    1.55  }
    1.56