diff options
Diffstat (limited to 'audio/softsynth/fmtowns_pc98/towns_midi.cpp')
-rw-r--r-- | audio/softsynth/fmtowns_pc98/towns_midi.cpp | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/audio/softsynth/fmtowns_pc98/towns_midi.cpp b/audio/softsynth/fmtowns_pc98/towns_midi.cpp index 3c7ce7d0e4..00f0d43b98 100644 --- a/audio/softsynth/fmtowns_pc98/towns_midi.cpp +++ b/audio/softsynth/fmtowns_pc98/towns_midi.cpp @@ -835,19 +835,6 @@ const uint8 TownsMidiInputChannel::_programAdjustLevel[] = { MidiDriver_TOWNS::MidiDriver_TOWNS(Audio::Mixer *mixer) : _timerProc(0), _timerProcPara(0), _channels(0), _out(0), _chanState(0), _operatorLevelTable(0), _tickCounter1(0), _tickCounter2(0), _rand(1), _allocCurPos(0), _isOpen(false) { _intf = new TownsAudioInterface(mixer, this); -} - -MidiDriver_TOWNS::~MidiDriver_TOWNS() { - close(); - delete _intf; -} - -int MidiDriver_TOWNS::open() { - if (_isOpen) - return MERR_ALREADY_OPEN; - - if (!_intf->init()) - return MERR_CANNOT_CONNECT; _channels = new TownsMidiInputChannel*[32]; for (int i = 0; i < 32; i++) @@ -866,6 +853,38 @@ int MidiDriver_TOWNS::open() { } for (int i = 0; i < 64; i++) _operatorLevelTable[i << 5] = 0; +} + +MidiDriver_TOWNS::~MidiDriver_TOWNS() { + close(); + delete _intf; + + if (_channels) { + for (int i = 0; i < 32; i++) + delete _channels[i]; + delete[] _channels; + } + _channels = 0; + + if (_out) { + for (int i = 0; i < 6; i++) + delete _out[i]; + delete[] _out; + } + _out = 0; + + delete[] _chanState; + _chanState = 0; + delete[] _operatorLevelTable; + _operatorLevelTable = 0; +} + +int MidiDriver_TOWNS::open() { + if (_isOpen) + return MERR_ALREADY_OPEN; + + if (!_intf->init()) + return MERR_CANNOT_CONNECT; _intf->callback(0); @@ -876,9 +895,7 @@ int MidiDriver_TOWNS::open() { _intf->callback(33, 8); _intf->setSoundEffectChanMask(~0x3f); - _tickCounter1 = _tickCounter2 = 0; - _allocCurPos = 0; - _rand = 1; + _allocCurPos = 0; _isOpen = true; @@ -893,25 +910,6 @@ void MidiDriver_TOWNS::close() { setTimerCallback(0, 0); g_system->delayMillis(20); - - if (_channels) { - for (int i = 0; i < 32; i++) - delete _channels[i]; - delete[] _channels; - } - _channels = 0; - - if (_out) { - for (int i = 0; i < 6; i++) - delete _out[i]; - delete[] _out; - } - _out = 0; - - delete[] _chanState; - _chanState = 0; - delete[] _operatorLevelTable; - _operatorLevelTable = 0; } void MidiDriver_TOWNS::send(uint32 b) { |