From be21072b58027794059067acabbeefee065a27f4 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 1 Sep 2018 11:33:39 -0400 Subject: [PATCH 1/3] 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; } } } From 1aa4035594b4ab02ed84b0f40bf2cb18e29cb611 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 1 Sep 2018 11:35:54 -0400 Subject: [PATCH 2/3] Revert "Fix MIDI music not reloading sometimes on settings change" This reverts commit be21072b58027794059067acabbeefee065a27f4. --- src/sdl/mixer_sound.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index f3532a2b5..133a8ff84 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -99,13 +99,7 @@ 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) @@ -118,15 +112,9 @@ 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; } } } From abb67d35e3672a6281881dde543f654934afeaa0 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sat, 1 Sep 2018 11:37:53 -0400 Subject: [PATCH 3/3] Reset MIDI music properly on settings change * Added reset flag to S_Start (now S_StartEx) --- src/s_sound.c | 4 ++-- src/s_sound.h | 3 ++- src/sdl/mixer_sound.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 7bfd0e62d..1e8839e29 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1608,7 +1608,7 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) // Kills playing sounds at start of level, // determines music if any, changes music. // -void S_Start(void) +void S_StartEx(boolean reset) { if (mapmusflags & MUSIC_RELOADRESET) { @@ -1617,7 +1617,7 @@ void S_Start(void) mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); } - if (cv_resetmusic.value) + if (cv_resetmusic.value || reset) S_StopMusic(); S_ChangeMusic(mapmusname, mapmusflags, true); } diff --git a/src/s_sound.h b/src/s_sound.h index 94bb27f93..01b95e307 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -114,7 +114,8 @@ void S_InitSfxChannels(INT32 sfxVolume); // void S_StopSounds(void); void S_ClearSfx(void); -void S_Start(void); +void S_StartEx(boolean reset); +#define S_Start() S_StartEx(false) // // Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum. diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 133a8ff84..73778e5ac 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -99,7 +99,7 @@ static void Midiplayer_Onchange(void) Mix_Timidity_addToPathList(cv_miditimiditypath.string); if (restart) - S_Start(); + S_StartEx(true); } static void MidiSoundfontPath_Onchange(void) @@ -114,7 +114,7 @@ static void MidiSoundfontPath_Onchange(void) if (rw != NULL) { SDL_RWclose(rw); Mix_SetSoundFonts(cv_midisoundfontpath.string); - S_Start(); + S_StartEx(true); } } }