From 5966391108eff3d8f2d205ea62b62535fac9b140 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 9 Dec 2019 16:06:41 +0200 Subject: [PATCH] - moved sound engine cleanup calls to own function https://forum.zdoom.org/viewtopic.php?t=66605#p1127457 --- src/sound/s_advsound.cpp | 7 +------ src/sound/s_sound.cpp | 14 ++++++++++++++ src/sound/s_soundinternal.h | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/sound/s_advsound.cpp b/src/sound/s_advsound.cpp index d3c79c54c7..d2f7ba0f55 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -742,12 +742,7 @@ void FPlayerSoundHashTable::MarkUsed() void S_ClearSoundData() { if (soundEngine) - { - soundEngine->StopAllChannels(); - soundEngine->UnloadAllSounds(); - soundEngine->GetSounds().Clear(); - soundEngine->ClearRandoms(); - } + soundEngine->Clear(); Ambients.Clear(); while (MusicVolumes != NULL) diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index 4fba205dc5..45524533b2 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -68,6 +68,20 @@ void SoundEngine::Init(TArray &curve) S_SoundCurve = std::move(curve); } +//========================================================================== +// +// SoundEngine::Clear +// +//========================================================================== + +void SoundEngine::Clear() +{ + StopAllChannels(); + UnloadAllSounds(); + GetSounds().Clear(); + ClearRandoms(); +} + //========================================================================== // // S_Shutdown diff --git a/src/sound/s_soundinternal.h b/src/sound/s_soundinternal.h index 17cf55e5b3..b05c1cdd45 100644 --- a/src/sound/s_soundinternal.h +++ b/src/sound/s_soundinternal.h @@ -277,6 +277,7 @@ public: // void Init(TArray &sndcurve); void InitData(); + void Clear(); void Shutdown(); void StopAllChannels(void);