don't actually use a method from libardourcp inside libardour; use a PBD::Signal...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 12 May 2017 16:49:09 +0000 (17:49 +0100)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 12 May 2017 16:49:09 +0000 (17:49 +0100)
libs/ardour/ardour/control_protocol_manager.h
libs/ardour/control_protocol_manager.cc
libs/surfaces/control_protocol/control_protocol.cc
libs/surfaces/control_protocol/control_protocol/control_protocol.h

index c8370e03a6f292851b690d8be43291f59433ca05..1fa8af13efbc2d577fb8d61b84ea8370c95e55e2 100644 (file)
@@ -84,6 +84,7 @@ class LIBARDOUR_API ControlProtocolManager : public PBD::Stateful, public ARDOUR
         PBD::Signal1<void,ControlProtocolInfo*> ProtocolStatusChange;
 
         void stripable_selection_changed (ARDOUR::StripableNotificationListPtr);
+        static PBD::Signal1<void,ARDOUR::StripableNotificationListPtr> StripableSelectionChanged;
 
   private:
        ControlProtocolManager ();
index 338ea816f23a992d00bfb7b194aa80a8b14f3aa8..a84ee9eb6e0eedf79f46c7bf610ca57bba263e8f 100644 (file)
@@ -42,7 +42,7 @@ using namespace PBD;
 
 ControlProtocolManager* ControlProtocolManager::_instance = 0;
 const string ControlProtocolManager::state_node_name = X_("ControlProtocols");
-
+PBD::Signal1<void,StripableNotificationListPtr> ControlProtocolManager::StripableSelectionChanged;
 
 ControlProtocolInfo::~ControlProtocolInfo ()
 {
@@ -566,7 +566,7 @@ ControlProtocolManager::stripable_selection_changed (StripableNotificationListPt
        */
 
        DEBUG_TRACE (DEBUG::Selection, string_compose ("Surface manager: selection changed, now %1 stripables\n", sp ? sp->size() : -1));
-       ControlProtocol::notify_stripable_selection_changed (sp);
+       StripableSelectionChanged (sp); /* EMIT SIGNAL */
 
        /* now give each protocol the chance to respond to the selection change
         */
index c2589d24e3b3166834d0ebefea5995ad60231e16..e094e9b6cc4a723c3410d4586962cb54bd812771 100644 (file)
@@ -21,6 +21,7 @@
 #include "pbd/convert.h"
 #include "pbd/error.h"
 
+#include "ardour/control_protocol_manager.h"
 #include "ardour/gain_control.h"
 #include "ardour/session.h"
 #include "ardour/record_enable_control.h"
@@ -60,6 +61,8 @@ Glib::Threads::Mutex ControlProtocol::special_stripable_mutex;
 boost::weak_ptr<Stripable> ControlProtocol::_first_selected_stripable;
 boost::weak_ptr<Stripable> ControlProtocol::_leftmost_mixer_stripable;
 StripableNotificationList ControlProtocol::_last_selected;
+PBD::ScopedConnection ControlProtocol::selection_connection;
+bool ControlProtocol::selection_connected = false;
 
 const std::string ControlProtocol::state_node_name ("Protocol");
 
@@ -68,6 +71,11 @@ ControlProtocol::ControlProtocol (Session& s, string str)
        , _name (str)
        , _active (false)
 {
+       if (!selection_connected) {
+               /* this is all static, connect it only once (and early), for all ControlProtocols */
+               ControlProtocolManager::StripableSelectionChanged.connect_same_thread (selection_connection, boost::bind (&ControlProtocol::notify_stripable_selection_changed, _1));
+               selection_connected = true;
+       }
 }
 
 ControlProtocol::~ControlProtocol ()
index ff5cd314fa604e333e1882a23301d81d8b17a2b2..0068cd6b66de33fc045d07739b7df272a1ff872a 100644 (file)
@@ -158,6 +158,8 @@ class LIBCONTROLCP_API ControlProtocol : public PBD::Stateful, public PBD::Scope
         static boost::weak_ptr<ARDOUR::Stripable> _leftmost_mixer_stripable;
         static boost::weak_ptr<ARDOUR::Stripable> _first_selected_stripable;
         static StripableNotificationList _last_selected;
+        static PBD::ScopedConnection selection_connection;
+        static bool selection_connected;
 };
 
 extern "C" {