summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-09-26 20:35:16 +0000
committerCarl Hetherington <carl@carlh.net>2011-09-26 20:35:16 +0000
commita7dc433498d712b908c429761a4c3f9ea24ce440 (patch)
treec64400e690144c9136102fdf72160f2011d2fbb7
parentd6112f121313f6db8353e32c1339f84cd1e59608 (diff)
Delete MIDI port objects when the MackieControlProtocol is torn down, so that it can be recreated without attempting to create duplicate JACK port names. Should fix #3886.
git-svn-id: svn://localhost/ardour2/branches/3.0@10129 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/midi++2/manager.cc10
-rw-r--r--libs/midi++2/midi++/manager.h1
-rw-r--r--libs/surfaces/mackie/surface_port.cc22
3 files changed, 31 insertions, 2 deletions
diff --git a/libs/midi++2/manager.cc b/libs/midi++2/manager.cc
index 8aa89c7a99..b411a1ddad 100644
--- a/libs/midi++2/manager.cc
+++ b/libs/midi++2/manager.cc
@@ -77,6 +77,16 @@ Manager::add_port (Port* p)
}
void
+Manager::remove_port (Port* p)
+{
+ RCUWriter<PortList> writer (_ports);
+ boost::shared_ptr<PortList> pw = writer.get_copy ();
+ pw->remove (p);
+
+ PortsChanged (); /* EMIT SIGNAL */
+}
+
+void
Manager::cycle_start (pframes_t nframes)
{
boost::shared_ptr<PortList> pr = _ports.reader ();
diff --git a/libs/midi++2/midi++/manager.h b/libs/midi++2/midi++/manager.h
index 75b0cb4864..ecfd7a0111 100644
--- a/libs/midi++2/midi++/manager.h
+++ b/libs/midi++2/midi++/manager.h
@@ -59,6 +59,7 @@ class Manager {
Port *midi_clock_output_port() const { return _midi_clock_output_port; }
Port* add_port (Port *);
+ void remove_port (Port *);
Port* port (std::string const &);
diff --git a/libs/surfaces/mackie/surface_port.cc b/libs/surfaces/mackie/surface_port.cc
index 3e10fa7b36..031009cd3d 100644
--- a/libs/surfaces/mackie/surface_port.cc
+++ b/libs/surfaces/mackie/surface_port.cc
@@ -20,8 +20,9 @@
#include "mackie_control_exception.h"
#include "controls.h"
-#include <midi++/types.h>
-#include <midi++/port.h>
+#include "midi++/types.h"
+#include "midi++/port.h"
+#include "midi++/manager.h"
#include <sigc++/sigc++.h>
#include <boost/shared_array.hpp>
@@ -40,6 +41,10 @@ SurfacePort::SurfacePort()
{
}
+/** @param input_port Input MIDI::Port; this object takes responsibility for removing it from
+ * the MIDI::Manager and destroying it.
+ * @param output_port Output MIDI::Port; responsibility similarly taken.
+ */
SurfacePort::SurfacePort (MIDI::Port & input_port, MIDI::Port & output_port, int number)
: _input_port (&input_port), _output_port (&output_port), _number (number), _active (false)
{
@@ -53,6 +58,19 @@ SurfacePort::~SurfacePort()
// make sure another thread isn't reading or writing as we close the port
Glib::RecMutex::Lock lock( _rwlock );
_active = false;
+
+ MIDI::Manager* mm = MIDI::Manager::instance ();
+
+ if (_input_port) {
+ mm->remove_port (_input_port);
+ delete _input_port;
+ }
+
+ if (_output_port) {
+ mm->remove_port (_output_port);
+ delete _output_port;
+ }
+
#ifdef PORT_DEBUG
cout << "~SurfacePort::SurfacePort() finished" << endl;
#endif