Skip to content

Commit

Permalink
Fix music changes between areas
Browse files Browse the repository at this point in the history
  • Loading branch information
N00byKing committed Apr 10, 2022
1 parent b855310 commit c364e55
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions desktop_version/src/Music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ class MusicTrack
FAudioSourceVoice_FlushSourceBuffers(musicVoice);
FAudioVoice_DestroyVoice(musicVoice);
musicVoice = NULL;
paused = true;
}
}

Expand All @@ -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;
}
}

Expand Down Expand Up @@ -406,6 +414,7 @@ class MusicTrack
bool shouldloop;
bool valid;

static bool paused;
static FAudioSourceVoice* musicVoice;

static void refillReserve(FAudioVoiceCallback* callback, void* ctx)
Expand Down Expand Up @@ -560,7 +569,7 @@ class MusicTrack
return (result * 60 + val) * samplerate_hz;
}
};

bool MusicTrack::paused = false;
FAudioSourceVoice* MusicTrack::musicVoice = NULL;

musicclass::musicclass(void)
Expand Down Expand Up @@ -1130,7 +1139,7 @@ void musicclass::resumeef(void)

bool musicclass::halted(void)
{
return MusicTrack::IsHalted();
return MusicTrack::IsPaused();
}

void musicclass::updatemutestate(void)
Expand Down

0 comments on commit c364e55

Please sign in to comment.