13
0

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
This commit is contained in:
Carl Hetherington 2011-09-26 20:35:16 +00:00
parent d6112f1213
commit a7dc433498
3 changed files with 31 additions and 2 deletions

View File

@ -76,6 +76,16 @@ Manager::add_port (Port* p)
return 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)
{

View File

@ -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 &);

View File

@ -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