Skip to content

Commit 570bc81

Browse files
committed
fix music stopping on pause and unpause, don't fade if not needed
1 parent 1c4d401 commit 570bc81

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Source/Managers/MusicMan.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,16 @@ void MusicMan::Update() {
5959
m_PreviousSoundContainer->FadeOut(musicFadeOutTimeMs);
6060
}
6161
}
62+
} else if (!m_ReturnToDynamicMusic) {
63+
if (m_CurrentSoundContainer && m_CurrentSoundContainer->GetAudibleVolume() == 0.0F) {
64+
g_ConsoleMan.PrintString("MusicMan: Inaudible CurrentSoundContainer is about to be deleted: " + m_PreviousSoundContainer->GetPresetName());
65+
m_CurrentSoundContainer = nullptr;
66+
}
6267
}
6368
if (m_PreviousSoundContainer && m_PreviousSoundContainer->GetAudibleVolume() == 0.0F) {
6469
g_ConsoleMan.PrintString("MusicMan: Inaudible PreviousSoundContainer is about to be deleted: " + m_PreviousSoundContainer->GetPresetName());
6570
m_PreviousSoundContainer = nullptr;
6671
}
67-
if (m_CurrentSoundContainer && m_CurrentSoundContainer->GetAudibleVolume() == 0.0F) {
68-
m_CurrentSoundContainer = nullptr;
69-
}
7072
}
7173

7274
bool MusicMan::IsMusicPlaying() const {
@@ -171,8 +173,8 @@ bool MusicMan::CyclePlayingSoundContainers(bool smoothFade) {
171173
if (m_CurrentSoundContainer && m_CurrentSoundContainer->IsBeingPlayed()) {
172174
if (smoothFade) {
173175
m_CurrentSoundContainer->FadeOut(static_cast<int>(m_NextSoundContainer->GetMusicPreEntryTime()));
174-
} else {
175-
g_ConsoleMan.PrintString("No smoothFade means upcoming PreviousSoundContainer will be faded out at entry point.");
176+
} else if (!m_MusicTimer.IsPastRealTimeLimit()) {
177+
g_ConsoleMan.PrintString("No smoothFade and premature cycling means upcoming PreviousSoundContainer will be faded out at entry point.");
176178
m_PreviousSoundContainerSetToFade = true;
177179
m_MusicFadeTimer.Reset();
178180
m_MusicFadeTimer.SetRealTimeLimitMS(static_cast<int>(m_NextSoundContainer->GetMusicPreEntryTime()));
@@ -251,6 +253,7 @@ void MusicMan::PlayInterruptingMusic(const SoundContainer* soundContainer) {
251253
}
252254

253255
void MusicMan::EndInterruptingMusic() {
256+
g_ConsoleMan.PrintString("MusicMan: Ending interrupting music.");
254257
if (m_InterruptingMusicSoundContainer && m_InterruptingMusicSoundContainer->IsBeingPlayed()) {
255258
m_InterruptingMusicSoundContainer->Stop();
256259

@@ -259,6 +262,7 @@ void MusicMan::EndInterruptingMusic() {
259262
}
260263

261264
if (m_CurrentSoundContainer != nullptr) {
265+
g_ConsoleMan.PrintString("Unpausing CurrentSoundContainer.");
262266
m_CurrentSoundContainer->SetPaused(false);
263267
}
264268

0 commit comments

Comments
 (0)