playmus.c
changeset 4 5c4485704b30
parent 0 4ce2db4db959
child 10 2fbd0414a1fc
equal deleted inserted replaced
3:f6dabb779e45 4:5c4485704b30
    37 static int audio_open = 0;
    37 static int audio_open = 0;
    38 static Mix_Music *music = NULL;
    38 static Mix_Music *music = NULL;
    39 
    39 
    40 void CleanUp(void)
    40 void CleanUp(void)
    41 {
    41 {
       
    42 	if( Mix_PlayingMusic() ) {
       
    43 		Mix_FadeOutMusic(1500);
       
    44 		SDL_Delay(1500);
       
    45 	}
    42 	if ( audio_open ) {
    46 	if ( audio_open ) {
    43 		Mix_CloseAudio();
    47 		Mix_CloseAudio();
    44 		audio_open = 0;
    48 		audio_open = 0;
    45 	}
    49 	}
    46 	if ( music ) {
    50 	if ( music ) {
   119 						argv[i], SDL_GetError());
   123 						argv[i], SDL_GetError());
   120 		exit(2);
   124 		exit(2);
   121 	}
   125 	}
   122 
   126 
   123 	/* Play and then exit */
   127 	/* Play and then exit */
   124 	Mix_PlayMusic(music,0);
   128 	Mix_FadeInMusic(music,0,2000);
   125 	while ( Mix_PlayingMusic() ) {
   129 	while ( Mix_PlayingMusic() ) {
   126 		SDL_Delay(100);
   130 		SDL_Delay(100);
   127 	}
   131 	}
   128 	exit(0);
   132 	exit(0);
   129 }
   133 }