[Scummvm-cvs-logs] scummvm master -> f92df4c6aab9ffb06ed241ae22779bdf11dc540c

fuzzie fuzzie at fuzzie.org
Mon Jan 27 00:25:00 CET 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

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


Commit: f92df4c6aab9ffb06ed241ae22779bdf11dc540c
    https://github.com/scummvm/scummvm/commit/f92df4c6aab9ffb06ed241ae22779bdf11dc540c
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2014-01-26T15:20:50-08:00

Commit Message:
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 86c2fe47e04449602e4c005fa0a9c183bc8bba39 and adds
a comment explaining why.

Changed paths:
    audio/midiparser.cpp
    audio/midiparser.h



diff --git a/audio/midiparser.cpp b/audio/midiparser.cpp
index 2454575..61f82c4 100644
--- a/audio/midiparser.cpp
+++ b/audio/midiparser.cpp
@@ -214,13 +214,16 @@ void MidiParser::onTimer() {
 				activeNote(info.channel(), info.basic.param1, true);
 		}
 
-		processEvent(info);
-
-		if (_abortParse)
-			break;
+		// Player::metaEvent() in SCUMM will delete the parser object,
+		// so return immediately if that might have happened.
+		bool ret = processEvent(info);
+		if (!ret)
+			return;
 
-		_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;
 }
 
 
diff --git a/audio/midiparser.h b/audio/midiparser.h
index 05d0cbe..9499d01 100644
--- a/audio/midiparser.h
+++ b/audio/midiparser.h
@@ -294,7 +294,7 @@ protected:
 	virtual void resetTracking();
 	virtual void allNotesOff();
 	virtual void parseNextEvent(EventInfo &info) = 0;
-	virtual void processEvent(const EventInfo &info, bool fireEvents = true);
+	virtual bool processEvent(const EventInfo &info, bool fireEvents = true);
 
 	void activeNote(byte channel, byte note, bool active);
 	void hangingNote(byte channel, byte note, uint32 ticksLeft, bool recycle = true);






More information about the Scummvm-git-logs mailing list