playmus.c
changeset 10 2fbd0414a1fc
parent 4 5c4485704b30
child 13 1e489d8b97d8
     1.1 --- a/playmus.c	Wed Oct 27 22:49:38 1999 +0000
     1.2 +++ b/playmus.c	Sat Oct 30 00:21:34 1999 +0000
     1.3 @@ -43,20 +43,20 @@
     1.4  		Mix_FadeOutMusic(1500);
     1.5  		SDL_Delay(1500);
     1.6  	}
     1.7 +	if ( music ) {
     1.8 +		Mix_FreeMusic(music);
     1.9 +		music = NULL;
    1.10 +	}
    1.11  	if ( audio_open ) {
    1.12  		Mix_CloseAudio();
    1.13  		audio_open = 0;
    1.14  	}
    1.15 -	if ( music ) {
    1.16 -		Mix_FreeMusic(music);
    1.17 -		music = NULL;
    1.18 -	}
    1.19  	SDL_Quit();
    1.20  }
    1.21  
    1.22  void Usage(char *argv0)
    1.23  {
    1.24 -	fprintf(stderr, "Usage: %s [-8] [-r rate] [-s] <musicfile>\n", argv0);
    1.25 +	fprintf(stderr, "Usage: %s |-l] [-8] [-r rate] [-s] <musicfile>\n", argv0);
    1.26  }
    1.27  	
    1.28  main(int argc, char *argv[])
    1.29 @@ -64,6 +64,7 @@
    1.30  	Uint32 audio_rate;
    1.31  	Uint16 audio_format;
    1.32  	int audio_channels;
    1.33 +	int looping = 0;
    1.34  	int i;
    1.35  
    1.36  	/* Initialize variables */
    1.37 @@ -80,6 +81,9 @@
    1.38  		if ( strcmp(argv[i], "-m") == 0 ) {
    1.39  			audio_channels = 1;
    1.40  		} else
    1.41 +		if ( strcmp(argv[i], "-l") == 0 ) {
    1.42 +			looping = -1;
    1.43 +		} else
    1.44  		if ( strcmp(argv[i], "-8") == 0 ) {
    1.45  			audio_format = AUDIO_U8;
    1.46  		} else {
    1.47 @@ -125,7 +129,7 @@
    1.48  	}
    1.49  
    1.50  	/* Play and then exit */
    1.51 -	Mix_FadeInMusic(music,0,2000);
    1.52 +	Mix_FadeInMusic(music,looping,2000);
    1.53  	while ( Mix_PlayingMusic() ) {
    1.54  		SDL_Delay(100);
    1.55  	}