summaryrefslogtreecommitdiff
path: root/libs/midi++2
diff options
context:
space:
mode:
Diffstat (limited to 'libs/midi++2')
-rw-r--r--libs/midi++2/alsa_sequencer_midiport.cc16
-rw-r--r--libs/midi++2/coremidi_midiport.cc2
-rw-r--r--libs/midi++2/midi.cc2
-rw-r--r--libs/midi++2/midimanager.cc41
-rw-r--r--libs/midi++2/midiparser.cc2
-rw-r--r--libs/midi++2/mtc.cc5
6 files changed, 55 insertions, 13 deletions
diff --git a/libs/midi++2/alsa_sequencer_midiport.cc b/libs/midi++2/alsa_sequencer_midiport.cc
index 1c2a98bfa3..fc69099d0e 100644
--- a/libs/midi++2/alsa_sequencer_midiport.cc
+++ b/libs/midi++2/alsa_sequencer_midiport.cc
@@ -171,7 +171,7 @@ ALSA_SequencerMidiPort::create_ports (const Port::Descriptor& desc)
caps |= SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE;
if (desc.mode == O_RDONLY || desc.mode == O_RDWR)
caps |= SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ;
-
+
if (0 <= (err = snd_seq_create_simple_port (seq, desc.tag.c_str(), caps,
(SND_SEQ_PORT_TYPE_MIDI_GENERIC|
SND_SEQ_PORT_TYPE_SOFTWARE|
@@ -308,13 +308,17 @@ ALSA_SequencerMidiPort::get_connections (vector<SequencerPortAddress>& connectio
seq_addr.client = snd_seq_client_id (seq);
seq_addr.port = port_id;
snd_seq_query_subscribe_set_root(subs, &seq_addr);
-
+
while (snd_seq_query_port_subscribers(seq, subs) >= 0) {
- seq_addr = *snd_seq_query_subscribe_get_addr (subs);
-
- connections.push_back (SequencerPortAddress (seq_addr.client,
- seq_addr.port));
+ if (snd_seq_query_subscribe_get_time_real (subs)) {
+ /* interesting connection */
+
+ seq_addr = *snd_seq_query_subscribe_get_addr (subs);
+
+ connections.push_back (SequencerPortAddress (seq_addr.client,
+ seq_addr.port));
+ }
snd_seq_query_subscribe_set_index(subs, snd_seq_query_subscribe_get_index(subs) + 1);
}
diff --git a/libs/midi++2/coremidi_midiport.cc b/libs/midi++2/coremidi_midiport.cc
index 14020a6f35..9eacfc0cc3 100644
--- a/libs/midi++2/coremidi_midiport.cc
+++ b/libs/midi++2/coremidi_midiport.cc
@@ -122,7 +122,7 @@ void CoreMidi_MidiPort::read_proc (const MIDIPacketList *pktlist, void *refCon,
if (driver->firstrecv) {
driver->firstrecv = false;
- PBD::ThreadCreated (pthread_self(), "COREMIDI");
+ PBD::notify_gui_about_thread_creation (pthread_self(), "COREMIDI");
}
for (unsigned int i = 0; i < pktlist->numPackets; ++i) {
diff --git a/libs/midi++2/midi.cc b/libs/midi++2/midi.cc
index f612b4707a..89d74b1b31 100644
--- a/libs/midi++2/midi.cc
+++ b/libs/midi++2/midi.cc
@@ -19,8 +19,6 @@
*/
#include <cstring>
-#include <string>
-#include <cstring>
#include <cstdlib>
#include <midi++/types.h>
diff --git a/libs/midi++2/midimanager.cc b/libs/midi++2/midimanager.cc
index 8a358c3183..14c9d43793 100644
--- a/libs/midi++2/midimanager.cc
+++ b/libs/midi++2/midimanager.cc
@@ -70,6 +70,47 @@ Manager::add_port (const XMLNode& node)
PortMap::iterator existing;
pair<string, Port *> newpair;
+ /* do not allow multiple ports with the same tag. if attempted, just return the existing
+ port with the same tag. XXX this is really caused by the mess of setup_midi() being
+ called twice in Ardour, once in the global init() function and once after the user RC file
+ has been loaded (there may be extra ports in it).
+ */
+
+ if ((existing = ports_by_tag.find (desc.tag)) != ports_by_tag.end()) {
+
+ port = (*existing).second;
+
+ if (port->mode() == desc.mode) {
+
+ /* Same mode - reuse the port, and just
+ create a new tag entry.
+ */
+
+ newpair.first = desc.tag;
+ 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 ((desc.mode == O_RDWR && port->mode() != O_RDWR) ||
+ (desc.mode != O_RDWR && port->mode() == O_RDWR)) {
+ error << "MIDIManager: port tagged \""
+ << desc.tag
+ << "\" cannot be opened duplex and non-duplex"
+ << endmsg;
+ return 0;
+ }
+
+ /* modes must be different or complementary */
+ }
+
if (!PortFactory::ignore_duplicate_devices (desc.type)) {
if ((existing = ports_by_device.find (desc.device)) != ports_by_device.end()) {
diff --git a/libs/midi++2/midiparser.cc b/libs/midi++2/midiparser.cc
index 423e833d2c..4cbcd27694 100644
--- a/libs/midi++2/midiparser.cc
+++ b/libs/midi++2/midiparser.cc
@@ -24,7 +24,7 @@
#include <cstring>
#include <cstdlib>
#include <unistd.h>
-#include <string>
+#include <cstring>
#include <iostream>
#include <iterator>
diff --git a/libs/midi++2/mtc.cc b/libs/midi++2/mtc.cc
index 13f5221929..9d62c7354c 100644
--- a/libs/midi++2/mtc.cc
+++ b/libs/midi++2/mtc.cc
@@ -18,10 +18,9 @@
$Id$
*/
-#include <cstring>
#include <cstdlib>
#include <unistd.h>
-#include <string>
+#include <cstring>
#include <iostream>
#include <midi++/types.h>
@@ -51,7 +50,6 @@ Parser::possible_mtc (byte *sysex_buf, size_t msglen)
fake_mtc_time[3] = (sysex_buf[5] & 0x1f); // hours
_mtc_fps = MTC_FPS ((sysex_buf[5] & 0x60) >> 5); // fps
-
fake_mtc_time[4] = (byte) _mtc_fps;
/* wait for first quarter frame, which could indicate forwards
@@ -293,6 +291,7 @@ Parser::process_mtc_quarter_frame (byte *msg)
if (!_mtc_locked) {
_mtc_locked = true;
}
+
mtc_time (_mtc_time, false);
}
expected_mtc_quarter_frame_code = 0;