1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Added checks to music player to detect potential freezes

This commit is contained in:
Ivan Savenko
2022-12-31 17:55:22 +02:00
parent 7e8516f927
commit 8526eba6fa

View File

@@ -542,6 +542,20 @@ MusicEntry::MusicEntry(CMusicHandler *owner, std::string setName, std::string mu
}
MusicEntry::~MusicEntry()
{
if (playing)
{
assert(0);
logGlobal->error("Attempt to delete music while playing!");
Mix_HaltMusic();
}
if (loop == 0 && Mix_FadingMusic() != MIX_NO_FADING)
{
assert(0);
logGlobal->error("Attempt to delete music while fading out!");
Mix_HaltMusic();
}
logGlobal->trace("Del-ing music file %s", currentName);
if (music)
Mix_FreeMusic(music);
@@ -619,7 +633,7 @@ bool MusicEntry::play()
bool MusicEntry::stop(int fade_ms)
{
if (playing)
if (Mix_PlayingMusic())
{
playing = false;
loop = 0;