- fixed: ZMusic_Close may not lock the mutex because it will delete it.

Here the calling code must ensure that the music object won't be accessible anymore before it gets deleted.
This commit is contained in:
Christoph Oelckers 2019-10-15 01:16:02 +02:00
parent 6854a509e9
commit 4d8f0fc014
2 changed files with 4 additions and 3 deletions

View file

@ -401,7 +401,6 @@ SoundStreamInfo ZMusic_GetStreamInfo(MusInfo *song)
void ZMusic_Close(MusInfo *song)
{
if (!song) return;
std::lock_guard<std::mutex> lock(song->CritSec);
delete song;
}

View file

@ -626,8 +626,9 @@ void S_StopMusic (bool force)
S_ResumeMusic();
S_StopStream();
ZMusic_Stop(mus_playing.handle);
ZMusic_Close(mus_playing.handle);
auto h = mus_playing.handle;
mus_playing.handle = nullptr;
ZMusic_Close(h);
}
mus_playing.LastSong = std::move(mus_playing.name);
}
@ -637,8 +638,9 @@ void S_StopMusic (bool force)
//Printf("Unable to stop %s: %s\n", mus_playing.name.GetChars(), err.what());
if (mus_playing.handle != nullptr)
{
ZMusic_Close(mus_playing.handle);
auto h = mus_playing.handle;
mus_playing.handle = nullptr;
ZMusic_Close(h);
}
mus_playing.name = "";
}