aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorEugene Sandulenko2004-11-04 21:34:17 +0000
committerEugene Sandulenko2004-11-04 21:34:17 +0000
commit775bd838c7a2857a1ca755494994e178a7707b00 (patch)
treefe9f4549d87645f0eeb21c3e0cf10bceed7e24d3 /sound
parent271f84cbde769069a5d74b7b73ba9747b88d3226 (diff)
downloadscummvm-rg350-775bd838c7a2857a1ca755494994e178a7707b00.tar.gz
scummvm-rg350-775bd838c7a2857a1ca755494994e178a7707b00.tar.bz2
scummvm-rg350-775bd838c7a2857a1ca755494994e178a7707b00.zip
Delegate channel functions to any MidiDriver. This is useful for the
MT-32 emulation and quite possibly other MidiDrivers in future. svn-id: r15711
Diffstat (limited to 'sound')
-rw-r--r--sound/mpu401.cpp11
-rw-r--r--sound/mpu401.h10
2 files changed, 13 insertions, 8 deletions
diff --git a/sound/mpu401.cpp b/sound/mpu401.cpp
index e301986a83..6ea50395f4 100644
--- a/sound/mpu401.cpp
+++ b/sound/mpu401.cpp
@@ -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 @@ MidiChannel *MidiDriver_MPU401::allocateChannel() {
if (i == 9 || !(_channel_mask & (1 << i)))
continue;
chan = &_midi_channels[i];
- if (!chan->_allocated) {
- chan->allocate();
+ if (chan->allocate()) {
return chan;
}
}
diff --git a/sound/mpu401.h b/sound/mpu401.h
index 365c46c5a5..213af64b6b 100644
--- a/sound/mpu401.h
+++ b/sound/mpu401.h
@@ -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 @@ public:
// SysEx messages
void sysEx_customInstrument (uint32 type, byte *instr);
+
+ // Only to be called by the owner
+ void init (MidiDriver *owner, byte channel);
+ bool allocate();
};