From cfafa610f09334029f8bda4877bd7de98345ea94 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 23 Oct 2013 13:51:04 -0400 Subject: [PATCH] fix MMC MTC and MIDI Clock port input handling was moved into the process/RT thread(s) during audioengine work, but MMC was left orphaned. Add it to the port(s) handled by the MIDI UI thread. Also, remove PortChange request from MidiUI because it has no meaning anymore --- libs/ardour/ardour/midi_ui.h | 3 -- libs/ardour/midi_ui.cc | 58 +++++++++++++++++------------------- 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/libs/ardour/ardour/midi_ui.h b/libs/ardour/ardour/midi_ui.h index c15a530057..9e46f226f7 100644 --- a/libs/ardour/ardour/midi_ui.h +++ b/libs/ardour/ardour/midi_ui.h @@ -51,8 +51,6 @@ class MidiControlUI : public AbstractUI static MidiControlUI* instance() { return _instance; } - static BaseUI::RequestType PortChange; - void change_midi_ports (); protected: @@ -63,7 +61,6 @@ class MidiControlUI : public AbstractUI typedef std::list PortSources; PortSources port_sources; ARDOUR::Session& _session; - PBD::ScopedConnection rebind_connection; bool midi_input_handler (Glib::IOCondition, AsyncMIDIPort*); void reset_ports (); diff --git a/libs/ardour/midi_ui.cc b/libs/ardour/midi_ui.cc index 7346c0244c..0729132d6c 100644 --- a/libs/ardour/midi_ui.cc +++ b/libs/ardour/midi_ui.cc @@ -39,7 +39,6 @@ using namespace Glib; #include "i18n.h" -BaseUI::RequestType MidiControlUI::PortChange = BaseUI::new_request_type(); MidiControlUI* MidiControlUI::_instance = 0; #include "pbd/abstract_ui.cc" /* instantiate the template */ @@ -60,24 +59,7 @@ MidiControlUI::~MidiControlUI () void MidiControlUI::do_request (MidiUIRequest* req) { - if (req->type == PortChange) { - - /* restart event loop with new ports */ - DEBUG_TRACE (DEBUG::MidiIO, "reset ports\n"); - reset_ports (); - - } else if (req->type == CallSlot) { - -#ifndef NDEBUG - if (getenv ("DEBUG_THREADED_SIGNALS")) { - cerr << "MIDI UI calls a slot\n"; - } -#endif - - req->the_slot (); - - } else if (req->type == Quit) { - + if (req->type == Quit) { BaseUI::quit (); } } @@ -117,23 +99,37 @@ MidiControlUI::clear_ports () void MidiControlUI::reset_ports () { - if (port_sources.empty()) { - AsyncMIDIPort* async = dynamic_cast (_session.midi_input_port()); + if (!port_sources.empty()) { + return; + } + + vector ports; + AsyncMIDIPort* p; + + if ((p = dynamic_cast (_session.midi_input_port()))) { + ports.push_back (p); + } + + + if ((p = dynamic_cast (_session.mmc_input_port()))) { + ports.push_back (p); + } + + if (ports.empty()) { + return; + } + + int fd; + for (vector::const_iterator pi = ports.begin(); pi != ports.end(); ++pi) { - if (!async) { - return; - } - - int fd; - - if ((fd = async->selectable ()) >= 0) { + if ((fd = (*pi)->selectable ()) >= 0) { Glib::RefPtr psrc = IOSource::create (fd, IO_IN|IO_HUP|IO_ERR); - psrc->connect (sigc::bind (sigc::mem_fun (this, &MidiControlUI::midi_input_handler), async)); + psrc->connect (sigc::bind (sigc::mem_fun (this, &MidiControlUI::midi_input_handler), *pi)); psrc->attach (_main_loop->get_context()); - + // glibmm hack: for now, store only the GSource* - + port_sources.push_back (psrc->gobj()); g_source_ref (psrc->gobj()); }