X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmidi_tracer.cc;h=cbf500ff99b321df4ca4db57085044bd04f12c27;hb=5fef65538040fbac1b9edd1847a269aa925a49c9;hp=fee339d126a32909d8271d65cb3ec218a16e9e03;hpb=f0fcda204444922fc0e1261929aa6fdb84412036;p=ardour.git diff --git a/gtk2_ardour/midi_tracer.cc b/gtk2_ardour/midi_tracer.cc index fee339d126..cbf500ff99 100644 --- a/gtk2_ardour/midi_tracer.cc +++ b/gtk2_ardour/midi_tracer.cc @@ -23,6 +23,9 @@ #include #include +#include "pbd/localtime_r.h" +#include "pbd/timersub.h" + #include "midi++/parser.h" #include "ardour/async_midi_port.h" @@ -40,13 +43,11 @@ using namespace Glib; MidiTracer::MidiTracer () : ArdourWindow (_("MIDI Tracer")) - , parser (0) , line_count_adjustment (200, 1, 2000, 1, 10) , line_count_spinner (line_count_adjustment) , line_count_label (_("Line history: ")) , autoscroll (true) , show_hex (true) - , collect (true) , show_delta_time (false) , _update_queued (0) , fifo (1024) @@ -164,16 +165,25 @@ MidiTracer::port_changed () return; } + /* The inheritance heirarchy makes this messy. AsyncMIDIPort has two + * available MIDI::Parsers what we could connect to, ::self_parser() + * (from ARDOUR::MidiPort) and ::parser() from MIDI::Port. One day, + * this mess will all go away ... + */ + boost::shared_ptr async = boost::dynamic_pointer_cast (p); if (!async) { - /* pure ARDOUR::MidiPort ... cannot currently attach to it because it - * has no Parser. - */ - return; + + boost::shared_ptr mp = boost::dynamic_pointer_cast (p); + + if (mp) { + mp->self_parser().any.connect_same_thread (_parser_connection, boost::bind (&MidiTracer::tracer, this, _1, _2, _3)); + } + + } else { + async->parser()->any.connect_same_thread (_parser_connection, boost::bind (&MidiTracer::tracer, this, _1, _2, _3)); } - - async->parser()->any.connect_same_thread (_parser_connection, boost::bind (&MidiTracer::tracer, this, _1, _2, _3)); } void @@ -203,7 +213,7 @@ MidiTracer::tracer (Parser&, byte* msg, size_t len) s = snprintf (buf, bufsize, "+%02" PRId64 ":%06" PRId64, (int64_t) delta.tv_sec, (int64_t) delta.tv_usec); bufsize -= s; } else { - localtime_r (&tv.tv_sec, &now); + localtime_r ((const time_t*)&tv.tv_sec, &now); s = strftime (buf, bufsize, "%H:%M:%S", &now); bufsize -= s; s += snprintf (&buf[s], bufsize, ".%06" PRId64, (int64_t) tv.tv_usec); @@ -393,11 +403,13 @@ MidiTracer::tracer (Parser&, byte* msg, size_t len) // If you want to append more to the line, uncomment this first // bufsize -= s; + assert(s <= buffer_size); // clang dead-assignment + fifo.write (&buf, 1); - if (g_atomic_int_get (&_update_queued) == 0) { + if (g_atomic_int_get (const_cast (&_update_queued)) == 0) { gui_context()->call_slot (invalidator (*this), boost::bind (&MidiTracer::update, this)); - g_atomic_int_inc (&_update_queued); + g_atomic_int_inc (const_cast (&_update_queued)); } } @@ -405,7 +417,7 @@ void MidiTracer::update () { bool updated = false; - g_atomic_int_dec_and_test (&_update_queued); + g_atomic_int_dec_and_test (const_cast (&_update_queued)); RefPtr buf (text.get_buffer());