music.c
changeset 521 565549e046b0
parent 518 8bc9b5fd2aae
child 527 1eddea51f162
     1.1 --- a/music.c	Sat Dec 31 14:23:44 2011 -0500
     1.2 +++ b/music.c	Sat Dec 31 18:32:49 2011 -0500
     1.3 @@ -1391,6 +1391,7 @@
     1.4  	Uint8 moremagic[9];
     1.5  	Mix_Music *music;
     1.6  	int start;
     1.7 +	int freerw = 0;
     1.8  
     1.9  	if (!rw) {
    1.10  		Mix_SetError("RWops pointer is NULL");
    1.11 @@ -1423,7 +1424,7 @@
    1.12  	if ( ((strcmp((char *)magic, "RIFF") == 0) && (strcmp((char *)(moremagic+4), "WAVE") == 0)) ||
    1.13  	     (strcmp((char *)magic, "FORM") == 0) ) {
    1.14  		music->type = MUS_WAV;
    1.15 -		music->data.wave = WAVStream_LoadSong_RW(rw, (char *)magic);
    1.16 +		music->data.wave = WAVStream_LoadSong_RW(rw, (char *)magic, freerw);
    1.17  		if ( music->data.wave == NULL ) {
    1.18  			music->error = 1;
    1.19  		}
    1.20 @@ -1434,7 +1435,7 @@
    1.21  	/* Ogg Vorbis files have the magic four bytes "OggS" */
    1.22  	if ( strcmp((char *)magic, "OggS") == 0 ) {
    1.23  		music->type = MUS_OGG;
    1.24 -		music->data.ogg = OGG_new_RW(rw);
    1.25 +		music->data.ogg = OGG_new_RW(rw, freerw);
    1.26  		if ( music->data.ogg == NULL ) {
    1.27  			music->error = 1;
    1.28  		}
    1.29 @@ -1444,7 +1445,7 @@
    1.30  	/* FLAC files have the magic four bytes "fLaC" */
    1.31  	if ( strcmp((char *)magic, "fLaC") == 0 ) {
    1.32  		music->type = MUS_FLAC;
    1.33 -		music->data.flac = FLAC_new_RW(rw);
    1.34 +		music->data.flac = FLAC_new_RW(rw, freerw);
    1.35  		if ( music->data.flac == NULL ) {
    1.36  			music->error = 1;
    1.37  		}
    1.38 @@ -1470,7 +1471,7 @@
    1.39  #ifdef MP3_MAD_MUSIC
    1.40  	if ( ( magic[0] == 0xFF && (magic[1] & 0xF0) == 0xF0) || ( strncmp((char *)magic, "ID3", 3) == 0 ) ) {
    1.41  		music->type = MUS_MP3_MAD;
    1.42 -		music->data.mp3_mad = mad_openFileRW(rw, &used_mixer);
    1.43 +		music->data.mp3_mad = mad_openFileRW(rw, &used_mixer, freerw);
    1.44  		if (music->data.mp3_mad == 0) {
    1.45  			Mix_SetError("Could not initialize MPEG stream.");
    1.46  			music->error = 1;
    1.47 @@ -1483,7 +1484,7 @@
    1.48  		music->type = MUS_MID;
    1.49  #ifdef USE_NATIVE_MIDI
    1.50  		if ( native_midi_ok ) {
    1.51 -			music->data.nativemidi = native_midi_loadsong_RW(rw);
    1.52 +			music->data.nativemidi = native_midi_loadsong_RW(rw, freerw);
    1.53  	  		if ( music->data.nativemidi == NULL ) {
    1.54  		  		Mix_SetError("%s", native_midi_error());
    1.55  			  	music->error = 1;
    1.56 @@ -1493,7 +1494,7 @@
    1.57  #endif
    1.58  #ifdef USE_FLUIDSYNTH_MIDI
    1.59  		if ( fluidsynth_ok ) {
    1.60 -			music->data.fluidsynthmidi = fluidsynth_loadsong_RW(rw);
    1.61 +			music->data.fluidsynthmidi = fluidsynth_loadsong_RW(rw, freerw);
    1.62  			if ( music->data.fluidsynthmidi == NULL ) {
    1.63  				music->error = 1;
    1.64  			}
    1.65 @@ -1502,7 +1503,7 @@
    1.66  #endif
    1.67  #ifdef USE_TIMIDITY_MIDI
    1.68  		if ( timidity_ok ) {
    1.69 -			music->data.midi = Timidity_LoadSong_RW(rw);
    1.70 +			music->data.midi = Timidity_LoadSong_RW(rw, freerw);
    1.71  			if ( music->data.midi == NULL ) {
    1.72  				Mix_SetError("%s", Timidity_Error());
    1.73  				music->error = 1;
    1.74 @@ -1520,7 +1521,7 @@
    1.75  #ifdef MODPLUG_MUSIC
    1.76  		if ( music->error ) {
    1.77  			music->type = MUS_MODPLUG;
    1.78 -			music->data.modplug = modplug_new_RW(rw);
    1.79 +			music->data.modplug = modplug_new_RW(rw, freerw);
    1.80  			if ( music->data.modplug ) {
    1.81  				music->error = 0;
    1.82  			}
    1.83 @@ -1529,7 +1530,7 @@
    1.84  #ifdef MOD_MUSIC
    1.85  		if ( music->error ) {
    1.86  			music->type = MUS_MOD;
    1.87 -			music->data.module = MOD_new_RW(rw);
    1.88 +			music->data.module = MOD_new_RW(rw, freerw);
    1.89  			if ( music->data.module ) {
    1.90  				music->error = 0;
    1.91  			}