*/
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;
};
}
}
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 */
}
}
+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
_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);
reset ();
+ port_manager->PortConnectedOrDisconnected.connect_same_thread (engine_connection,
+ boost::bind (&Port::port_connected_or_disconnected, this, _1, _3, _5));
return 0;
}