From a76cdd094621869db0c1293fe333ddfd152268ee Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 30 Sep 2019 19:41:03 +0200 Subject: [PATCH] - fixed crash with non-looping music ending. In this case it was the song terminating the stream, with the new setup the main music code has to do this itself. --- libraries/zmusic/musicformats/music_midi.cpp | 1 + src/sound/s_music.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libraries/zmusic/musicformats/music_midi.cpp b/libraries/zmusic/musicformats/music_midi.cpp index 36d0754af..d01ff7ac9 100644 --- a/libraries/zmusic/musicformats/music_midi.cpp +++ b/libraries/zmusic/musicformats/music_midi.cpp @@ -979,6 +979,7 @@ bool MIDIStreamer::SetSubsong(int subsong) bool MIDIStreamer::ServiceStream(void* buff, int len) { + if (!MIDI) return false; return static_cast(MIDI.get())->ServiceStream(buff, len); } diff --git a/src/sound/s_music.cpp b/src/sound/s_music.cpp index 76d287ad7..2aec2c853 100644 --- a/src/sound/s_music.cpp +++ b/src/sound/s_music.cpp @@ -277,10 +277,17 @@ void S_UpdateMusic () // [RH] Update music and/or playlist. IsPlaying() must be called // to attempt to reconnect to broken net streams and to advance the // playlist when the current song finishes. - if (!mus_playing.handle->IsPlaying() && PlayList) + if (!mus_playing.handle->IsPlaying()) { - PlayList->Advance(); - S_ActivatePlayList(false); + if (PlayList) + { + PlayList->Advance(); + S_ActivatePlayList(false); + } + else + { + S_StopMusic(true); + } } } }