From bbb68514680909051c9af89f45573e6de706c372 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 13 Jan 2021 20:00:39 +0100 Subject: [PATCH] Subscribe to pretty-port name changes (surfaces) --- libs/surfaces/faderport/faderport.cc | 1 + libs/surfaces/faderport8/faderport8.cc | 1 + .../generic_midi/generic_midi_control_protocol.cc | 3 ++- .../generic_midi/generic_midi_control_protocol.h | 2 +- libs/surfaces/launch_control_xl/launch_control_xl.cc | 5 +++-- libs/surfaces/launch_control_xl/launch_control_xl.h | 2 +- libs/surfaces/push2/push2.cc | 10 ++++++---- libs/surfaces/push2/push2.h | 3 +-- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index eaed7bee1f..329d34b8be 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -110,6 +110,7 @@ FaderPort::FaderPort (Session& s) /* Catch port connections and disconnections */ ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&FaderPort::connection_handler, this, _1, _2, _3, _4, _5), this); + ARDOUR::AudioEngine::instance()->PortPrettyNameChanged.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&FaderPort::ConnectionChange, this), this); /* notify GUI */ buttons.insert (std::make_pair (Mute, Button (*this, _("Mute"), Mute, 21))); buttons.insert (std::make_pair (Solo, Button (*this, _("Solo"), Solo, 22))); diff --git a/libs/surfaces/faderport8/faderport8.cc b/libs/surfaces/faderport8/faderport8.cc index 53e7d3b64e..fce7179632 100644 --- a/libs/surfaces/faderport8/faderport8.cc +++ b/libs/surfaces/faderport8/faderport8.cc @@ -172,6 +172,7 @@ FaderPort8::FaderPort8 (Session& s) ); ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::connection_handler, this, _2, _4), this); + ARDOUR::AudioEngine::instance()->PortPrettyNameChanged.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::ConnectionChange, this), this); /* notify GUI */ ARDOUR::AudioEngine::instance()->Stopped.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::engine_reset, this), this); ARDOUR::Port::PortDrop.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::engine_reset, this), this); diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index 31e5383dcb..74665eb899 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -137,9 +137,10 @@ GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s) PresentationInfo::Change.connect (*this, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::reset_controllables, this), this); /* Catch port connections and disconnections (cross-thread) */ - ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, + ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::connection_handler, this, _1, _2, _3, _4, _5), this); + ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&GenericMidiControlProtocol::ConnectionChange, this), this); /* notify GUI */ reload_maps (); } diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.h b/libs/surfaces/generic_midi/generic_midi_control_protocol.h index 9fa5d99197..366d9f3e69 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.h +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.h @@ -183,7 +183,7 @@ private: int connection_state; bool connection_handler (boost::weak_ptr, std::string name1, boost::weak_ptr, std::string name2, bool yn); - PBD::ScopedConnection port_connection; + PBD::ScopedConnectionList port_connections; std::string _current_binding; uint32_t _bank_size; diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.cc b/libs/surfaces/launch_control_xl/launch_control_xl.cc index b7764ba7b0..325dcab6bd 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.cc +++ b/libs/surfaces/launch_control_xl/launch_control_xl.cc @@ -103,7 +103,8 @@ LaunchControlXL::LaunchControlXL (ARDOUR::Session& s) ports_acquire (); /* Catch port connections and disconnections */ - ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::connection_handler, this, _1, _2, _3, _4, _5), this); + ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::connection_handler, this, _1, _2, _3, _4, _5), this); + ARDOUR::AudioEngine::instance()->PortPrettyNameChanged.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::ConnectionChange, this), this); /* notify GUI */ session->RouteAdded.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::stripables_added, this), lcxl); session->vca_manager().VCAAdded.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&LaunchControlXL::stripables_added, this), lcxl); @@ -115,7 +116,7 @@ LaunchControlXL::~LaunchControlXL () /* do this before stopping the event loop, so that we don't get any notifications */ port_reg_connection.disconnect (); - port_connection.disconnect (); + port_connections.drop_connections (); session_connections.drop_connections (); stripable_connections.drop_connections (); diff --git a/libs/surfaces/launch_control_xl/launch_control_xl.h b/libs/surfaces/launch_control_xl/launch_control_xl.h index f8e0b1561a..fcae638d9d 100644 --- a/libs/surfaces/launch_control_xl/launch_control_xl.h +++ b/libs/surfaces/launch_control_xl/launch_control_xl.h @@ -640,7 +640,7 @@ private: bool connection_handler(boost::weak_ptr, std::string name1, boost::weak_ptr, std::string name2, bool yn); - PBD::ScopedConnection port_connection; + PBD::ScopedConnectionList port_connections; void connected(); /* GUI */ diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 9a619b0663..1c1536780d 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -125,10 +125,13 @@ Push2::Push2 (ARDOUR::Session& s) ports_acquire (); /* catch arrival and departure of Push2 itself */ - ARDOUR::AudioEngine::instance()->PortRegisteredOrUnregistered.connect (port_reg_connection, MISSING_INVALIDATOR, boost::bind (&Push2::port_registration_handler, this), this); + ARDOUR::AudioEngine::instance()->PortRegisteredOrUnregistered.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&Push2::port_registration_handler, this), this); /* Catch port connections and disconnections */ - ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&Push2::connection_handler, this, _1, _2, _3, _4, _5), this); + ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&Push2::connection_handler, this, _1, _2, _3, _4, _5), this); + + /* Catch name changes, notify GUI */ + ARDOUR::AudioEngine::instance()->PortPrettyNameChanged.connect (port_connections, MISSING_INVALIDATOR, boost::bind (&Push2::ConnectionChange, this), this); /* Push 2 ports might already be there */ port_registration_handler (); @@ -139,8 +142,7 @@ Push2::~Push2 () DEBUG_TRACE (DEBUG::Push2, "push2 control surface object being destroyed\n"); /* do this before stopping the event loop, so that we don't get any notifications */ - port_reg_connection.disconnect (); - port_connection.disconnect (); + port_connections.drop_connections (); stop_using_device (); device_release (); diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 9f65751f45..220753d409 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -549,7 +549,6 @@ class Push2 : public ARDOUR::ControlProtocol boost::weak_ptr current_pad_target; - PBD::ScopedConnection port_reg_connection; void port_registration_handler (); enum ConnectionState { @@ -559,7 +558,7 @@ class Push2 : public ARDOUR::ControlProtocol int connection_state; bool connection_handler (boost::weak_ptr, std::string name1, boost::weak_ptr, std::string name2, bool yn); - PBD::ScopedConnection port_connection; + PBD::ScopedConnectionList port_connections; void connected (); /* GUI */