summaryrefslogtreecommitdiff
path: root/libs/midi++2
diff options
context:
space:
mode:
Diffstat (limited to 'libs/midi++2')
-rw-r--r--libs/midi++2/SConscript2
-rw-r--r--libs/midi++2/midi++/factory.h5
-rw-r--r--libs/midi++2/midifactory.cc30
-rw-r--r--libs/midi++2/midimanager.cc64
4 files changed, 55 insertions, 46 deletions
diff --git a/libs/midi++2/SConscript b/libs/midi++2/SConscript
index 65d0882dce..477d49c6ca 100644
--- a/libs/midi++2/SConscript
+++ b/libs/midi++2/SConscript
@@ -51,7 +51,7 @@ elif env['SYSMIDI'] == 'CoreMIDI':
midi2.Append(CCFLAGS="-D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE")
midi2.Append(CCFLAGS="-DLIBSIGC_DISABLE_DEPRECATED")
-midi2.VersionBuild(['version.cc','midi++/version.h'], 'SConscript')
+midi2.VersionBuild(['version.cc','midi++/version.h'], [])
libmidi2 = midi2.SharedLibrary('midi++', [ sources, sysdep_src ])
diff --git a/libs/midi++2/midi++/factory.h b/libs/midi++2/midi++/factory.h
index e29d7543f8..1d5c7e0b30 100644
--- a/libs/midi++2/midi++/factory.h
+++ b/libs/midi++2/midi++/factory.h
@@ -30,9 +30,8 @@ namespace MIDI {
class PortFactory {
public:
Port *create_port (PortRequest &req, void* data);
-
- static void add_port_request (std::vector<PortRequest *> &reqs,
- const std::string &reqstr);
+
+ static bool ignore_duplicate_devices (Port::Type);
};
} // namespace MIDI
diff --git a/libs/midi++2/midifactory.cc b/libs/midi++2/midifactory.cc
index d8119e362e..de4a246bcf 100644
--- a/libs/midi++2/midifactory.cc
+++ b/libs/midi++2/midifactory.cc
@@ -89,20 +89,28 @@ PortFactory::create_port (PortRequest &req, void* data)
return port;
}
-void
-PortFactory::add_port_request (vector<PortRequest *> &reqs,
- const string &str)
-
+bool
+PortFactory::ignore_duplicate_devices (Port::Type type)
{
- PortRequest *req;
+ bool ret = false;
- req = new PortRequest;
- req->devname = strdup (str.c_str());
- req->tagname = strdup (str.c_str());
+ switch (type) {
+#ifdef WITH_ALSA
+ case Port::ALSA_Sequencer:
+ ret = true;
+ break;
+#endif // WITH_ALSA
- req->mode = O_RDWR;
- req->type = Port::ALSA_RawMidi;
+#if WITH_COREMIDI
+ case Port::CoreMidi_MidiPort:
+ ret = true;
+ break;
+#endif // WITH_COREMIDI
+
+ default:
+ break;
+ }
- reqs.push_back (req);
+ return ret;
}
diff --git a/libs/midi++2/midimanager.cc b/libs/midi++2/midimanager.cc
index bfe8f147b6..970674232d 100644
--- a/libs/midi++2/midimanager.cc
+++ b/libs/midi++2/midimanager.cc
@@ -66,41 +66,43 @@ Manager::add_port (PortRequest &req)
PortMap::iterator existing;
pair<string, Port *> newpair;
- if ((existing = ports_by_device.find (req.devname)) !=
- ports_by_device.end()) {
-
- port = (*existing).second;
- if (port->mode() == req.mode) {
+ if (!PortFactory::ignore_duplicate_devices (req.type)) {
+
+ if ((existing = ports_by_device.find (req.devname)) != ports_by_device.end()) {
+
+ port = (*existing).second;
+
+ if (port->mode() == req.mode) {
+
+ /* Same mode - reuse the port, and just
+ create a new tag entry.
+ */
+
+ newpair.first = req.tagname;
+ newpair.second = port;
+
+ ports_by_tag.insert (newpair);
+ return port;
+ }
- /* Same mode - reuse the port, and just
- create a new tag entry.
+ /* If the existing is duplex, and this request
+ is not, then fail, because most drivers won't
+ allow opening twice with duplex and non-duplex
+ operation.
*/
-
- newpair.first = req.tagname;
- newpair.second = port;
-
- ports_by_tag.insert (newpair);
- return port;
- }
-
- /* If the existing is duplex, and this request
- is not, then fail, because most drivers won't
- allow opening twice with duplex and non-duplex
- operation.
- */
-
- if ((req.mode == O_RDWR && port->mode() != O_RDWR) ||
- (req.mode != O_RDWR && port->mode() == O_RDWR)) {
- error << "MIDIManager: port tagged \""
- << req.tagname
- << "\" cannot be opened duplex and non-duplex"
- << endmsg;
- return 0;
+
+ if ((req.mode == O_RDWR && port->mode() != O_RDWR) ||
+ (req.mode != O_RDWR && port->mode() == O_RDWR)) {
+ error << "MIDIManager: port tagged \""
+ << req.tagname
+ << "\" cannot be opened duplex and non-duplex"
+ << endmsg;
+ return 0;
+ }
+
+ /* modes must be different or complementary */
}
-
- /* modes must be different or complementary */
}
-
port = factory.create_port (req, api_data);
if (port == 0) {