1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fix possible crashes on audio shutdown

This commit is contained in:
Ivan Savenko
2025-03-12 13:32:46 +00:00
parent 4684756c49
commit 6855b895a0
3 changed files with 5 additions and 4 deletions

View File

@@ -37,7 +37,8 @@ CAudioBase::~CAudioBase()
--initializationCounter;
if(initializationCounter == 0 && initializeSuccess)
{
Mix_CloseAudio();
initializeSuccess = false;
}
}

View File

@@ -232,8 +232,7 @@ MusicEntry::~MusicEntry()
if(loop == 0 && Mix_FadingMusic() != MIX_NO_FADING)
{
assert(0);
logGlobal->error("Attempt to delete music while fading out!");
logGlobal->trace("Halting playback of music file %s", currentName.getOriginalName());
Mix_HaltMusic();
}

View File

@@ -56,6 +56,7 @@ CSoundHandler::~CSoundHandler()
{
if(isInitialized())
{
Mix_ChannelFinished(nullptr);
Mix_HaltChannel(-1);
for(auto & chunk : soundChunks)