Skip to content

Commit

Permalink
Fixed bug 1252 - Added Mix_LoadMUSType_RW() so you can tell SDL_mixer…
Browse files Browse the repository at this point in the history
… what type the music is

This involved a complete refactoring of the music loading so it's entirely rwops based and has improved music type detection code.
  • Loading branch information
slouken committed Jan 4, 2012
1 parent 19df5f0 commit 89c8c0a
Show file tree
Hide file tree
Showing 28 changed files with 257 additions and 498 deletions.
2 changes: 2 additions & 0 deletions CHANGES
@@ -1,6 +1,8 @@
1.2.12:
Sam Lantinga - Tue Jan 3 01:36:33 EST 2012
* The Mac OS X framework name changed to SDLmixer, to meet Apple's requirements
Nikos Chantziaras - 2012-01-02 17:37:36 PST
* Added Mix_LoadMUSType_RW() so you can tell SDL_mixer what type the music is
Sam Lantinga - Sat Dec 31 19:11:59 EST 2011
* Fixed dropping audio in the FLAC audio decoding
Sam Lantinga - Sat Dec 31 18:32:05 EST 2011
Expand Down
3 changes: 3 additions & 0 deletions SDL_mixer.h
Expand Up @@ -154,6 +154,9 @@ extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *rw);

/* Load a music file from an SDL_RWop object assuming a specific format */
extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *rw, Mix_MusicType type, int freesrc);

/* Load a wave file of the mixer format from a memory buffer */
extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);

Expand Down
2 changes: 1 addition & 1 deletion configure
Expand Up @@ -1995,7 +1995,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
MAJOR_VERSION=1
MINOR_VERSION=2
MICRO_VERSION=12
INTERFACE_AGE=2
INTERFACE_AGE=0
BINARY_AGE=12
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION

Expand Down
2 changes: 1 addition & 1 deletion configure.in
Expand Up @@ -15,7 +15,7 @@ dnl Set various version strings - taken gratefully from the GTk sources
MAJOR_VERSION=1
MINOR_VERSION=2
MICRO_VERSION=12
INTERFACE_AGE=2
INTERFACE_AGE=0
BINARY_AGE=12
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION

Expand Down
8 changes: 0 additions & 8 deletions dynamic_mp3.c
Expand Up @@ -65,13 +65,6 @@ int Mix_InitMP3()
SDL_UnloadObject(smpeg.handle);
return -1;
}
smpeg.SMPEG_new =
(SMPEG* (*)(const char *, SMPEG_Info*, int))
SDL_LoadFunction(smpeg.handle, "SMPEG_new");
if ( smpeg.SMPEG_new == NULL ) {
SDL_UnloadObject(smpeg.handle);
return -1;
}
smpeg.SMPEG_new_rwops =
(SMPEG* (*)(SDL_RWops *, SMPEG_Info*, int))
SDL_LoadFunction(smpeg.handle, "SMPEG_new_rwops");
Expand Down Expand Up @@ -151,7 +144,6 @@ int Mix_InitMP3()
smpeg.SMPEG_delete = SMPEG_delete;
smpeg.SMPEG_enableaudio = SMPEG_enableaudio;
smpeg.SMPEG_enablevideo = SMPEG_enablevideo;
smpeg.SMPEG_new = SMPEG_new;
smpeg.SMPEG_new_rwops = SMPEG_new_rwops;
smpeg.SMPEG_play = SMPEG_play;
smpeg.SMPEG_playAudio = SMPEG_playAudio;
Expand Down
1 change: 0 additions & 1 deletion dynamic_mp3.h
Expand Up @@ -29,7 +29,6 @@ typedef struct {
void (*SMPEG_delete)( SMPEG* mpeg );
void (*SMPEG_enableaudio)( SMPEG* mpeg, int enable );
void (*SMPEG_enablevideo)( SMPEG* mpeg, int enable );
SMPEG* (*SMPEG_new)(const char *file, SMPEG_Info* info, int sdl_audio);
SMPEG* (*SMPEG_new_rwops)(SDL_RWops *src, SMPEG_Info* info, int sdl_audio);
void (*SMPEG_play)( SMPEG* mpeg );
int (*SMPEG_playAudio)( SMPEG *mpeg, Uint8 *stream, int len );
Expand Down
21 changes: 2 additions & 19 deletions fluidsynth.c
Expand Up @@ -66,7 +66,7 @@ int fluidsynth_init(SDL_AudioSpec *mixer)
return 0;
}

FluidSynthMidiSong *fluidsynth_loadsong_common(int (*function)(FluidSynthMidiSong*, void*), void *data)
static FluidSynthMidiSong *fluidsynth_loadsong_common(int (*function)(FluidSynthMidiSong*, void*), void *data)
{
FluidSynthMidiSong *song;
fluid_settings_t *settings = NULL;
Expand Down Expand Up @@ -105,19 +105,7 @@ FluidSynthMidiSong *fluidsynth_loadsong_common(int (*function)(FluidSynthMidiSon
return NULL;
}

int fluidsynth_loadsong_internal(FluidSynthMidiSong *song, void *data)
{
const char* path = (const char*) data;

if (fluidsynth.fluid_player_add(song->player, path) == FLUID_OK) {
return 1;
} else {
Mix_SetError("FluidSynth failed to load %s", path);
return 0;
}
}

int fluidsynth_loadsong_RW_internal(FluidSynthMidiSong *song, void *data)
static int fluidsynth_loadsong_RW_internal(FluidSynthMidiSong *song, void *data)
{
off_t offset;
size_t size;
Expand Down Expand Up @@ -146,11 +134,6 @@ int fluidsynth_loadsong_RW_internal(FluidSynthMidiSong *song, void *data)
return 0;
}

FluidSynthMidiSong *fluidsynth_loadsong(const char *midifile)
{
return fluidsynth_loadsong_common(fluidsynth_loadsong_internal, (void*) midifile);
}

FluidSynthMidiSong *fluidsynth_loadsong_RW(SDL_RWops *rw, int freerw)
{
FluidSynthMidiSong *song;
Expand Down
1 change: 0 additions & 1 deletion fluidsynth.h
Expand Up @@ -38,7 +38,6 @@ typedef struct {
} FluidSynthMidiSong;

int fluidsynth_init(SDL_AudioSpec *mixer);
FluidSynthMidiSong *fluidsynth_loadsong(const char *midifile);
FluidSynthMidiSong *fluidsynth_loadsong_RW(SDL_RWops *rw, int freerw);
void fluidsynth_freesong(FluidSynthMidiSong *song);
void fluidsynth_start(FluidSynthMidiSong *song);
Expand Down

0 comments on commit 89c8c0a

Please sign in to comment.