along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
*/
#ifndef __midi_manager_h__
#define __midi_manager_h__
-#include <map>
+#include <list>
+
#include <string>
-#include <midi++/types.h>
-#include <midi++/port.h>
+#include "midi++/types.h"
+#include "midi++/port.h"
namespace MIDI {
+class MachineControl;
+
class Manager {
public:
~Manager ();
- Port *add_port (PortRequest &);
- int remove_port (std::string port);
-
- Port *port (std::string name);
- Port *port (size_t number);
+ /** Signal the start of an audio cycle.
+ * This MUST be called before any reading/writing for this cycle.
+ * Realtime safe.
+ */
+ void cycle_start (pframes_t nframes);
+
+ /** Signal the end of an audio cycle.
+ * This signifies that the cycle began with @ref cycle_start has ended.
+ * This MUST be called at the end of each cycle.
+ * Realtime safe.
+ */
+ void cycle_end ();
- size_t nports () { return ports_by_device.size(); }
+ MachineControl* mmc () const { return _mmc; }
+ Port *mtc_input_port() const { return _mtc_input_port; }
+ Port *mtc_output_port() const { return _mtc_output_port; }
+ Port *midi_input_port() const { return _midi_input_port; }
+ Port *midi_output_port() const { return _midi_output_port; }
+ Port *midi_clock_input_port() const { return _midi_clock_input_port; }
+ Port *midi_clock_output_port() const { return _midi_clock_output_port; }
- /* defaults for clients who are not picky */
-
- Port *inputPort;
- Port *outputPort;
- channel_t inputChannelNumber;
- channel_t outputChannelNumber;
+ Port* add_port (Port *);
- int set_input_port (size_t port);
- int set_input_port (std::string);
- int set_output_port (size_t port);
- int set_output_port (std::string);
- int set_input_channel (channel_t);
- int set_output_channel (channel_t);
+ Port* port (std::string const &);
- int foreach_port (int (*func)(const Port &, size_t n, void *),
- void *arg);
+ void set_port_states (std::list<XMLNode*>);
- typedef std::map<std::string, Port *> PortMap;
+ typedef std::list<Port *> PortList;
- const PortMap& get_midi_ports() const { return ports_by_tag; }
+ const PortList& get_midi_ports() const { return _ports; }
+ static void create (jack_client_t* jack);
+
static Manager *instance () {
- if (theManager == 0) {
- theManager = new Manager;
- }
return theManager;
}
- static int parse_port_request (std::string str, Port::Type type);
+ void reestablish (jack_client_t *);
+ void reconnect ();
+
+ PBD::Signal0<void> PortsChanged;
private:
/* This is a SINGLETON pattern */
- Manager ();
-
+ Manager (jack_client_t *);
static Manager *theManager;
- PortMap ports_by_device; /* canonical */
- PortMap ports_by_tag; /* may contain duplicate Ports */
- void close_ports ();
+ MIDI::MachineControl* _mmc;
+ MIDI::Port* _mtc_input_port;
+ MIDI::Port* _mtc_output_port;
+ MIDI::Port* _midi_input_port;
+ MIDI::Port* _midi_output_port;
+ MIDI::Port* _midi_clock_input_port;
+ MIDI::Port* _midi_clock_output_port;
+
+ std::list<Port*> _ports;
};
} // namespace MIDI