From 1701b81079459d9f69285e7a558a6fb5cd5218ff Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 19 Aug 2018 22:49:53 -0400 Subject: [PATCH] * Allow S_ChangeMusic to queue the same track for fading * StopDigSong upon running queue so that GME works for queueing --- src/s_sound.c | 58 ++++++++++++++++++++----------------------- src/sdl/mixer_sound.c | 16 +++++++----- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 9e96480e1..12c322788 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1400,50 +1400,46 @@ void S_ChangeMusicWithFade(const char *mmusic, UINT16 mflags, boolean looping, U return; } - if (strncmp(music_name, newmusic, 6)) + if (S_MusicExists(newmusic, false, true) && !nodigimusic && !digital_disabled) // digmusic? { - if (S_MusicExists(newmusic, false, true) && !nodigimusic && !digital_disabled) // digmusic? + if (prefadems) //have to queue post-fade // allow even if the music is the same { - if (prefadems) //have to queue post-fade - { - I_FadeOutStopMusic(prefadems); - I_QueueDigSongPostFade(newmusic, mflags & MUSIC_TRACKMASK, looping, position, fadeinms); + I_FadeOutStopMusic(prefadems); + I_QueueDigSongPostFade(newmusic, mflags & MUSIC_TRACKMASK, looping, position, fadeinms); - // HACK: set the vars now and hope everything works out - strncpy(music_name, newmusic, 7); - music_name[6] = 0; - music_lumpnum = LUMPERROR; - music_data = NULL; - music_handle = 0; - return; - } - else - { - S_StopMusic(); - if (!S_DigMusic(newmusic, looping)) - { - CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), newmusic); - return; - } - } + // HACK: set the vars now and hope everything works out + strncpy(music_name, newmusic, 7); + music_name[6] = 0; + music_lumpnum = LUMPERROR; + music_data = NULL; + music_handle = 0; + return; } - else if (S_MusicExists(newmusic, true, false) && !nomidimusic && !music_disabled) // midimusic? + else if (strncmp(music_name, newmusic, 6)) { - // HACK: We don't support fade for MIDI right now, so - // just fall to old behavior verbatim. This technically should be implemented in - // the interfaces, even as a stub. - S_StopMusic(); - - if (!S_MIDIMusic(newmusic, looping)) + if (!S_DigMusic(newmusic, looping)) { CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), newmusic); return; } + I_SetSongTrack(mflags & MUSIC_TRACKMASK); } } + else if (strncmp(music_name, newmusic, 6) && S_MusicExists(newmusic, true, false) && !nomidimusic && !music_disabled) // midimusic? + { + // HACK: We don't support fade for MIDI right now, so + // just fall to old behavior verbatim. This technically should be implemented in + // the interfaces, even as a stub. - I_SetSongTrack(mflags & MUSIC_TRACKMASK); + S_StopMusic(); + + if (!S_MIDIMusic(newmusic, looping)) + { + CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), newmusic); + return; + } + } } musictype_t S_MusicType() diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 71421ea62..13c29bc1b 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -527,13 +527,17 @@ static void run_queue() { if (queue_stopafterfade) I_StopDigSong(); - else if (queue_music_name[0] && I_StartDigSong(queue_music_name, queue_looping)) + else if (queue_music_name[0]) { - I_SetSongTrack(queue_track); - if (queue_fadeinms) - I_FadeMusicFromLevel(100, 0, queue_fadeinms, false); - if (queue_position) - I_SetMusicPosition(queue_position); + I_StopDigSong(); + if (I_StartDigSong(queue_music_name, queue_looping)) + { + I_SetSongTrack(queue_track); + if (queue_fadeinms) + I_FadeMusicFromLevel(100, 0, queue_fadeinms, false); + if (queue_position) + I_SetMusicPosition(queue_position); + } } queuecleanup(); }