X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fmidi%2B%2B2%2Fparser.cc;h=453fede251255b190ec9f720999fd6debe98351e;hb=82e23ecd2aaea1cfc10e790ee86ebc126d680ec2;hp=60a321cefb2e1ea2ca6dcaae17fcff1f9a8f036c;hpb=c83389b8ec5fef9553a401e6123b7e55702af9e2;p=ardour.git diff --git a/libs/midi++2/parser.cc b/libs/midi++2/parser.cc index 60a321cefb..453fede251 100644 --- a/libs/midi++2/parser.cc +++ b/libs/midi++2/parser.cc @@ -104,9 +104,7 @@ Parser::midi_event_type_name (eventType t) } } -Parser::Parser (Port &p) - : _port (p) - +Parser::Parser () { trace_stream = 0; trace_prefix = ""; @@ -134,11 +132,11 @@ Parser::Parser (Port &p) Parser::~Parser () { - delete msgbuf; + free (msgbuf); } void -Parser::trace_event (Parser &, byte *msg, size_t len) +Parser::trace_event (Parser &, MIDI::byte *msg, size_t len) { eventType type; ostream *o; @@ -326,9 +324,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 @@ -386,9 +385,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; } @@ -419,17 +420,22 @@ Parser::scanner (unsigned char inbyte) } cerr << dec << endl; #endif - if (msgindex > 0 && (edit.empty() || !(*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,7 +496,10 @@ Parser::scanner (unsigned char inbyte) case NEEDONEBYTE: /* We've completed a 1 or 2 byte message. */ - if (edit.empty() || !(*edit (msgbuf, msgindex) == 0)) { + + edit_result = edit (msgbuf, msgindex); + + if (edit_result.get_value_or (1)) { /* message not cancelled by an editor */ @@ -649,7 +658,7 @@ Parser::system_msg (unsigned char inbyte) } void -Parser::signal (byte *msg, size_t len) +Parser::signal (MIDI::byte *msg, size_t len) { channel_t chan = msg[0]&0xF; int chan_i = chan; @@ -752,7 +761,7 @@ Parser::signal (byte *msg, size_t len) } bool -Parser::possible_mmc (byte *msg, size_t msglen) +Parser::possible_mmc (MIDI::byte *msg, size_t msglen) { if (!MachineControl::is_mmc (msg, msglen)) { return false;