summaryrefslogtreecommitdiff
path: root/libs/surfaces/mackie/surface_port.cc
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 /libs/surfaces/mackie/surface_port.cc
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
Diffstat (limited to 'libs/surfaces/mackie/surface_port.cc')
-rw-r--r--libs/surfaces/mackie/surface_port.cc22
1 files changed, 20 insertions, 2 deletions
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