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.
22 #include "pbd/error.h"
23 #include "pbd/convert.h"
25 #include "midi++/types.h"
26 #include "midi++/factory.h"
27 #include "midi++/fifomidi.h"
30 #include "midi++/jack.h"
32 std::string MIDI::JACK_MidiPort::typestring = "jack";
33 #endif // WITH_JACK_MIDI
35 std::string MIDI::FIFO_MidiPort::typestring = "fifo";
38 #include "midi++/alsa_sequencer.h"
39 #include "midi++/alsa_rawmidi.h"
41 std::string MIDI::ALSA_SequencerMidiPort::typestring = "alsa/sequencer";
42 std::string MIDI::ALSA_RawMidiPort::typestring = "alsa/raw";
47 #include "midi++/coremidi_midiport.h"
49 std::string MIDI::CoreMidi_MidiPort::typestring = "coremidi";
51 #endif // WITH_COREMIDI
57 // FIXME: void* data pointer, filthy
59 PortFactory::create_port (const XMLNode& node, void* data)
62 Port::Descriptor desc (node);
69 port = new JACK_MidiPort (node, (jack_client_t*) data);
71 #endif // WITH_JACK_MIDI
74 case Port::ALSA_RawMidi:
75 port = new ALSA_RawMidiPort (node);
78 case Port::ALSA_Sequencer:
79 port = new ALSA_SequencerMidiPort (node);
84 case Port::CoreMidi_MidiPort:
85 port = new CoreMidi_MidiPort (node);
87 #endif // WITH_COREMIDI
90 port = new FIFO_MidiPort (node);
101 PortFactory::ignore_duplicate_devices (Port::Type type)
107 case Port::ALSA_Sequencer:
113 case Port::CoreMidi_MidiPort:
116 #endif // WITH_COREMIDI
126 PortFactory::get_known_ports (vector<PortSet>& ports)
130 n += ALSA_SequencerMidiPort::discover (ports);
134 n += CoreMidi_MidiPort::discover (ports);
135 #endif // WITH_COREMIDI
141 PortFactory::default_port_type ()
143 #ifdef WITH_JACK_MIDI
148 return "alsa/sequencer";
153 #endif // WITH_COREMIDI
155 PBD::fatal << "programming error: no default port type defined in midifactory.cc" << endmsg;
161 PortFactory::string_to_type (const string& xtype)
165 } else if (strings_equal_ignore_case (xtype, ALSA_RawMidiPort::typestring)) {
166 return Port::ALSA_RawMidi;
167 } else if (strings_equal_ignore_case (xtype, ALSA_SequencerMidiPort::typestring)) {
168 return Port::ALSA_Sequencer;
171 } else if (strings_equal_ignore_case (xtype, CoreMidi_MidiPort::typestring)) {
172 return Port::CoreMidi_MidiPort;
174 } else if (strings_equal_ignore_case (xtype, FIFO_MidiPort::typestring)) {
176 #ifdef WITH_JACK_MIDI
177 } else if (strings_equal_ignore_case (xtype, JACK_MidiPort::typestring)) {
178 return Port::JACK_Midi;
182 return Port::Unknown;
186 PortFactory::mode_to_string (int mode)
188 if (mode == O_RDONLY) {
190 } else if (mode == O_WRONLY) {
198 PortFactory::string_to_mode (const string& str)
200 if (strings_equal_ignore_case (str, "output") || strings_equal_ignore_case (str, "out")) {
202 } else if (strings_equal_ignore_case (str, "input") || strings_equal_ignore_case (str, "in")) {