X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fmidi%2B%2B2%2Fparser.cc;h=cdd23a5306814793c1b24c6dd9eaf66655c30b0d;hb=a71172feb2af77d88f77ae26c9cfd0052540ef4b;hp=af9cfafaca9876d114cd4de98cd8de8c4c62f49e;hpb=f450df300c9c057141a4caf79ff6dbfbf58492d9;p=ardour.git diff --git a/libs/midi++2/parser.cc b/libs/midi++2/parser.cc index af9cfafaca..cdd23a5306 100644 --- a/libs/midi++2/parser.cc +++ b/libs/midi++2/parser.cc @@ -313,7 +313,6 @@ Parser::trace (bool onoff, ostream *o, const string &prefix) trace_connection.disconnect (); if (onoff) { - cerr << "enabling tracing for port " << _port.name() << endl; trace_stream = o; trace_prefix = prefix; any.connect_same_thread (trace_connection, boost::bind (&Parser::trace_event, this, _1, _2, _3)); @@ -327,9 +326,10 @@ void Parser::scanner (unsigned char inbyte) { bool statusbit; + boost::optional edit_result; // cerr << "parse: " << hex << (int) inbyte << dec << " state = " << state << " msgindex = " << msgindex << " runnable = " << runnable << endl; - + /* Check active sensing early, so it doesn't interrupt sysex. NOTE: active sense messages are not considered to fit under @@ -387,9 +387,11 @@ Parser::scanner (unsigned char inbyte) } if (rtmsg) { - if (edit (&inbyte, 1) >= 0 && !_offline) { + boost::optional res = edit (&inbyte, 1); + + if (res.get_value_or (1) >= 0 && !_offline) { realtime_msg (inbyte); - } + } return; } @@ -402,8 +404,9 @@ Parser::scanner (unsigned char inbyte) * an EOX. Actually, since EOX is a status byte, this * code ALWAYS handles the end of a VARIABLELENGTH message. */ - + if (state == VARIABLELENGTH && statusbit) { + /* The message has ended, so process it */ /* add EOX to any sysex message */ @@ -419,16 +422,21 @@ Parser::scanner (unsigned char inbyte) } cerr << dec << endl; #endif - if (msgindex > 0 && edit (msgbuf, msgindex) >= 0) { - if (!possible_mmc (msgbuf, msgindex) || _mmc_forward) { - if (!possible_mtc (msgbuf, msgindex) || _mtc_forward) { - if (!_offline) { - sysex (*this, msgbuf, msgindex); + if (msgindex > 0) { + + boost::optional res = edit (msgbuf, msgindex); + + if (res.get_value_or (1) >= 0) { + if (!possible_mmc (msgbuf, msgindex) || _mmc_forward) { + if (!possible_mtc (msgbuf, msgindex) || _mtc_forward) { + if (!_offline) { + sysex (*this, msgbuf, msgindex); + } } } - } - if (!_offline) { - any (*this, msgbuf, msgindex); + if (!_offline) { + any (*this, msgbuf, msgindex); + } } } } @@ -490,8 +498,10 @@ Parser::scanner (unsigned char inbyte) case NEEDONEBYTE: /* We've completed a 1 or 2 byte message. */ - - if (edit (msgbuf, msgindex) == 0) { + + edit_result = edit (msgbuf, msgindex); + + if (edit_result.get_value_or (1)) { /* message not cancelled by an editor */