From 4bfdcc18bd5284879d02a4ed9f44905ba84058d4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 23 Apr 2012 10:54:34 +0000 Subject: [PATCH] ControlProtocol doesn't actually need any record of an event loop and doesn't need to connect to any signals itself git-svn-id: svn://localhost/ardour2/branches/3.0@12063 d708f5d6-7413-0410-9779-e7cbd77b26cf --- .../control_protocol/control_protocol.cc | 25 +++---------------- .../control_protocol/control_protocol.h | 10 ++------ .../generic_midi_control_protocol.cc | 2 +- .../mackie/mackie_control_protocol.cc | 8 +++--- libs/surfaces/mackie/strip.cc | 21 +++++++--------- libs/surfaces/mackie/surface.cc | 9 ++----- libs/surfaces/osc/osc.cc | 2 +- libs/surfaces/powermate/powermate.cc | 2 +- 8 files changed, 24 insertions(+), 55 deletions(-) diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc index e2bc1673d8..1868957d3f 100644 --- a/libs/surfaces/control_protocol/control_protocol.cc +++ b/libs/surfaces/control_protocol/control_protocol.cc @@ -50,34 +50,17 @@ PBD::Signal1 ControlProtocol::SetRouteSelection; PBD::Signal1 ControlProtocol::RemoveRouteFromSelection; PBD::Signal0 ControlProtocol::ClearRouteSelection; -ControlProtocol::ControlProtocol (Session& s, string str, EventLoop* evloop) - : BasicUI (s), - _name (str) +ControlProtocol::ControlProtocol (Session& s, string str) + : BasicUI (s) + , _name (str) + , _active (false) { - if (evloop) { - _own_event_loop = false; - _event_loop = evloop; - } else { - _own_event_loop = true; - fatal << "programming error: cannot create control protocols without an existing event loop (yet)" << endmsg; - /*NOTREACHED*/ - } - - _active = false; - - session->RouteAdded.connect (*this, MISSING_INVALIDATOR, boost::protect (boost::bind (&ControlProtocol::add_strip, this, _1)), _event_loop); } ControlProtocol::~ControlProtocol () { } -void -ControlProtocol::add_strip (ARDOUR::RouteList&) -{ - route_list_changed(); -} - void ControlProtocol::next_track (uint32_t initial_id) { diff --git a/libs/surfaces/control_protocol/control_protocol/control_protocol.h b/libs/surfaces/control_protocol/control_protocol/control_protocol.h index 5401c98599..fc45f1e92a 100644 --- a/libs/surfaces/control_protocol/control_protocol/control_protocol.h +++ b/libs/surfaces/control_protocol/control_protocol/control_protocol.h @@ -39,9 +39,9 @@ class Route; class Session; class Bundle; -class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI { +class ControlProtocol : public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI { public: - ControlProtocol (Session&, std::string name, PBD::EventLoop* event_loop); + ControlProtocol (Session&, std::string name); virtual ~ControlProtocol(); std::string name() const { return _name; } @@ -52,8 +52,6 @@ class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, pu virtual int set_feedback (bool /*yn*/) { return 0; } virtual bool get_feedback () const { return false; } - virtual void route_list_changed () {} - virtual void midi_connectivity_established () {} PBD::Signal0 ActiveChanged; @@ -132,14 +130,10 @@ class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, pu virtual void tear_down_gui() { } protected: - PBD::EventLoop* _event_loop; - bool _own_event_loop; std::vector > route_table; std::string _name; bool _active; - void add_strip (std::list >&); - void next_track (uint32_t initial_id); void prev_track (uint32_t initial_id); diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index bff46462a7..f6d411e3f5 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -54,7 +54,7 @@ using namespace std; #define ui_bind(x) boost::protect (boost::bind ((x))) GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s) - : ControlProtocol (s, _("Generic MIDI"), midi_ui_context()) + : ControlProtocol (s, _("Generic MIDI")) , _motorised (false) , gui (0) { diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index db00546eef..2608ec4879 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -93,7 +93,7 @@ bool MackieControlProtocol::probe() } MackieControlProtocol::MackieControlProtocol (Session& session) - : ControlProtocol (session, X_("Mackie"), this) + : ControlProtocol (session, X_("Mackie")) , AbstractUI ("mackie") , _current_initial_bank (0) , _timecode_type (ARDOUR::AnyTime::BBT) @@ -164,9 +164,9 @@ MackieControlProtocol::thread_init () void MackieControlProtocol::midi_connectivity_established () { - /* may need to tell surfaces because they may need to wake up the - * device - */ + for (Surfaces::const_iterator si = surfaces.begin(); si != surfaces.end(); ++si) { + (*si)->say_hello (); + } } // go to the previous track. diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index ccb9137185..a97afb9414 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -61,9 +61,6 @@ using namespace PBD; #define ui_context() MackieControlProtocol::instance() /* a UICallback-derived object that specifies the event loop for signal handling */ #define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__)) -extern PBD::EventLoop::InvalidationRecord* __invalidator (sigc::trackable& trackable, const char*, int); -#define invalidator() __invalidator (*(MackieControlProtocol::instance()), __FILE__, __LINE__) - Strip::Strip (Surface& s, const std::string& name, int index, const map& strip_buttons) : Group (name) , _solo (0) @@ -168,23 +165,23 @@ Strip::set_route (boost::shared_ptr r, bool with_messages) set_vpot_parameter (PanAzimuthAutomation); - _route->solo_control()->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_solo_changed, this), ui_context()); - _route->mute_control()->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_mute_changed, this), ui_context()); + _route->solo_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_solo_changed, this), ui_context()); + _route->mute_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_mute_changed, this), ui_context()); boost::shared_ptr pannable = _route->pannable(); if (pannable) { - pannable->pan_azimuth_control->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_panner_azi_changed, this, false), ui_context()); - pannable->pan_width_control->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_panner_width_changed, this, false), ui_context()); + pannable->pan_azimuth_control->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_panner_azi_changed, this, false), ui_context()); + pannable->pan_width_control->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_panner_width_changed, this, false), ui_context()); } - _route->gain_control()->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_gain_changed, this, false), ui_context()); - _route->PropertyChanged.connect (route_connections, invalidator(), ui_bind (&Strip::notify_property_changed, this, _1), ui_context()); + _route->gain_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_gain_changed, this, false), ui_context()); + _route->PropertyChanged.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_property_changed, this, _1), ui_context()); boost::shared_ptr trk = boost::dynamic_pointer_cast(_route); if (trk) { _recenable->set_control (trk->rec_enable_control()); - trk->rec_enable_control()->Changed .connect(route_connections, invalidator(), ui_bind (&Strip::notify_record_enable_changed, this), ui_context()); + trk->rec_enable_control()->Changed .connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_record_enable_changed, this), ui_context()); } @@ -192,8 +189,8 @@ Strip::set_route (boost::shared_ptr r, bool with_messages) // TODO this works when a currently-banked route is made inactive, but not // when a route is activated which should be currently banked. - _route->active_changed.connect (route_connections, invalidator(), ui_bind (&Strip::notify_active_changed, this), ui_context()); - _route->DropReferences.connect (route_connections, invalidator(), ui_bind (&Strip::notify_route_deleted, this), ui_context()); + _route->active_changed.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_active_changed, this), ui_context()); + _route->DropReferences.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_route_deleted, this), ui_context()); /* Update */ diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index c53ea0fdc0..5c6eb6d559 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -43,8 +43,6 @@ using ARDOUR::AutomationControl; #define ui_context() MackieControlProtocol::instance() /* a UICallback-derived object that specifies the event loop for signal handling */ #define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__)) -extern PBD::EventLoop::InvalidationRecord* __invalidator (sigc::trackable& trackable, const char*, int); -#define invalidator() __invalidator (*(MackieControlProtocol::instance()), __FILE__, __LINE__) // The MCU sysex header.4th byte Will be overwritten // when we get an incoming sysex that identifies @@ -208,7 +206,7 @@ Surface::setup_master () } _master_fader->set_control (m->gain_control()); - m->gain_control()->Changed.connect (*this, invalidator(), ui_bind (&Surface::master_gain_changed, this), ui_context()); + m->gain_control()->Changed.connect (*this, MISSING_INVALIDATOR, ui_bind (&Surface::master_gain_changed, this), ui_context()); } void @@ -796,8 +794,7 @@ Surface::gui_selection_changed (ARDOUR::RouteNotificationListPtr routes) void Surface::say_hello () { - /* wakey wakey */ - + /* wakeup for Mackie Control */ MidiByteArray wakeup (7, MIDI::sysex, 0x00, 0x00, 0x66, 0x14, 0x00, MIDI::eox); _port->write (wakeup); wakeup[4] = 0x15; /* wakup Mackie XT */ @@ -806,8 +803,6 @@ Surface::say_hello () _port->write (wakeup); wakeup[4] = 0x11; /* wakeup Logic Control XT */ _port->write (wakeup); - - zero_all (); } void diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index a76943156c..0c9f4746ad 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -73,7 +73,7 @@ static void error_callback(int, const char *, const char *) #endif OSC::OSC (Session& s, uint32_t port) - : ControlProtocol (s, "OSC", this) + : ControlProtocol (s, "OSC") , AbstractUI ("osc") , _port(port) { diff --git a/libs/surfaces/powermate/powermate.cc b/libs/surfaces/powermate/powermate.cc index 44db8741ac..0475603a51 100644 --- a/libs/surfaces/powermate/powermate.cc +++ b/libs/surfaces/powermate/powermate.cc @@ -91,7 +91,7 @@ int find_powermate(int mode) } PowermateControlProtocol::PowermateControlProtocol (Session& s) - : ControlProtocol (s, "powermate", 0 /* XXX need an event loop here */) + : ControlProtocol (s, "powermate") { }