X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fmidi%2B%2B2%2Fmtc.cc;h=1a477c3b8caaf9f1aaacfabf86d2c4aa2431ec84;hb=8c9749e42faf7808034ed8b7afce4a2fe6dc6f33;hp=d7c089eecd4e6cc643d748b54f672070f7741162;hpb=6236cf7df25991518dba783661df3947114a6289;p=ardour.git diff --git a/libs/midi++2/mtc.cc b/libs/midi++2/mtc.cc index d7c089eecd..1a477c3b8c 100644 --- a/libs/midi++2/mtc.cc +++ b/libs/midi++2/mtc.cc @@ -33,10 +33,10 @@ using namespace std; using namespace sigc; using namespace MIDI; -#define DEBUG_MTC +#undef DEBUG_MTC bool -Parser::possible_mtc (byte *sysex_buf, size_t msglen) +Parser::possible_mtc (MIDI::byte *sysex_buf, size_t msglen) { byte fake_mtc_time[5]; @@ -91,7 +91,7 @@ Parser::reset_mtc_state () } void -Parser::process_mtc_quarter_frame (byte *msg) +Parser::process_mtc_quarter_frame (MIDI::byte *msg) { int which_quarter_frame = (msg[1] & 0xf0) >> 4; @@ -185,7 +185,9 @@ Parser::process_mtc_quarter_frame (byte *msg) true, just ignore this in terms of it being an error. */ - if (1) { /* mtc_skipped () */ + boost::optional res = mtc_skipped (); + + if (res.get_value_or (false)) { /* no error, reset next expected frame */ @@ -217,17 +219,12 @@ Parser::process_mtc_quarter_frame (byte *msg) return; } - /* go back to waiting for the first frame */ - - expected_mtc_quarter_frame_code = 0; - memset (_qtr_mtc_time, 0, sizeof (_qtr_mtc_time)); - - _mtc_running = MTC_Stopped; - _mtc_locked = false; + /* skip counts as an error ... go back to waiting for the first frame */ #ifdef DEBUG_MTC cerr << "Skipped MTC qtr frame, return to stopped state" << endl; #endif + reset_mtc_state (); mtc_status (MTC_Stopped); return; @@ -243,7 +240,7 @@ Parser::process_mtc_quarter_frame (byte *msg) /* time code is looking good */ #ifdef DEBUG_MTC - // cerr << "for quarter frame " << which_quarter_frame << " byte = " << hex << (int) msg[1] << dec << endl; + cerr << "for quarter frame " << which_quarter_frame << " byte = " << hex << (int) msg[1] << dec << endl; #endif switch (which_quarter_frame) { @@ -303,7 +300,7 @@ Parser::process_mtc_quarter_frame (byte *msg) switch (_mtc_running) { case MTC_Forward: - if ((which_quarter_frame == 7)) { + if (which_quarter_frame == 7) { /* we've reached the final of 8 quarter frame messages. store the time, reset the pending time holder,