From aa48278fd46810c0d80cc2f81ac7362c6ebae788 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 1 Sep 2018 11:33:39 -0400 Subject: [PATCH] Fix MIDI music not reloading sometimes on settings change --- src/sdl/mixer_sound.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 133a8ff84..f3532a2b5 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -99,7 +99,13 @@ static void Midiplayer_Onchange(void) Mix_Timidity_addToPathList(cv_miditimiditypath.string); if (restart) + { + // HACK: Need to set cv_resetmusic to reload MIDI music + INT32 resetmusicval = cv_resetmusic.value; + cv_resetmusic.value = 1; S_Start(); + cv_resetmusic.value = resetmusicval; + } } static void MidiSoundfontPath_Onchange(void) @@ -112,9 +118,15 @@ static void MidiSoundfontPath_Onchange(void) // check if file exists; menu calls this method at every keystroke SDL_RWops *rw = SDL_RWFromFile(cv_midisoundfontpath.string, "r"); if (rw != NULL) { + INT32 resetmusicval = cv_resetmusic.value; + SDL_RWclose(rw); Mix_SetSoundFonts(cv_midisoundfontpath.string); + + // HACK: Need to set cv_resetmusic to reload MIDI music + cv_resetmusic.value = 1; S_Start(); + cv_resetmusic.value = resetmusicval; } } }