aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();
};