TINSEL: Fix DW2 deadlock in PCMMusicPlayer when loading scene

Preemptively acquire mixer lock to match locking order of audio thread.

Fixes #13953
This commit is contained in:
PushmePullyu 2023-11-28 02:14:09 +01:00 committed by Filippos Karapetis
parent b2cb32202e
commit 1738a2fac7

View File

@ -839,6 +839,11 @@ void PCMMusicPlayer::restoreThatTune(void *voidPtr) {
void PCMMusicPlayer::setMusicSceneDetails(SCNHANDLE hScript,
SCNHANDLE hSegment, const char *fileName) {
// A call to setVol(uint8) later in this method will lock the mixer.
// To match the locking order of the audio thread and prevent a deadlock,
// we preemptively lock it here first.
// See bug #13953
Common::StackLock mixerLock(_vm->_mixer->mutex());
Common::StackLock lock(_mutex);
stop();