Skip to content

Commit

Permalink
Sam Lantinga - Sat Nov 14 12:38:01 PST 2009
Browse files Browse the repository at this point in the history
 * Fixed initialization error and crashes if MikMod library isn't available
  • Loading branch information
slouken committed Nov 14, 2009
1 parent 75988b2 commit 29ed527
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CHANGES
@@ -1,6 +1,6 @@
1.2.11:
Sam Lantinga - Sat Nov 14 12:38:01 PST 2009
* Fixed crash on exit if the MikMod library isn't available
* Fixed initialization error and crashes if MikMod library isn't available
Sam Lantinga - Sat Nov 14 11:22:14 PST 2009
* Fixed bug loading multiple music files

Expand Down
21 changes: 4 additions & 17 deletions music.c
Expand Up @@ -304,19 +304,13 @@ void music_mixer(void *udata, Uint8 *stream, int len)
/* Initialize the music players with a certain desired audio format */
int open_music(SDL_AudioSpec *mixer)
{
int music_error = 0;

#ifdef WAV_MUSIC
if ( WAVStream_Init(mixer) < 0 ) {
++music_error;
} else {
if ( WAVStream_Init(mixer) == 0 ) {
add_music_decoder("WAVE");
}
#endif
#ifdef MOD_MUSIC
if ( MOD_init(mixer) < 0 ) {
++music_error;
} else {
if ( MOD_init(mixer) == 0 ) {
add_music_decoder("MIKMOD");
}
#endif
Expand Down Expand Up @@ -345,16 +339,12 @@ int open_music(SDL_AudioSpec *mixer)
#endif
#endif
#ifdef OGG_MUSIC
if ( OGG_init(mixer) < 0 ) {
++music_error;
} else {
if ( OGG_init(mixer) == 0 ) {
add_music_decoder("OGG");
}
#endif
#ifdef FLAC_MUSIC
if ( FLAC_init(mixer) < 0 ) {
++music_error;
} else {
if ( FLAC_init(mixer) == 0 ) {
add_music_decoder("FLAC");
}
#endif
Expand All @@ -366,9 +356,6 @@ int open_music(SDL_AudioSpec *mixer)

music_playing = NULL;
music_stopped = 0;
if ( music_error ) {
return(-1);
}
Mix_VolumeMusic(SDL_MIX_MAXVOLUME);

/* Calculate the number of ms for each callback */
Expand Down
5 changes: 5 additions & 0 deletions music_mod.c
Expand Up @@ -220,6 +220,11 @@ MODULE *MOD_new_RW(SDL_RWops *rw)
{
MODULE *module;

/* Make sure the mikmod library is loaded */
if ( !Mix_Init(MIX_INIT_MOD) ) {
return NULL;
}

module = MikMod_LoadSongRW(rw,64);
if (!module) {
Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno));
Expand Down

0 comments on commit 29ed527

Please sign in to comment.