mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 06:42:12 +00:00
- 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:
parent
6854a509e9
commit
4d8f0fc014
2 changed files with 4 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = "";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue