Skip to content
Permalink
Browse files

1.2.6:

Andre Leiradella - Fri, 30 May 2003 16:12:03 -0300
 * Added SDL_RWops support for reading MOD files
  • Loading branch information
slouken committed Jun 28, 2003
1 parent d2fe293 commit cd5cec96bf1f775060f99ecb95eacc856ddc5b4f
Showing with 54 additions and 2 deletions.
  1. +2 −0 CHANGES
  2. +2 −2 SDL_mixer.h
  3. +50 −0 music.c
@@ -1,4 +1,6 @@
1.2.6:
Andre Leiradella - Fri, 30 May 2003 16:12:03 -0300
* Added SDL_RWops support for reading MOD files
Kyle Davenport - Sat, 19 Apr 2003 17:13:31 -0500
* Added .la files to the development RPM, fixing RPM build on RedHat 8

@@ -125,10 +125,10 @@ extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
#define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);

#if 0 /* This hasn't been hooked into music.c yet */
#ifdef USE_RWOPS /* This hasn't been hooked into music.c yet */
/* Load a music file from an SDL_RWop object (MikMod-specific currently)
Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
extern no_parse_DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *rw);
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *rw);
#endif

/* Load a wave file of the mixer format from a memory buffer */
50 music.c
@@ -48,6 +48,9 @@
# define UNIMOD MODULE
# define MikMod_Init() MikMod_Init(NULL)
# define MikMod_LoadSong(a,b) Player_Load(a,b,0)
# ifdef USE_RWOPS
# define MikMod_LoadSongRW(a,b) Player_LoadRW(a,b,0)
# endif
# define MikMod_FreeSong Player_Free
extern int MikMod_errno;
# else /* old MikMod 3.0.3 */
@@ -1115,3 +1118,50 @@ void close_music(void)
#endif
}

#ifdef USE_RWOPS

Mix_Music *Mix_LoadMUS_RW(SDL_RWops *rw) {
/*Uint8 magic[5]; Apparently there is no way to check if the file is really a MOD,*/
/* or there are too many formats supported by MikMod or MikMod does */
/* this check by itself. If someone implements other formats (e.g. MP3) */
/* the check can be uncommented */
Mix_Music *music;

/* Just skip the check */
/* Figure out what kind of file this is */
/*if (SDL_RWread(rw,magic,1,4)!=4) {
Mix_SetError("Couldn't read from RWops");
return NULL;
}
magic[4]='\0';*/

/* Allocate memory for the music structure */
music=(Mix_Music *)malloc(sizeof(Mix_Music));
if (music==NULL ) {
Mix_SetError("Out of memory");
return(NULL);
}
music->error = 0;

#ifdef MOD_MUSIC
if (1) {
music->type=MUS_MOD;
music->data.module=MikMod_LoadSongRW(rw,64);
if (music->data.module==NULL) {
Mix_SetError("%s",MikMod_strerror(MikMod_errno));
music->error=1;
}
} else
#endif
{
Mix_SetError("Unrecognized music format");
music->error=1;
}
if (music->error) {
free(music);
music=NULL;
}
return(music);
}

#endif /* USE_RWOPS */

0 comments on commit cd5cec9

Please sign in to comment.