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);
// The sequencer object is now ready to be used from other threads.
{
- lock_guard<mutex> lock(mu);
+ lock_guard<recursive_mutex> lock(mu);
alsa_seq = seq;
alsa_queue_id = queue_id;
}
while (snd_seq_query_next_port(seq, pinfo) >= 0) {
constexpr int mask = SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ;
if ((snd_seq_port_info_get_capability(pinfo) & mask) == mask) {
- lock_guard<mutex> lock(mu);
+ lock_guard<recursive_mutex> lock(mu);
subscribe_to_port_lock_held(seq, *snd_seq_port_info_get_addr(pinfo));
}
}
return;
}
- lock_guard<mutex> lock(mu);
switch (event->type) {
case SND_SEQ_EVENT_CONTROLLER: {
receiver->controller_received(event->data.control.param, event->data.control.value);
receiver->note_on_received(event->data.note.note);
break;
}
- case SND_SEQ_EVENT_PORT_START:
+ case SND_SEQ_EVENT_PORT_START: {
+ lock_guard<recursive_mutex> 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;