Browse Source

Release lock before finalizing sound samples (#8468)

pull/8469/head
Stephen C. Wills 1 month ago committed by GitHub
parent
commit
1b07a9d34c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      Source/engine/sound.cpp

11
Source/engine/sound.cpp

@ -193,8 +193,15 @@ const auto OptionChangeDevice = (GetOptions().Audio.device.SetValueChangedCallba
void ClearDuplicateSounds()
{
const std::lock_guard<SdlMutex> lock(*duplicateSoundsMutex);
duplicateSounds.clear();
// Move sound samples to a temporary list,
// avoiding a deadlock that involves SDL's
// mixer lock being taken by finalizers
std::list<std::unique_ptr<SoundSample>> drain;
{
const std::lock_guard<SdlMutex> lock(*duplicateSoundsMutex);
drain = std::move(duplicateSounds);
duplicateSounds.clear();
}
}
void snd_play_snd(TSnd *pSnd, int lVolume, int lPan, int userVolume)

Loading…
Cancel
Save