Skip to content

Commit 0451a6e

Browse files
cmaughansamaaron
authored andcommitted
Midi Fix
Catch potential exceptions from RtMidi in the constructors
1 parent 4513d18 commit 0451a6e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

app/external/sp_midi/src/midiin.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,16 @@ MidiIn::MidiIn(const string& portName, const string& normalizedPortName, int por
3838
if (!isVirtual) {
3939
m_rtMidiId = portId;
4040
m_midiIn = make_unique<RtMidiIn>();
41-
m_midiIn->openPort(m_rtMidiId);
41+
42+
try
43+
{
44+
m_midiIn->openPort(m_rtMidiId);
45+
}
46+
catch(const RtMidiError& err)
47+
{
48+
m_logger.debug("Failed to open midi out port");
49+
}
50+
4251
m_midiIn->ignoreTypes( false, false, false );
4352
}
4453
// TODO: do the virtual ports

app/external/sp_midi/src/midiout.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ MidiOut::MidiOut(const std::string& portName, const std::string& normalizedPortN
3636

3737
// FIXME: need to check if name does not exist
3838
m_midiOut = make_unique<RtMidiOut>();
39-
m_midiOut->openPort(m_rtMidiId);
39+
40+
try
41+
{
42+
m_midiOut->openPort(m_rtMidiId);
43+
}
44+
catch(const RtMidiError& err)
45+
{
46+
m_logger.debug("Failed to open midi out port");
47+
}
4048
}
4149

4250
MidiOut::~MidiOut()

0 commit comments

Comments
 (0)