Revert "AUDIO: Simplify MidiTracker::processEvent return value"

MI2 deletes the parser object(!) so we can't access any member
variables here. Thanks to athrxx for finding this.

This reverts commit 86c2fe47e0 and adds
a comment explaining why.
This commit is contained in:
Alyssa Milburn 2014-01-27 00:13:58 +01:00
parent 83ce4cfb5e
commit f92df4c6aa
2 changed files with 14 additions and 10 deletions

View file

@ -214,13 +214,16 @@ void MidiParser::onTimer() {
activeNote(info.channel(), info.basic.param1, true);
}
processEvent(info);
// Player::metaEvent() in SCUMM will delete the parser object,
// so return immediately if that might have happened.
bool ret = processEvent(info);
if (!ret)
return;
if (_abortParse)
break;
_position._lastEventTime = eventTime;
parseNextEvent(_nextEvent);
if (!_abortParse) {
_position._lastEventTime = eventTime;
parseNextEvent(_nextEvent);
}
}
if (!_abortParse) {
@ -229,7 +232,7 @@ void MidiParser::onTimer() {
}
}
void MidiParser::processEvent(const EventInfo &info, bool fireEvents) {
bool MidiParser::processEvent(const EventInfo &info, bool fireEvents) {
if (info.event == 0xF0) {
// SysEx event
// Check for trailing 0xF7 -- if present, remove it.
@ -252,8 +255,7 @@ void MidiParser::processEvent(const EventInfo &info, bool fireEvents) {
if (fireEvents)
_driver->metaEvent(info.ext.type, info.ext.data, (uint16)info.length);
}
_abortParse = true;
return;
return false;
} else if (info.ext.type == 0x51) {
if (info.length >= 3) {
setTempo(info.ext.data[0] << 16 | info.ext.data[1] << 8 | info.ext.data[2]);
@ -265,6 +267,8 @@ void MidiParser::processEvent(const EventInfo &info, bool fireEvents) {
if (fireEvents)
sendToDriver(info.event, info.basic.param1, info.basic.param2);
}
return true;
}