X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shared%2Fmidi_device.cpp;h=0383ec20d921bd8166595a24f4fe6fe3201124a3;hb=5e77e932e6a5795882ecba1b3f62a26523863179;hp=9d77e218f5078f37b5aa3eeba8c9bb87d84a8226;hpb=7a702edcef2297bd19aef14ef5537a4fd6837607;p=nageru diff --git a/shared/midi_device.cpp b/shared/midi_device.cpp index 9d77e21..0383ec2 100644 --- a/shared/midi_device.cpp +++ b/shared/midi_device.cpp @@ -21,7 +21,7 @@ MIDIDevice::~MIDIDevice() const uint64_t one = 1; if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) { perror("write(should_quit_fd)"); - exit(1); + abort(); } midi_thread.join(); close(should_quit_fd); @@ -154,7 +154,6 @@ void MIDIDevice::handle_event(snd_seq_t *seq, snd_seq_event_t *event) return; } - lock_guard lock(mu); switch (event->type) { case SND_SEQ_EVENT_CONTROLLER: { receiver->controller_received(event->data.control.param, event->data.control.value); @@ -169,9 +168,11 @@ void MIDIDevice::handle_event(snd_seq_t *seq, snd_seq_event_t *event) receiver->note_on_received(event->data.note.note); break; } - case SND_SEQ_EVENT_PORT_START: + case SND_SEQ_EVENT_PORT_START: { + lock_guard lock(mu); subscribe_to_port_lock_held(seq, event->data.addr); break; + } case SND_SEQ_EVENT_PORT_EXIT: printf("MIDI port %d:%d went away.\n", event->data.addr.client, event->data.addr.port); break;