part two of: don't crash during startup with no config files when trying to use a...
[ardour2.git] / libs / midi++2 / midi++ / manager.h
blob915f650c9dddd4295a32549d5ba4b912bb439ea9
1 /*
2 Copyright (C) 1998 Paul Barton-Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __midi_manager_h__
21 #define __midi_manager_h__
23 #include <list>
25 #include <string>
27 #include "midi++/types.h"
28 #include "midi++/port.h"
30 namespace MIDI {
32 class MachineControl;
34 class Manager {
35 public:
36 ~Manager ();
38 /** Signal the start of an audio cycle.
39 * This MUST be called before any reading/writing for this cycle.
40 * Realtime safe.
42 void cycle_start(nframes_t nframes);
44 /** Signal the end of an audio cycle.
45 * This signifies that the cycle began with @ref cycle_start has ended.
46 * This MUST be called at the end of each cycle.
47 * Realtime safe.
49 void cycle_end();
51 MachineControl* mmc () const { return _mmc; }
52 Port *mtc_input_port() const { return _mtc_input_port; }
53 Port *mtc_output_port() const { return _mtc_output_port; }
54 Port *midi_input_port() const { return _midi_input_port; }
55 Port *midi_output_port() const { return _midi_output_port; }
56 Port *midi_clock_input_port() const { return _midi_clock_input_port; }
57 Port *midi_clock_output_port() const { return _midi_clock_output_port; }
59 Port* add_port (Port *);
61 Port* port (std::string const &);
63 void set_port_states (std::list<XMLNode*>);
65 typedef std::list<Port *> PortList;
67 const PortList& get_midi_ports() const { return _ports; }
69 static void create (jack_client_t* jack);
71 static Manager *instance () {
72 return theManager;
75 void reestablish (jack_client_t *);
76 void reconnect ();
78 PBD::Signal0<void> PortsChanged;
80 private:
81 /* This is a SINGLETON pattern */
83 Manager (jack_client_t *);
84 static Manager *theManager;
86 MIDI::MachineControl* _mmc;
87 MIDI::Port* _mtc_input_port;
88 MIDI::Port* _mtc_output_port;
89 MIDI::Port* _midi_input_port;
90 MIDI::Port* _midi_output_port;
91 MIDI::Port* _midi_clock_input_port;
92 MIDI::Port* _midi_clock_output_port;
94 std::list<Port*> _ports;
97 } // namespace MIDI
99 #endif // __midi_manager_h__