diff options
-rw-r--r-- | audio/midiparser.cpp | 8 | ||||
-rw-r--r-- | audio/midiparser.h | 1 | ||||
-rw-r--r-- | engines/sci/sound/midiparser_sci.cpp | 8 | ||||
-rw-r--r-- | engines/sci/sound/music.cpp | 5 | ||||
-rw-r--r-- | engines/sci/sound/music.h | 1 |
5 files changed, 10 insertions, 13 deletions
diff --git a/audio/midiparser.cpp b/audio/midiparser.cpp index dcb83bb090..2454575413 100644 --- a/audio/midiparser.cpp +++ b/audio/midiparser.cpp @@ -44,7 +44,8 @@ _centerPitchWheelOnUnload(false), _sendSustainOffOnNotesOff(false), _numTracks(0), _activeTrack(255), -_abortParse(0) { +_abortParse(false), +_jumpingToTick(false) { memset(_activeNotes, 0, sizeof(_activeNotes)); memset(_tracks, 0, sizeof(_tracks)); _nextEvent.start = NULL; @@ -382,6 +383,9 @@ bool MidiParser::jumpToTick(uint32 tick, bool fireEvents, bool stopNotes, bool d if (_activeTrack >= _numTracks) return false; + assert(!_jumpingToTick); // This function is not re-entrant + _jumpingToTick = true; + Tracker currentPos(_position); EventInfo currentEvent(_nextEvent); @@ -411,6 +415,7 @@ bool MidiParser::jumpToTick(uint32 tick, bool fireEvents, bool stopNotes, bool d // This means that we failed to find the right tick. _position = currentPos; _nextEvent = currentEvent; + _jumpingToTick = false; return false; } else { processEvent(info, fireEvents); @@ -437,6 +442,7 @@ bool MidiParser::jumpToTick(uint32 tick, bool fireEvents, bool stopNotes, bool d } _abortParse = true; + _jumpingToTick = false; return true; } diff --git a/audio/midiparser.h b/audio/midiparser.h index 28f39e623f..05d0cbe1db 100644 --- a/audio/midiparser.h +++ b/audio/midiparser.h @@ -287,6 +287,7 @@ protected: ///< so each event is parsed only once; this permits ///< simulated events in certain formats. bool _abortParse; ///< If a jump or other operation interrupts parsing, flag to abort. + bool _jumpingToTick; ///< True if currently inside jumpToTick protected: static uint32 readVLQ(byte * &data); diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp index 0af8e7aedd..40ae91d83d 100644 --- a/engines/sci/sound/midiparser_sci.cpp +++ b/engines/sci/sound/midiparser_sci.cpp @@ -543,7 +543,7 @@ void MidiParser_SCI::processEvent(const EventInfo &info, bool fireEvents) { // That is probably why this signal isn't triggered // immediately there. if (_soundVersion <= SCI_VERSION_0_LATE || _position._playTick) { - if (!_pSnd->inFastForward) { + if (!_jumpingToTick) { _pSnd->setSignal(info.basic.param1); debugC(4, kDebugLevelSound, "signal %04x", info.basic.param1); } @@ -586,15 +586,13 @@ void MidiParser_SCI::processEvent(const EventInfo &info, bool fireEvents) { // marker set for that song by cmdSetSoundHold. // If it is, loop back, but don't stop notes when jumping. if (info.basic.param2 == _pSnd->hold) { - _pSnd->inFastForward = true; jumpToTick(_loopTick, false, false); - _pSnd->inFastForward = false; // Done with this event. return; } return; case kUpdateCue: - if (!_pSnd->inFastForward) { + if (!_jumpingToTick) { int inc; switch (_soundVersion) { case SCI_VERSION_0_EARLY: @@ -658,9 +656,7 @@ void MidiParser_SCI::processEvent(const EventInfo &info, bool fireEvents) { // (e.g. song 110, during the intro). The original interpreter // treats this case as an infinite loop (bug #3311911). if (_pSnd->loop || _pSnd->hold > 0) { - _pSnd->inFastForward = true; jumpToTick(_loopTick); - _pSnd->inFastForward = false; // Done with this event. return; diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index 1628a22386..8c6d0d6431 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -521,11 +521,7 @@ void SciMusic::soundPlay(MusicEntry *pSnd) { pSnd->pMidiParser->jumpToTick(0); else { // Fast forward to the last position and perform associated events when loading - pSnd->inFastForward = true; - // we set this flag, so that the midiparser doesn't set any signals for scripts - // if we don't do this, at least accessing the debugger will reset previously set signals pSnd->pMidiParser->jumpToTick(pSnd->ticker, true, true, true); - pSnd->inFastForward = false; } // Restore looping and hold @@ -765,7 +761,6 @@ MusicEntry::MusicEntry() { resourceId = 0; isQueued = false; - inFastForward = false; dataInc = 0; ticker = 0; diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index 5924a0fd12..1f798c90d7 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -65,7 +65,6 @@ public: uint16 resourceId; bool isQueued; // for SCI0 only! - bool inFastForward; // if we are currently fast-forwarding (disables any signals to scripts) uint16 dataInc; uint16 ticker; |