X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=midi_mapper.cpp;h=42ad1e5e2a00f3e29d43459e77b41ff1b90fbe33;hb=e284d1c7a2e18ee7e4aea082c4a57a3504a0f5e8;hp=d03f38211e524a2fcb85b70c96cddc4c958b46d9;hpb=71480f2d1cd96c1ca5b2888f82bf33d290d60228;p=nageru diff --git a/midi_mapper.cpp b/midi_mapper.cpp index d03f382..42ad1e5 100644 --- a/midi_mapper.cpp +++ b/midi_mapper.cpp @@ -232,6 +232,10 @@ void MIDIMapper::thread_func() 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; } @@ -386,8 +390,14 @@ void MIDIMapper::handle_event(snd_seq_t *seq, snd_seq_event_t *event) 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; }