MIDI output: don't spam logs on error
This commit is contained in:
parent
7beb1271ae
commit
feef9234b6
|
@ -160,6 +160,7 @@ bool TAMidiInRtMidi::quit() {
|
||||||
|
|
||||||
bool TAMidiOutRtMidi::send(const TAMidiMessage& what) {
|
bool TAMidiOutRtMidi::send(const TAMidiMessage& what) {
|
||||||
if (!isOpen) return false;
|
if (!isOpen) return false;
|
||||||
|
if (!isWorking) return false;
|
||||||
if (what.type<0x80) return false;
|
if (what.type<0x80) return false;
|
||||||
size_t len=0;
|
size_t len=0;
|
||||||
switch (what.type&0xf0) {
|
switch (what.type&0xf0) {
|
||||||
|
@ -190,6 +191,7 @@ bool TAMidiOutRtMidi::send(const TAMidiMessage& what) {
|
||||||
port->sendMessage(what.sysExData.get(),len);
|
port->sendMessage(what.sysExData.get(),len);
|
||||||
} catch (RtMidiError& e) {
|
} catch (RtMidiError& e) {
|
||||||
logE("MIDI output error! %s",e.what());
|
logE("MIDI output error! %s",e.what());
|
||||||
|
isWorking=false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -209,6 +211,7 @@ bool TAMidiOutRtMidi::send(const TAMidiMessage& what) {
|
||||||
port->sendMessage((const unsigned char*)&what.type,len);
|
port->sendMessage((const unsigned char*)&what.type,len);
|
||||||
} catch (RtMidiError& e) {
|
} catch (RtMidiError& e) {
|
||||||
logE("MIDI output error! %s",e.what());
|
logE("MIDI output error! %s",e.what());
|
||||||
|
isWorking=false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -237,17 +240,20 @@ bool TAMidiOutRtMidi::openDevice(String name) {
|
||||||
}
|
}
|
||||||
isOpen=portOpen;
|
isOpen=portOpen;
|
||||||
if (!portOpen) logW("could not find MIDI out device...");
|
if (!portOpen) logW("could not find MIDI out device...");
|
||||||
|
isWorking=true;
|
||||||
return portOpen;
|
return portOpen;
|
||||||
} catch (RtMidiError& e) {
|
} catch (RtMidiError& e) {
|
||||||
logW("could not open MIDI out device! %s",e.what());
|
logW("could not open MIDI out device! %s",e.what());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
isWorking=true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TAMidiOutRtMidi::closeDevice() {
|
bool TAMidiOutRtMidi::closeDevice() {
|
||||||
if (port==NULL) return false;
|
if (port==NULL) return false;
|
||||||
if (!isOpen) return false;
|
if (!isOpen) return false;
|
||||||
|
isWorking=false;
|
||||||
try {
|
try {
|
||||||
port->closePort();
|
port->closePort();
|
||||||
} catch (RtMidiError& e) {
|
} catch (RtMidiError& e) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ class TAMidiInRtMidi: public TAMidiIn {
|
||||||
|
|
||||||
class TAMidiOutRtMidi: public TAMidiOut {
|
class TAMidiOutRtMidi: public TAMidiOut {
|
||||||
RtMidiOut* port;
|
RtMidiOut* port;
|
||||||
bool isOpen;
|
bool isOpen, isWorking;
|
||||||
public:
|
public:
|
||||||
bool send(const TAMidiMessage& what);
|
bool send(const TAMidiMessage& what);
|
||||||
bool isDeviceOpen();
|
bool isDeviceOpen();
|
||||||
|
@ -49,5 +49,6 @@ class TAMidiOutRtMidi: public TAMidiOut {
|
||||||
bool init();
|
bool init();
|
||||||
TAMidiOutRtMidi():
|
TAMidiOutRtMidi():
|
||||||
port(NULL),
|
port(NULL),
|
||||||
isOpen(false) {}
|
isOpen(false),
|
||||||
|
isWorking(false) {}
|
||||||
};
|
};
|
Loading…
Reference in a new issue