diff options
author | Robin Gareus <robin@gareus.org> | 2016-04-17 18:36:40 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-04-17 18:36:40 +0200 |
commit | 81faa3b420303eec2ca0e3a10e188ac948464099 (patch) | |
tree | 65a2dedfad8f68a50dc7178ce8d13c60e018018e /libs | |
parent | 10bffda8107082afae440924ee23508755130445 (diff) |
notify IO about port disconnection due to port removal
[Jack] Ports can be deleted without being disconnected first.
the IO Object does not catch that condition.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/port.h | 6 | ||||
-rw-r--r-- | libs/ardour/port.cc | 27 |
2 files changed, 29 insertions, 4 deletions
diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h index 4b6188fce4..9f9a4d88df 100644 --- a/libs/ardour/ardour/port.h +++ b/libs/ardour/ardour/port.h @@ -169,8 +169,10 @@ private: */ std::set<std::string> _connections; - void drop (); - PBD::ScopedConnection drop_connection; + void port_connected_or_disconnected (boost::weak_ptr<Port>, boost::weak_ptr<Port>, bool); + void drop (); + PBD::ScopedConnection drop_connection; + PBD::ScopedConnection engine_connection; }; } diff --git a/libs/ardour/port.cc b/libs/ardour/port.cc index a64d617eba..dcb3e2ff4a 100644 --- a/libs/ardour/port.cc +++ b/libs/ardour/port.cc @@ -75,6 +75,8 @@ Port::Port (std::string const & n, DataType t, PortFlags f) } PortDrop.connect_same_thread (drop_connection, boost::bind (&Port::drop, this)); + port_manager->PortConnectedOrDisconnected.connect_same_thread (engine_connection, + boost::bind (&Port::port_connected_or_disconnected, this, _1, _3, _5)); } /** Port destructor */ @@ -126,6 +128,26 @@ Port::drop () } } +void +Port::port_connected_or_disconnected (boost::weak_ptr<Port> w0, boost::weak_ptr<Port> w1, bool con) +{ + if (con) { + /* we're only interested in disconnect */ + return; + } + boost::shared_ptr<Port> p0 = w0.lock (); + boost::shared_ptr<Port> p1 = w1.lock (); + /* a cheaper, less hacky way to do boost::shared_from_this() ... */ + boost::shared_ptr<Port> pself = AudioEngine::instance()->get_port_by_name (name()); + + if (p0 == pself) { + PostDisconnect (p0, p1); // emit signal + } + if (p1 == pself) { + PostDisconnect (p1, p0); // emit signal + } +} + /** @return true if this port is connected to anything */ bool Port::connected () const @@ -238,8 +260,7 @@ Port::disconnect (std::string const & other) _connections.erase (other); } - /* a cheaper, less hacky way to do boost::shared_from_this() ... - */ + /* a cheaper, less hacky way to do boost::shared_from_this() ... */ boost::shared_ptr<Port> pself = AudioEngine::instance()->get_port_by_name (name()); boost::shared_ptr<Port> pother = AudioEngine::instance()->get_port_by_name (other); @@ -478,6 +499,8 @@ Port::reestablish () reset (); + port_manager->PortConnectedOrDisconnected.connect_same_thread (engine_connection, + boost::bind (&Port::port_connected_or_disconnected, this, _1, _3, _5)); return 0; } |