SCI/new music: Resolved another possible deadlock when pausing all sounds

svn-id: r46971
This commit is contained in:
Filippos Karapetis 2010-01-04 14:43:14 +00:00
parent 60ece55fb9
commit d437b25c57

View File

@ -529,20 +529,24 @@ void SoundCommandParser::cmdPauseSound(reg_t obj, int16 value) {
changeSoundStatus(obj, value ? SOUND_STATUS_SUSPENDED : SOUND_STATUS_PLAYING); changeSoundStatus(obj, value ? SOUND_STATUS_SUSPENDED : SOUND_STATUS_PLAYING);
#else #else
Common::StackLock lock(_music->_mutex);
MusicEntry *musicSlot = NULL; MusicEntry *musicSlot = NULL;
MusicList::iterator slotLoop = NULL; MusicList::iterator slotLoop = NULL;
MusicList::iterator listEnd = NULL;
if (!obj.segment) { if (!obj.segment) {
// Pausing/Resuming the whole playlist was introduced // Pausing/Resuming the whole playlist was introduced
// in the SCI1 late sound scheme // in the SCI1 late sound scheme
if (_soundVersion <= SCI_VERSION_1_EARLY) if (_soundVersion <= SCI_VERSION_1_EARLY)
return; return;
_music->_mutex.lock();
slotLoop = _music->getPlayListStart(); slotLoop = _music->getPlayListStart();
listEnd = _music->getPlayListEnd();
musicSlot = *slotLoop; musicSlot = *slotLoop;
_music->_mutex.unlock();
} else { } else {
_music->_mutex.lock();
musicSlot = _music->getSlot(obj); musicSlot = _music->getSlot(obj);
_music->_mutex.unlock();
if (!musicSlot) { if (!musicSlot) {
warning("cmdPauseSound: Slot not found (%04x:%04x)", PRINT_REG(obj)); warning("cmdPauseSound: Slot not found (%04x:%04x)", PRINT_REG(obj));
return; return;
@ -561,10 +565,13 @@ void SoundCommandParser::cmdPauseSound(reg_t obj, int16 value) {
} }
if (slotLoop) { if (slotLoop) {
if (slotLoop == _music->getPlayListEnd()) if (slotLoop == listEnd) {
break; break;
else } else {
_music->_mutex.lock();
musicSlot = *(slotLoop++); musicSlot = *(slotLoop++);
_music->_mutex.unlock();
}
} }
} while (slotLoop); } while (slotLoop);