From 0dd2fb557c95f15672345e6368a478d25898a4d1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 29 Dec 2010 17:52:32 +0000 Subject: Update mixer strip input/output button labels from the general JACK port connection / disconnection callback so that all changes are noticed. Fixes #3638. git-svn-id: svn://localhost/ardour2/branches/3.0@8368 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/mixer_strip.cc | 25 +++++++++++++------------ gtk2_ardour/mixer_strip.h | 4 +--- libs/ardour/ardour/audioengine.h | 7 +++++-- libs/ardour/ardour/io.h | 2 ++ libs/ardour/audioengine.cc | 24 ++++++++++++++++++++++-- libs/ardour/io.cc | 9 ++++++++- 6 files changed, 51 insertions(+), 20 deletions(-) diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 324f36cf91..7422d55407 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -341,6 +341,10 @@ MixerStrip::init () set_flags (get_flags() | Gtk::CAN_FOCUS); SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io)); + + AudioEngine::instance()->PortConnectedOrDisconnected.connect ( + *this, invalidator (*this), boost::bind (&MixerStrip::port_connected_or_disconnected, this, _1, _2), gui_context () + ); } MixerStrip::~MixerStrip () @@ -460,8 +464,6 @@ MixerStrip::set_route (boost::shared_ptr rt) _route->comment()); _route->meter_change.connect (route_connections, invalidator (*this), bind (&MixerStrip::meter_changed, this), gui_context()); - _route->input()->changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::input_changed, this, _1, _2), gui_context()); - _route->output()->changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::output_changed, this, _1, _2), gui_context()); _route->route_group_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::route_group_changed, this), gui_context()); if (_route->panner()) { @@ -1214,20 +1216,19 @@ MixerStrip::diskstream_changed () } void -MixerStrip::input_changed (IOChange /*change*/, void */*src*/) +MixerStrip::port_connected_or_disconnected (Port* a, Port* b) { - Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_input_display, this)); - set_width_enum (_width, this); -} + if (_route->input()->has_port (a) || _route->input()->has_port (b)) { + update_input_display (); + set_width_enum (_width, this); + } -void -MixerStrip::output_changed (IOChange /*change*/, void */*src*/) -{ - Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_output_display, this)); - set_width_enum (_width, this); + if (_route->output()->has_port (a) || _route->output()->has_port (b)) { + update_output_display (); + set_width_enum (_width, this); + } } - void MixerStrip::comment_editor_done_editing() { diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index bbebbcaf15..af7eeca654 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -218,9 +218,6 @@ class MixerStrip : public RouteUI, public Gtk::EventBox void new_send (); void show_send_controls (); - void input_changed (ARDOUR::IOChange, void *); - void output_changed (ARDOUR::IOChange, void *); - PBD::ScopedConnection panstate_connection; PBD::ScopedConnection panstyle_connection; void connect_to_pan (); @@ -279,6 +276,7 @@ class MixerStrip : public RouteUI, public Gtk::EventBox static int scrollbar_height; void update_io_button (boost::shared_ptr route, Width width, bool input_button); + void port_connected_or_disconnected (ARDOUR::Port *, ARDOUR::Port *); }; #endif /* __ardour_mixer_strip__ */ diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index a4eb68b1bb..390c0bbda6 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -245,8 +245,11 @@ _ the regular process() call to session->process() is not made. /** Emitted if a JACK port is registered or unregistered */ PBD::Signal0 PortRegisteredOrUnregistered; - /** Emitted if a JACK port is connected or disconnected */ - PBD::Signal0 PortConnectedOrDisconnected; + /** Emitted if a JACK port is connected or disconnected. + * The Port parameters are the ports being connected / disconnected, or 0 if they are not known to Ardour. + * The bool parameter is true if ports were connected, or false for disconnected. + */ + PBD::Signal3 PortConnectedOrDisconnected; std::string make_port_name_relative (std::string); std::string make_port_name_non_relative (std::string); diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index 94dbfadb04..8335225f3c 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -118,6 +118,8 @@ class IO : public SessionObject, public Latent PortSet& ports() { return _ports; } const PortSet& ports() const { return _ports; } + bool has_port (Port *) const; + Port *nth (uint32_t n) const { if (n < _ports.num_ports()) { return _ports.port(n); diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 683dbca422..b2241f5c2f 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -394,10 +394,30 @@ AudioEngine::_registration_callback (jack_port_id_t /*id*/, int /*reg*/, void* a } void -AudioEngine::_connect_callback (jack_port_id_t /*id_a*/, jack_port_id_t /*id_b*/, int /*conn*/, void* arg) +AudioEngine::_connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn, void* arg) { AudioEngine* ae = static_cast (arg); - ae->PortConnectedOrDisconnected (); /* EMIT SIGNAL */ + + GET_PRIVATE_JACK_POINTER (ae->_jack); + + jack_port_t* jack_port_a = jack_port_by_id (_priv_jack, id_a); + jack_port_t* jack_port_b = jack_port_by_id (_priv_jack, id_b); + + Port* port_a = 0; + Port* port_b = 0; + + boost::shared_ptr pr = ae->ports.reader (); + Ports::iterator i = pr->begin (); + while (i != pr->end() && (port_a == 0 || port_b == 0)) { + if (jack_port_a == (*i)->_jack_port) { + port_a = *i; + } else if (jack_port_b == (*i)->_jack_port) { + port_b = *i; + } + ++i; + } + + ae->PortConnectedOrDisconnected (port_a, port_b, conn == 0 ? false : true); /* EMIT SIGNAL */ } void diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index ced4508d7a..17a1da231b 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -162,7 +162,7 @@ IO::disconnect (Port* our_port, string other_port, void* src) if (other_port.length() == 0 || our_port == 0) { return 0; } - + { Glib::Mutex::Lock lm (io_lock); @@ -1612,3 +1612,10 @@ IO::physically_connected () const return false; } + +bool +IO::has_port (Port* p) const +{ + Glib::Mutex::Lock lm (io_lock); + return _ports.contains (p); +} -- cgit v1.2.3