diff options
-rw-r--r-- | engines/sci/sound/midiparser_sci.cpp | 15 | ||||
-rw-r--r-- | engines/sci/sound/music.cpp | 20 | ||||
-rw-r--r-- | engines/sci/sound/music.h | 1 |
3 files changed, 24 insertions, 12 deletions
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp index 769df73365..598b394887 100644 --- a/engines/sci/sound/midiparser_sci.cpp +++ b/engines/sci/sound/midiparser_sci.cpp @@ -445,12 +445,8 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) { } if (_signalSet) { _signalSet = false; - if (!_pSnd->signal) { - _pSnd->signal = _signalToSet; - } else { - // signal already set and waiting for getting to scripts, queue new one - _pSnd->signalQueue.push_back(_signalToSet); - } + _pSnd->setSignal(_signalToSet); + debugC(4, kDebugLevelSound, "signal %04x", _signalToSet); } @@ -613,12 +609,7 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) { jumpToTick(_loopTick); } else { _pSnd->status = kSoundStopped; - if (!_pSnd->signal) { - _pSnd->signal = SIGNAL_OFFSET; - } else { - // signal already set and waiting for getting to scripts, queue new one - _pSnd->signalQueue.push_back(SIGNAL_OFFSET); - } + _pSnd->setSignal(SIGNAL_OFFSET); debugC(4, kDebugLevelSound, "signal EOT"); } diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index fc1e56fcea..91e04de3ad 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -30,6 +30,7 @@ #include "sci/sci.h" #include "sci/console.h" #include "sci/resource.h" +#include "sci/engine/features.h" #include "sci/engine/kernel.h" #include "sci/engine/state.h" #include "sci/sound/midiparser_sci.h" @@ -681,4 +682,23 @@ void MusicEntry::doFade() { } } +void MusicEntry::setSignal(int newSignal) { + // For SCI0, we cache the signals to set, as some songs might + // update their signal faster than kGetEvent is called (which is where + // we manually invoke kDoSoundUpdateCues for SCI0 games). SCI01 and + // newer handle signalling inside kDoSoundUpdateCues. Refer to bug #3042981 + if (g_sci->_features->detectDoSoundType() <= SCI_VERSION_0_LATE) { + if (!signal) { + signal = newSignal; + } else { + // signal already set and waiting for getting to scripts, queue new one + signalQueue.push_back(newSignal); + } + } else { + // Set the signal directly for newer games, otherwise the sound + // object might be deleted already later on (refer to bug #3045913) + signal = newSignal; + } +} + } // End of namespace Sci diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index 3cf600fcf3..7f02dc1513 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -109,6 +109,7 @@ public: void doFade(); void onTimer(); + void setSignal(int signal); virtual void saveLoadWithSerializer(Common::Serializer &ser); }; |