#ifndef __midi_manager_h__
#define __midi_manager_h__
-#include <map>
-#include <vector>
+#include <list>
#include <string>
namespace MIDI {
+class MachineControl;
+
class Manager {
public:
~Manager ();
- void set_api_data(void* data) { api_data = data; }
-
/** Signal the start of an audio cycle.
* This MUST be called before any reading/writing for this cycle.
* Realtime safe.
*/
- void cycle_start(nframes_t nframes);
+ 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();
-
- Port *add_port (const XMLNode& node);
- int remove_port (Port*);
+ void cycle_end ();
- Port *port (std::string name);
+ 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; }
- size_t nports () { return ports_by_device.size(); }
-
- /* 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 (std::string);
- 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;
}
- int get_known_ports (std::vector<PortSet>&);
+ 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* api_data;
-
- 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