playmus.c
changeset 625 1d489d8ec2e0
parent 617 87116a42526e
child 642 dae7bb0a66b1
equal deleted inserted replaced
624:449c261f8480 625:1d489d8ec2e0
   103 
   103 
   104 #endif
   104 #endif
   105 
   105 
   106 int main(int argc, char *argv[])
   106 int main(int argc, char *argv[])
   107 {
   107 {
   108     SDL_RWops *rwfp = NULL;
       
   109     int audio_rate;
   108     int audio_rate;
   110     Uint16 audio_format;
   109     Uint16 audio_format;
   111     int audio_channels;
   110     int audio_channels;
   112     int audio_buffers;
   111     int audio_buffers;
   113     int audio_volume = MIX_MAX_VOLUME;
   112     int audio_volume = MIX_MAX_VOLUME;
   198     while (argv[i]) {
   197     while (argv[i]) {
   199         next_track = 0;
   198         next_track = 0;
   200 
   199 
   201         /* Load the requested music file */
   200         /* Load the requested music file */
   202         if ( rwops ) {
   201         if ( rwops ) {
   203             rwfp = SDL_RWFromFile(argv[i], "rb");
   202             music = Mix_LoadMUS_RW(SDL_RWFromFile(argv[i], "rb"), SDL_TRUE);
   204             music = Mix_LoadMUS_RW(rwfp);
       
   205         } else {
   203         } else {
   206             music = Mix_LoadMUS(argv[i]);
   204             music = Mix_LoadMUS(argv[i]);
   207         }
   205         }
   208         if ( music == NULL ) {
   206         if ( music == NULL ) {
   209             fprintf(stderr, "Couldn't load %s: %s\n",
   207             fprintf(stderr, "Couldn't load %s: %s\n",
   219                 Menu();
   217                 Menu();
   220             else
   218             else
   221                 SDL_Delay(100);
   219                 SDL_Delay(100);
   222         }
   220         }
   223         Mix_FreeMusic(music);
   221         Mix_FreeMusic(music);
   224         if ( rwops ) {
       
   225             SDL_RWclose(rwfp);
       
   226         }
       
   227         music = NULL;
   222         music = NULL;
   228 
   223 
   229         /* If the user presses Ctrl-C more than once, exit. */
   224         /* If the user presses Ctrl-C more than once, exit. */
   230         SDL_Delay(500);
   225         SDL_Delay(500);
   231         if ( next_track > 1 ) break;
   226         if ( next_track > 1 ) break;