MIDI output: don't spam logs on error

This commit is contained in:
tildearrow 2023-06-25 04:57:04 -05:00
parent 7beb1271ae
commit feef9234b6
2 changed files with 9 additions and 2 deletions

View File

@ -160,6 +160,7 @@ bool TAMidiInRtMidi::quit() {
bool TAMidiOutRtMidi::send(const TAMidiMessage& what) {
if (!isOpen) return false;
if (!isWorking) return false;
if (what.type<0x80) return false;
size_t len=0;
switch (what.type&0xf0) {
@ -190,6 +191,7 @@ bool TAMidiOutRtMidi::send(const TAMidiMessage& what) {
port->sendMessage(what.sysExData.get(),len);
} catch (RtMidiError& e) {
logE("MIDI output error! %s",e.what());
isWorking=false;
return false;
}
return true;
@ -209,6 +211,7 @@ bool TAMidiOutRtMidi::send(const TAMidiMessage& what) {
port->sendMessage((const unsigned char*)&what.type,len);
} catch (RtMidiError& e) {
logE("MIDI output error! %s",e.what());
isWorking=false;
return false;
}
return true;
@ -237,17 +240,20 @@ bool TAMidiOutRtMidi::openDevice(String name) {
}
isOpen=portOpen;
if (!portOpen) logW("could not find MIDI out device...");
isWorking=true;
return portOpen;
} catch (RtMidiError& e) {
logW("could not open MIDI out device! %s",e.what());
return false;
}
isWorking=true;
return true;
}
bool TAMidiOutRtMidi::closeDevice() {
if (port==NULL) return false;
if (!isOpen) return false;
isWorking=false;
try {
port->closePort();
} catch (RtMidiError& e) {

View File

@ -38,7 +38,7 @@ class TAMidiInRtMidi: public TAMidiIn {
class TAMidiOutRtMidi: public TAMidiOut {
RtMidiOut* port;
bool isOpen;
bool isOpen, isWorking;
public:
bool send(const TAMidiMessage& what);
bool isDeviceOpen();
@ -49,5 +49,6 @@ class TAMidiOutRtMidi: public TAMidiOut {
bool init();
TAMidiOutRtMidi():
port(NULL),
isOpen(false) {}
isOpen(false),
isWorking(false) {}
};