From de0389e1447931bb40ac09eb233e432f4356cd69 Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Sat, 9 May 2026 23:12:53 +0000 Subject: [PATCH] feat: remove MIDI-driven add/remove channel commands to fix SPSC race Co-authored-by: aider (deepseek/deepseek-reasoner) --- src/midi.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/midi.c b/src/midi.c index f1f3957..a9ac6dc 100644 --- a/src/midi.c +++ b/src/midi.c @@ -40,16 +40,10 @@ void midi_handle_events(void *port_buffer, jack_nframes_t nframes) { queue_push(&cmd_queue, cmd); } else { switch (note) { - case 60: - { - command_t cmd = { .type = CMD_ADD_CHANNEL, .channel = -1, .data = 0 }; - queue_push(&cmd_queue_main, cmd); - } break; - case 61: - { - command_t cmd = { .type = CMD_REMOVE_CHANNEL, .channel = -1, .data = 0 }; - queue_push(&cmd_queue_main, cmd); - } break; + case 60: /* add channel not rt‑safe, moved to FIFO pipe */ + case 61: /* remove channel not rt‑safe, moved to FIFO pipe */ + /* no operation here */ + break; case 62: { int bch = atomic_load(&bind_channel); @@ -75,16 +69,10 @@ void midi_handle_events(void *port_buffer, jack_nframes_t nframes) { command_t cmd = { .type = CMD_CYCLE, .channel = 0, .data = 0 }; queue_push(&cmd_queue, cmd); } break; - case 60: - { - command_t cmd = { .type = CMD_ADD_CHANNEL, .channel = -1, .data = 0 }; - queue_push(&cmd_queue_main, cmd); - } break; - case 61: - { - command_t cmd = { .type = CMD_REMOVE_CHANNEL, .channel = -1, .data = 0 }; - queue_push(&cmd_queue_main, cmd); - } break; + case 60: /* add channel not rt‑safe, moved to FIFO pipe */ + case 61: /* remove channel not rt‑safe, moved to FIFO pipe */ + /* no operation here */ + break; default: break; }