From c364e55a1a650ebd794edf272da30f8ed95e52d8 Mon Sep 17 00:00:00 2001 From: N00byKing Date: Sun, 10 Apr 2022 21:50:15 +0200 Subject: [PATCH] Fix music changes between areas --- desktop_version/src/Music.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 438454a02c..ac923841e5 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -357,6 +357,7 @@ class MusicTrack FAudioSourceVoice_FlushSourceBuffers(musicVoice); FAudioVoice_DestroyVoice(musicVoice); musicVoice = NULL; + paused = true; } } @@ -370,14 +371,21 @@ class MusicTrack if (!IsHalted()) { FAudioSourceVoice_Stop(musicVoice, 0, FAUDIO_COMMIT_NOW); + paused = true; } } + static bool IsPaused() + { + return paused || IsHalted(); + } + static void Resume() { if (!IsHalted()) { FAudioSourceVoice_Start(musicVoice, 0, FAUDIO_COMMIT_NOW); + paused = false; } } @@ -406,6 +414,7 @@ class MusicTrack bool shouldloop; bool valid; + static bool paused; static FAudioSourceVoice* musicVoice; static void refillReserve(FAudioVoiceCallback* callback, void* ctx) @@ -560,7 +569,7 @@ class MusicTrack return (result * 60 + val) * samplerate_hz; } }; - +bool MusicTrack::paused = false; FAudioSourceVoice* MusicTrack::musicVoice = NULL; musicclass::musicclass(void) @@ -1130,7 +1139,7 @@ void musicclass::resumeef(void) bool musicclass::halted(void) { - return MusicTrack::IsHalted(); + return MusicTrack::IsPaused(); } void musicclass::updatemutestate(void)