2008-06-02 17:41:35 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 1998-99 Paul Barton-Davis
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "midi++/types.h"
|
|
|
|
#include "midi++/manager.h"
|
|
|
|
#include "midi++/channel.h"
|
2010-07-05 20:16:36 -04:00
|
|
|
#include "midi++/port.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace MIDI;
|
|
|
|
using namespace PBD;
|
|
|
|
|
|
|
|
Manager *Manager::theManager = 0;
|
|
|
|
|
|
|
|
Manager::Manager ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Manager::~Manager ()
|
|
|
|
{
|
2009-11-13 14:50:39 -05:00
|
|
|
for (PortList::iterator p = _ports.begin(); p != _ports.end(); ++p) {
|
|
|
|
delete *p;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (theManager == this) {
|
|
|
|
theManager = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Port *
|
2010-07-06 20:40:58 -04:00
|
|
|
Manager::add_port (Port* p)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2010-07-06 20:40:58 -04:00
|
|
|
_ports.push_back (p);
|
2009-12-08 22:05:14 -05:00
|
|
|
|
|
|
|
PortsChanged (); /* EMIT SIGNAL */
|
|
|
|
|
2010-07-06 20:40:58 -04:00
|
|
|
return p;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::cycle_start(nframes_t nframes)
|
|
|
|
{
|
2009-11-13 14:50:39 -05:00
|
|
|
for (PortList::iterator p = _ports.begin(); p != _ports.end(); ++p) {
|
|
|
|
(*p)->cycle_start (nframes);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::cycle_end()
|
|
|
|
{
|
2009-11-13 14:50:39 -05:00
|
|
|
for (PortList::iterator p = _ports.begin(); p != _ports.end(); ++p) {
|
|
|
|
(*p)->cycle_end ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-05 11:41:05 -04:00
|
|
|
/** Re-register ports that disappear on JACK shutdown */
|
|
|
|
void
|
|
|
|
Manager::reestablish (void* a)
|
|
|
|
{
|
|
|
|
for (PortList::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
|
|
|
|
(*p)->reestablish (a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Re-connect ports after a reestablish () */
|
|
|
|
void
|
|
|
|
Manager::reconnect ()
|
|
|
|
{
|
|
|
|
for (PortList::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
|
|
|
|
(*p)->reconnect ();
|
|
|
|
}
|
|
|
|
}
|
2010-07-06 20:40:58 -04:00
|
|
|
|
|
|
|
Port*
|
|
|
|
Manager::port (string const & n)
|
|
|
|
{
|
|
|
|
PortList::const_iterator p = _ports.begin();
|
|
|
|
while (p != _ports.end() && (*p)->name() != n) {
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p == _ports.end()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *p;
|
|
|
|
}
|