#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/message.h>
#include <google/protobuf/text_format.h>
+#include <pthread.h>
#include <poll.h>
#include <stdint.h>
#include <stdio.h>
void MIDIMapper::thread_func()
{
+ pthread_setname_np(pthread_self(), "MIDIMapper");
+
snd_seq_t *seq;
int err;
if (err < 0) {
if (err == -EINTR) continue;
if (err == -EAGAIN) break;
+ if (err == -ENOSPC) {
+ fprintf(stderr, "snd_seq_event_input: Some events were lost.\n");
+ continue;
+ }
fprintf(stderr, "snd_seq_event_input: %s\n", snd_strerror(err));
return;
}
void MIDIMapper::subscribe_to_port_lock_held(snd_seq_t *seq, const snd_seq_addr_t &addr)
{
- // Client 0 is basically the system; ignore it.
- if (addr.client == 0) {
+ // Client 0 (SNDRV_SEQ_CLIENT_SYSTEM) is basically the system; ignore it.
+ // MIDI through (SNDRV_SEQ_CLIENT_DUMMY) echoes back what we give it, so ignore that, too.
+ if (addr.client == 0 || addr.client == 14) {
+ return;
+ }
+
+ // Don't listen to ourselves.
+ if (addr.client == snd_seq_client_id(seq)) {
return;
}