diff options
Diffstat (limited to 'libs/ardour/io.cc')
-rw-r--r-- | libs/ardour/io.cc | 27 |
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 */ |