[Scummvm-cvs-logs] CVS: scummvm/sound mpu401.cpp,1.26,1.27 mpu401.h,1.19,1.20

Eugene Sandulenko sev at users.sourceforge.net
Thu Nov 4 13:40:23 CET 2004


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16062

Modified Files:
	mpu401.cpp mpu401.h 
Log Message:
Delegate channel functions to any MidiDriver. This is useful for the 
MT-32 emulation and quite possibly other MidiDrivers in future.


Index: mpu401.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mpu401.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mpu401.cpp	22 Aug 2004 13:27:34 -0000	1.26
+++ mpu401.cpp	4 Nov 2004 21:34:17 -0000	1.27
@@ -23,12 +23,18 @@
 #include "common/timer.h"
 #include "common/util.h"	// for ARRAYSIZE
 
-void MidiChannel_MPU401::init(MidiDriver_MPU401 *owner, byte channel) {
+void MidiChannel_MPU401::init(MidiDriver *owner, byte channel) {
 	_owner = owner;
 	_channel = channel;
 	_allocated = false;
 }
 
+bool MidiChannel_MPU401::allocate() {
+	if (_allocated)
+		return false;
+	return (_allocated = true);
+}
+
 MidiDriver *MidiChannel_MPU401::device() {
 	return _owner;
 }
@@ -117,8 +123,7 @@
 		if (i == 9 || !(_channel_mask & (1 << i)))
 			continue;
 		chan = &_midi_channels[i];
-		if (!chan->_allocated) {
-			chan->allocate();
+		if (chan->allocate()) {
 			return chan;
 		}
 	}

Index: mpu401.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mpu401.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- mpu401.h	22 Aug 2004 13:27:34 -0000	1.19
+++ mpu401.h	4 Nov 2004 21:34:17 -0000	1.20
@@ -35,16 +35,12 @@
 class MidiDriver_MPU401;
 
 class MidiChannel_MPU401 : public MidiChannel {
-	friend class MidiDriver_MPU401;
 
 private:
-	MidiDriver_MPU401 *_owner;
+	MidiDriver *_owner;
 	bool _allocated;
 	byte _channel;
 
-	void init (MidiDriver_MPU401 *owner, byte channel);
-	void allocate() { _allocated = true; }
-
 public:
 	MidiDriver *device();
 	byte getNumber() { return _channel; }
@@ -64,6 +60,10 @@
 
 	// SysEx messages
 	void sysEx_customInstrument (uint32 type, byte *instr);
+
+	// Only to be called by the owner
+	void init (MidiDriver *owner, byte channel);
+	bool allocate();
 };
 
 





More information about the Scummvm-git-logs mailing list