summaryrefslogtreecommitdiff
path: root/libs/ardour/port.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/port.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/port.cc')
-rw-r--r--libs/ardour/port.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/libs/ardour/port.cc b/libs/ardour/port.cc
index d6c959df30..45874bba8d 100644
--- a/libs/ardour/port.cc
+++ b/libs/ardour/port.cc
@@ -39,6 +39,8 @@ using namespace std;
using namespace ARDOUR;
using namespace PBD;
+PBD::Signal2<void,boost::shared_ptr<Port>, boost::shared_ptr<Port> > Port::PostDisconnect;
+
AudioEngine* Port::_engine = 0;
bool Port::_connecting_blocked = false;
pframes_t Port::_global_port_buffer_offset = 0;
@@ -94,6 +96,11 @@ Port::disconnect_all ()
jack_port_disconnect (_engine->jack(), _jack_port);
_connections.clear ();
+ /* a cheaper, less hacky way to do boost::shared_from_this() ...
+ */
+ boost::shared_ptr<Port> pself = _engine->get_port_by_name (name());
+ PostDisconnect (pself, boost::shared_ptr<Port>()); // emit signal
+
return 0;
}
@@ -168,21 +175,34 @@ Port::connect (std::string const & other)
int
Port::disconnect (std::string const & other)
{
- std::string const other_shrt = _engine->make_port_name_non_relative (other);
- std::string const this_shrt = _engine->make_port_name_non_relative (_name);
+ std::string const other_fullname = _engine->make_port_name_non_relative (other);
+ std::string const this_fullname = _engine->make_port_name_non_relative (_name);
int r = 0;
if (sends_output ()) {
- r = jack_disconnect (_engine->jack (), this_shrt.c_str (), other_shrt.c_str ());
+ r = jack_disconnect (_engine->jack (), this_fullname.c_str (), other_fullname.c_str ());
} else {
- r = jack_disconnect (_engine->jack (), other_shrt.c_str (), this_shrt.c_str ());
+ r = jack_disconnect (_engine->jack (), other_fullname.c_str (), this_fullname.c_str ());
}
if (r == 0) {
_connections.erase (other);
}
+ /* a cheaper, less hacky way to do boost::shared_from_this() ...
+ */
+ boost::shared_ptr<Port> pself = _engine->get_port_by_name (name());
+ boost::shared_ptr<Port> pother = _engine->get_port_by_name (other);
+
+ if (pself && pother) {
+ /* Disconnecting from another Ardour port: need to allow
+ a check on whether this may affect anything that we
+ need to know about.
+ */
+ PostDisconnect (pself, pother); // emit signal
+ }
+
return r;
}