summaryrefslogtreecommitdiff
path: root/libs/ardour/io.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-01-26 19:00:27 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-01-26 19:00:27 +0000
commite3b21111094556494993a711edf6fbc6f826a057 (patch)
tree116ea553f73149e28e0fec2a30acf968e0cbffbd /libs/ardour/io.cc
parent9b3aefec1b0da4b838ecc90df7080be539b2edba (diff)
add Port::PostDisconnect signal to allow objects other than the one being directly disconnected to act when disconnection happens. This turns out to be much easier than using the JACK port connect/disconnect callback
git-svn-id: svn://localhost/ardour2/branches/3.0@11355 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/io.cc')
-rw-r--r--libs/ardour/io.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index 2397c7ee06..3805d7ac83 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -69,6 +69,7 @@ IO::IO (Session& s, const string& name, Direction dir, DataType default_type)
, _default_type (default_type)
{
_active = true;
+ Port::PostDisconnect.connect_same_thread (*this, boost::bind (&IO::disconnect_check, this, _1, _2));
pending_state_node = 0;
setup_bundle ();
}
@@ -80,6 +81,7 @@ IO::IO (Session& s, const XMLNode& node, DataType dt)
{
_active = true;
pending_state_node = 0;
+ Port::PostDisconnect.connect_same_thread (*this, boost::bind (&IO::disconnect_check, this, _1, _2));
set_state (node, Stateful::loading_state_version);
setup_bundle ();
@@ -97,6 +99,31 @@ IO::~IO ()
}
void
+IO::disconnect_check (boost::shared_ptr<Port> a, boost::shared_ptr<Port> b)
+{
+ /* this could be called from within our own ::disconnect() method(s)
+ or from somewhere that operates directly on a port. so, we don't
+ know for sure if we can take this lock or not. if we fail,
+ we assume that its safely locked by our own ::disconnect().
+ */
+
+ Glib::Mutex::Lock tm (io_lock, Glib::TRY_LOCK);
+
+ if (tm.locked()) {
+ /* we took the lock, so we cannot be here from inside
+ * ::disconnect()
+ */
+ if (_ports.contains (a) || _ports.contains (b)) {
+ changed (IOChange (IOChange::ConnectionsChanged), this); /* EMIT SIGNAL */
+ }
+ } else {
+ /* we didn't get the lock, so assume that we're inside
+ * ::disconnect(), and it will call changed() appropriately.
+ */
+ }
+}
+
+void
IO::increment_port_buffer_offset (pframes_t offset)
{
/* io_lock, not taken: function must be called from Session::process() calltree */