diff options
author | Filippos Karapetis | 2010-01-29 17:45:30 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-01-29 17:45:30 +0000 |
commit | be293572d2ba066574ce16449e783c60c386943b (patch) | |
tree | 9da22cfe3249073f8152c46b3e259a0ba5b8de48 /engines/sci | |
parent | 266ff9934d223439a53175b4acb1f4acbb11a747 (diff) | |
download | scummvm-rg350-be293572d2ba066574ce16449e783c60c386943b.tar.gz scummvm-rg350-be293572d2ba066574ce16449e783c60c386943b.tar.bz2 scummvm-rg350-be293572d2ba066574ce16449e783c60c386943b.zip |
Don't modify the objects of sound slots that are already stopped, as the associated objects could have been disposed. Fixes odd crashes in SQ3
svn-id: r47675
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/sound/soundcmd.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp index 5b30734045..96d839c672 100644 --- a/engines/sci/sound/soundcmd.cpp +++ b/engines/sci/sound/soundcmd.cpp @@ -511,11 +511,15 @@ void SoundCommandParser::cmdStopSound(reg_t obj, int16 value) { return; } - PUT_SEL32V(_segMan, obj, handle, 0); - if (_soundVersion <= SCI_VERSION_0_LATE) - PUT_SEL32V(_segMan, obj, state, kSoundStopped); - else - PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET); + // Don't modify the objects of sound slots that are already stopped, + // as the associated objects could have been disposed + if (musicSlot->status != kSoundStopped) { + PUT_SEL32V(_segMan, obj, handle, 0); + if (_soundVersion <= SCI_VERSION_0_LATE) + PUT_SEL32V(_segMan, obj, state, kSoundStopped); + else + PUT_SEL32V(_segMan, obj, signal, SIGNAL_OFFSET); + } musicSlot->dataInc = 0; musicSlot->signal = 0; @@ -903,10 +907,14 @@ void SoundCommandParser::cmdStopAllSounds(reg_t obj, int16 value) { const MusicList::iterator end = _music->getPlayListEnd(); for (MusicList::iterator i = _music->getPlayListStart(); i != end; ++i) { - if (_soundVersion <= SCI_VERSION_0_LATE) - PUT_SEL32V(_segMan, (*i)->soundObj, state, kSoundStopped); - else - PUT_SEL32V(_segMan, (*i)->soundObj, signal, SIGNAL_OFFSET); + // Don't modify the objects of sound slots that are already stopped, + // as the associated objects could have been disposed + if ((*i)->status != kSoundStopped) { + if (_soundVersion <= SCI_VERSION_0_LATE) + PUT_SEL32V(_segMan, (*i)->soundObj, state, kSoundStopped); + else + PUT_SEL32V(_segMan, (*i)->soundObj, signal, SIGNAL_OFFSET); + } (*i)->dataInc = 0; _music->soundStop(*i); |