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. 7
      Source/engine/sound.cpp

7
Source/engine/sound.cpp

@ -192,10 +192,17 @@ const auto OptionChangeDevice = (GetOptions().Audio.device.SetValueChangedCallba
} // namespace } // namespace
void ClearDuplicateSounds() void ClearDuplicateSounds()
{
// 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); const std::lock_guard<SdlMutex> lock(*duplicateSoundsMutex);
drain = std::move(duplicateSounds);
duplicateSounds.clear(); duplicateSounds.clear();
} }
}
void snd_play_snd(TSnd *pSnd, int lVolume, int lPan, int userVolume) void snd_play_snd(TSnd *pSnd, int lVolume, int lPan, int userVolume)
{ {

Loading…
Cancel
Save