From 5984e52918cb2652c0f916e5ad26d678a5e90a95 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 10 Mar 2018 03:54:07 -0500 Subject: [PATCH] Fix MidiIO destructor crash --- include/midi.hpp | 8 +++----- src/Core/MIDIToCVInterface.cpp | 1 - src/midi.cpp | 14 +++++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/midi.hpp b/include/midi.hpp index c5602599..57ed40ee 100644 --- a/include/midi.hpp +++ b/include/midi.hpp @@ -42,7 +42,7 @@ struct MidiIO { /** Cached */ std::string deviceName; - virtual ~MidiIO(); + virtual ~MidiIO() {} std::vector 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; }; diff --git a/src/Core/MIDIToCVInterface.cpp b/src/Core/MIDIToCVInterface.cpp index 534fc001..7543de14 100644 --- a/src/Core/MIDIToCVInterface.cpp +++ b/src/Core/MIDIToCVInterface.cpp @@ -56,7 +56,6 @@ struct MIDIToCVInterface : Module { bool gate; MIDIToCVInterface() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) { - midiInput.enableTime = true; onReset(); } diff --git a/src/midi.cpp b/src/midi.cpp index 2279bc83..06911484 100644 --- a/src/midi.cpp +++ b/src/midi.cpp @@ -12,10 +12,6 @@ namespace rack { // MidiIO //////////////////// -MidiIO::~MidiIO() { - setDriver(-1); -} - std::vector MidiIO::getDrivers() { std::vector 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) {