Browse Source

Fix MidiIO destructor crash

tags/v0.6.0
Andrew Belt 6 years ago
parent
commit
5984e52918
3 changed files with 12 additions and 11 deletions
  1. +3
    -5
      include/midi.hpp
  2. +0
    -1
      src/Core/MIDIToCVInterface.cpp
  3. +9
    -5
      src/midi.cpp

+ 3
- 5
include/midi.hpp View File

@@ -42,7 +42,7 @@ struct MidiIO {
/** Cached */
std::string deviceName;

virtual ~MidiIO();
virtual ~MidiIO() {}
std::vector<int> getDrivers();
std::string getDriverName(int driver);
virtual void setDriver(int driver) {}
@@ -61,11 +61,8 @@ struct MidiIO {

struct MidiInput : MidiIO {
RtMidiIn *rtMidiIn = NULL;
/** These flags must be set before the driver and device is set */
bool enableSysEx = false;
bool enableTime = false;
bool enableSense = false;
MidiInput();
~MidiInput();
void setDriver(int driver) override;
virtual void onMessage(const MidiMessage &message) {}
};
@@ -83,6 +80,7 @@ struct MidiInputQueue : MidiInput {
struct MidiOutput : MidiIO {
RtMidiOut *rtMidiOut = NULL;
MidiOutput();
~MidiOutput();
void setDriver(int driver) override;
};



+ 0
- 1
src/Core/MIDIToCVInterface.cpp View File

@@ -56,7 +56,6 @@ struct MIDIToCVInterface : Module {
bool gate;

MIDIToCVInterface() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {
midiInput.enableTime = true;
onReset();
}



+ 9
- 5
src/midi.cpp View File

@@ -12,10 +12,6 @@ namespace rack {
// MidiIO
////////////////////

MidiIO::~MidiIO() {
setDriver(-1);
}

std::vector<int> MidiIO::getDrivers() {
std::vector<RtMidi::Api> rtApis;
RtMidi::getCompiledApi(rtApis);
@@ -149,6 +145,10 @@ MidiInput::MidiInput() {
setDriver(RtMidi::UNSPECIFIED);
}

MidiInput::~MidiInput() {
setDriver(-1);
}

void MidiInput::setDriver(int driver) {
setDevice(-1);
if (rtMidiIn) {
@@ -159,7 +159,7 @@ void MidiInput::setDriver(int driver) {
if (driver >= 0) {
rtMidiIn = new RtMidiIn((RtMidi::Api) driver);
rtMidiIn->setCallback(midiInputCallback, this);
rtMidiIn->ignoreTypes(!enableSysEx, !enableTime, !enableSense);
rtMidiIn->ignoreTypes(false, false, false);
rtMidi = rtMidiIn;
this->driver = rtMidiIn->getCurrentApi();
}
@@ -189,6 +189,10 @@ MidiOutput::MidiOutput() {
setDriver(RtMidi::UNSPECIFIED);
}

MidiOutput::~MidiOutput() {
setDriver(-1);
}

void MidiOutput::setDriver(int driver) {
setDevice(-1);
if (rtMidiOut) {


Loading…
Cancel
Save