music.c
changeset 533 f19368c22ebd
parent 531 f9c790738ec3
child 538 b5e3fe1b5a09
     1.1 --- a/music.c	Sun Jan 01 14:40:22 2012 -0500
     1.2 +++ b/music.c	Sun Jan 01 16:45:58 2012 -0500
     1.3 @@ -199,10 +199,17 @@
     1.4  	
     1.5  	if (!music_internal_playing()) 
     1.6  	{
     1.7 +		/* Native MIDI handles looping internally */
     1.8 +		if (music_playing->type == MUS_MID && native_midi_ok) {
     1.9 +			music_loops = 0;
    1.10 +		}
    1.11 +
    1.12  		/* Restart music if it has to loop at a high level */
    1.13 -		if (music_loops && --music_loops)
    1.14 +		if (music_loops)
    1.15  		{
    1.16 -			Mix_Fading current_fade = music_playing->fading;
    1.17 +			Mix_Fading current_fade;
    1.18 +			--music_loops;
    1.19 +			current_fade = music_playing->fading;
    1.20  			music_internal_play(music_playing, 0.0);
    1.21  			music_playing->fading = current_fade;
    1.22  		} 
    1.23 @@ -791,7 +798,7 @@
    1.24  	    case MUS_MID:
    1.25  #ifdef USE_NATIVE_MIDI
    1.26  		if ( native_midi_ok ) {
    1.27 -			native_midi_start(music->data.nativemidi);
    1.28 +			native_midi_start(music->data.nativemidi, music_loops);
    1.29  			goto skip;
    1.30  		}
    1.31  #endif
    1.32 @@ -889,6 +896,10 @@
    1.33  		SDL_LockAudio();
    1.34  	}
    1.35  	music_active = 1;
    1.36 +	if (loops == 1) {
    1.37 +		/* Loop is the number of times to play the audio */
    1.38 +		loops = 0;
    1.39 +	}
    1.40  	music_loops = loops;
    1.41  	retval = music_internal_play(music, position);
    1.42  	SDL_UnlockAudio();
    1.43 @@ -920,18 +931,6 @@
    1.44  		MOD_jump_to_time(music_playing->data.module, position);
    1.45  		break;
    1.46  #endif
    1.47 -#ifdef MID_MUSIC
    1.48 -	    case MUS_MID:
    1.49 -#ifdef USE_NATIVE_MIDI
    1.50 -		if ( native_midi_ok ) {
    1.51 -			retval = native_midi_jump_to_time(music_playing->data.nativemidi, position);
    1.52 -			break;
    1.53 -		}
    1.54 -#endif
    1.55 -		/* TODO: Implement this for other music backends */
    1.56 -		retval = -1;
    1.57 -		break;
    1.58 -#endif
    1.59  #ifdef OGG_MUSIC
    1.60  	    case MUS_OGG:
    1.61  		OGG_jump_to_time(music_playing->data.ogg, position);