1.2.6:
authorSam Lantinga <slouken@libsdl.org>
Sat, 28 Jun 2003 17:31:24 +0000
changeset 2263691a375f2e6
parent 225 0ce0217441fc
child 227 61b8509257c3
1.2.6:
Andre Leiradella - Fri, 30 May 2003 16:12:03 -0300
* Added SDL_RWops support for reading MOD files
CHANGES
SDL_mixer.h
music.c
     1.1 --- a/CHANGES	Sat May 03 20:15:25 2003 +0000
     1.2 +++ b/CHANGES	Sat Jun 28 17:31:24 2003 +0000
     1.3 @@ -1,4 +1,6 @@
     1.4  1.2.6:
     1.5 +Andre Leiradella - Fri, 30 May 2003 16:12:03 -0300
     1.6 + * Added SDL_RWops support for reading MOD files
     1.7  Kyle Davenport - Sat, 19 Apr 2003 17:13:31 -0500
     1.8   * Added .la files to the development RPM, fixing RPM build on RedHat 8
     1.9  
     2.1 --- a/SDL_mixer.h	Sat May 03 20:15:25 2003 +0000
     2.2 +++ b/SDL_mixer.h	Sat Jun 28 17:31:24 2003 +0000
     2.3 @@ -125,10 +125,10 @@
     2.4  #define Mix_LoadWAV(file)	Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
     2.5  extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
     2.6  
     2.7 -#if 0 /* This hasn't been hooked into music.c yet */
     2.8 +#ifdef USE_RWOPS /* This hasn't been hooked into music.c yet */
     2.9  /* Load a music file from an SDL_RWop object (MikMod-specific currently)
    2.10     Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
    2.11 -extern no_parse_DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *rw);
    2.12 +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *rw);
    2.13  #endif
    2.14  
    2.15  /* Load a wave file of the mixer format from a memory buffer */
     3.1 --- a/music.c	Sat May 03 20:15:25 2003 +0000
     3.2 +++ b/music.c	Sat Jun 28 17:31:24 2003 +0000
     3.3 @@ -48,6 +48,9 @@
     3.4  #    define UNIMOD			MODULE
     3.5  #    define MikMod_Init()		MikMod_Init(NULL)
     3.6  #    define MikMod_LoadSong(a,b)	Player_Load(a,b,0)
     3.7 +#    ifdef USE_RWOPS
     3.8 +#      define MikMod_LoadSongRW(a,b)	Player_LoadRW(a,b,0)
     3.9 +#    endif
    3.10  #    define MikMod_FreeSong		Player_Free
    3.11       extern int MikMod_errno;
    3.12  #  else                                        /* old MikMod 3.0.3 */
    3.13 @@ -1115,3 +1118,50 @@
    3.14  #endif
    3.15  }
    3.16  
    3.17 +#ifdef USE_RWOPS
    3.18 +
    3.19 +Mix_Music *Mix_LoadMUS_RW(SDL_RWops *rw) {
    3.20 +	/*Uint8     magic[5]; Apparently there is no way to check if the file is really a MOD,*/
    3.21 +      /*		    or there are too many formats supported by MikMod or MikMod does */
    3.22 +      /*		    this check by itself. If someone implements other formats (e.g. MP3) */
    3.23 +      /*		    the check can be uncommented */
    3.24 +	Mix_Music *music;
    3.25 +
    3.26 +      /* Just skip the check */
    3.27 +	/* Figure out what kind of file this is */
    3.28 +	/*if (SDL_RWread(rw,magic,1,4)!=4) {
    3.29 +		Mix_SetError("Couldn't read from RWops");
    3.30 +		return NULL;
    3.31 +	}
    3.32 +	magic[4]='\0';*/
    3.33 +
    3.34 +	/* Allocate memory for the music structure */
    3.35 +	music=(Mix_Music *)malloc(sizeof(Mix_Music));
    3.36 +	if (music==NULL ) {
    3.37 +		Mix_SetError("Out of memory");
    3.38 +		return(NULL);
    3.39 +	}
    3.40 +	music->error = 0;
    3.41 +
    3.42 +#ifdef MOD_MUSIC
    3.43 +	if (1) {
    3.44 +		music->type=MUS_MOD;
    3.45 +		music->data.module=MikMod_LoadSongRW(rw,64);
    3.46 +		if (music->data.module==NULL) {
    3.47 +			Mix_SetError("%s",MikMod_strerror(MikMod_errno));
    3.48 +			music->error=1;
    3.49 +		}
    3.50 +	} else
    3.51 +#endif
    3.52 +	{
    3.53 +		Mix_SetError("Unrecognized music format");
    3.54 +		music->error=1;
    3.55 +	}
    3.56 +	if (music->error) {
    3.57 +		free(music);
    3.58 +		music=NULL;
    3.59 +	}
    3.60 +	return(music);
    3.61 +}
    3.62 +
    3.63 +#endif /* USE_RWOPS */