summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-03-06 23:41:15 +0100
committerRobin Gareus <robin@gareus.org>2019-03-06 23:41:15 +0100
commit8ccc45d44d03ecdcee13cfaaae49236d38647ed5 (patch)
treeeb8152f244a63dd54a90925f58611fe4ca00b08d /libs
parent210d03a47741373b1e531040550326214ab5e49e (diff)
Ardour/ALSA allow multiple MIDI devices with the same name
Diffstat (limited to 'libs')
-rw-r--r--libs/backends/alsa/alsa_audiobackend.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/libs/backends/alsa/alsa_audiobackend.cc b/libs/backends/alsa/alsa_audiobackend.cc
index 00c6940d7c..56fa82f24a 100644
--- a/libs/backends/alsa/alsa_audiobackend.cc
+++ b/libs/backends/alsa/alsa_audiobackend.cc
@@ -1644,7 +1644,12 @@ AlsaAudioBackend::register_system_midi_ports(const std::string device)
delete mout;
} else {
char tmp[64];
- snprintf(tmp, sizeof(tmp), "system:midi_playback_%u", elf_hash (i->first));
+ for (int x = 0; x < 10; ++x) {
+ snprintf(tmp, sizeof(tmp), "system:midi_playback_%x%d", elf_hash (i->first), x);
+ if (!find_port (tmp)) {
+ break;
+ }
+ }
PortHandle p = add_port(std::string(tmp), DataType::MIDI, static_cast<PortFlags>(IsInput | IsPhysical | IsTerminal));
if (!p) {
mout->stop();
@@ -1685,7 +1690,12 @@ AlsaAudioBackend::register_system_midi_ports(const std::string device)
delete midin;
} else {
char tmp[64];
- snprintf(tmp, sizeof(tmp), "system:midi_capture_%u", elf_hash (i->first));
+ for (int x = 0; x < 10; ++x) {
+ snprintf(tmp, sizeof(tmp), "system:midi_capture_%x%d", elf_hash (i->first), x);
+ if (!find_port (tmp)) {
+ break;
+ }
+ }
PortHandle p = add_port(std::string(tmp), DataType::MIDI, static_cast<PortFlags>(IsOutput | IsPhysical | IsTerminal));
if (!p) {
midin->stop();