2 Copyright (C) 1998-99 Paul Barton-Davis
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "pbd/error.h"
24 #include "pbd/convert.h"
26 #include "midi++/types.h"
27 #include "midi++/factory.h"
28 #include "midi++/fifomidi.h"
31 #include "midi++/jack.h"
33 std::string MIDI::JACK_MidiPort::typestring = "jack";
34 #endif // WITH_JACK_MIDI
36 std::string MIDI::FIFO_MidiPort::typestring = "fifo";
39 #include "midi++/alsa_sequencer.h"
40 #include "midi++/alsa_rawmidi.h"
42 std::string MIDI::ALSA_SequencerMidiPort::typestring = "alsa/sequencer";
43 std::string MIDI::ALSA_RawMidiPort::typestring = "alsa/raw";
48 #include "midi++/coremidi_midiport.h"
50 std::string MIDI::CoreMidi_MidiPort::typestring = "coremidi";
52 #endif // WITH_COREMIDI
58 // FIXME: void* data pointer, filthy
60 PortFactory::create_port (const XMLNode& node, void* data)
63 Port::Descriptor desc (node);
70 port = new JACK_MidiPort (node, (jack_client_t*) data);
72 #endif // WITH_JACK_MIDI
75 case Port::ALSA_RawMidi:
76 port = new ALSA_RawMidiPort (node);
79 case Port::ALSA_Sequencer:
80 port = new ALSA_SequencerMidiPort (node);
85 case Port::CoreMidi_MidiPort:
86 port = new CoreMidi_MidiPort (node);
88 #endif // WITH_COREMIDI
91 port = new FIFO_MidiPort (node);
102 PortFactory::ignore_duplicate_devices (Port::Type type)
108 case Port::ALSA_Sequencer:
114 case Port::CoreMidi_MidiPort:
117 #endif // WITH_COREMIDI
127 #if defined (WITH_ALSA) || defined (WITH_COREMIDI)
128 PortFactory::get_known_ports (vector<PortSet>& ports)
130 PortFactory::get_known_ports (vector<PortSet>&)
135 n += ALSA_SequencerMidiPort::discover (ports);
139 n += CoreMidi_MidiPort::discover (ports);
140 #endif // WITH_COREMIDI
146 PortFactory::default_port_type ()
148 #ifdef WITH_JACK_MIDI
153 return "alsa/sequencer";
158 #endif // WITH_COREMIDI
160 PBD::fatal << "programming error: no default port type defined in midifactory.cc" << endmsg;
166 PortFactory::string_to_type (const string& xtype)
170 } else if (strings_equal_ignore_case (xtype, ALSA_RawMidiPort::typestring)) {
171 return Port::ALSA_RawMidi;
172 } else if (strings_equal_ignore_case (xtype, ALSA_SequencerMidiPort::typestring)) {
173 return Port::ALSA_Sequencer;
176 } else if (strings_equal_ignore_case (xtype, CoreMidi_MidiPort::typestring)) {
177 return Port::CoreMidi_MidiPort;
179 } else if (strings_equal_ignore_case (xtype, FIFO_MidiPort::typestring)) {
181 #ifdef WITH_JACK_MIDI
182 } else if (strings_equal_ignore_case (xtype, JACK_MidiPort::typestring)) {
183 return Port::JACK_Midi;
187 return Port::Unknown;
191 PortFactory::mode_to_string (int mode)
193 if (mode == O_RDONLY) {
195 } else if (mode == O_WRONLY) {
203 PortFactory::string_to_mode (const string& str)
205 if (strings_equal_ignore_case (str, "output") || strings_equal_ignore_case (str, "out")) {
207 } else if (strings_equal_ignore_case (str, "input") || strings_equal_ignore_case (str, "in")) {