feat: remove MIDI-driven add/remove channel commands to fix SPSC race

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-09 23:12:53 +00:00
parent bd5fd59b7b
commit de0389e144

View File

@@ -40,16 +40,10 @@ void midi_handle_events(void *port_buffer, jack_nframes_t nframes) {
queue_push(&cmd_queue, cmd); queue_push(&cmd_queue, cmd);
} else { } else {
switch (note) { switch (note) {
case 60: case 60: /* add channel not rtsafe, moved to FIFO pipe */
{ case 61: /* remove channel not rtsafe, moved to FIFO pipe */
command_t cmd = { .type = CMD_ADD_CHANNEL, .channel = -1, .data = 0 }; /* no operation here */
queue_push(&cmd_queue_main, cmd); break;
} break;
case 61:
{
command_t cmd = { .type = CMD_REMOVE_CHANNEL, .channel = -1, .data = 0 };
queue_push(&cmd_queue_main, cmd);
} break;
case 62: case 62:
{ {
int bch = atomic_load(&bind_channel); 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 }; command_t cmd = { .type = CMD_CYCLE, .channel = 0, .data = 0 };
queue_push(&cmd_queue, cmd); queue_push(&cmd_queue, cmd);
} break; } break;
case 60: case 60: /* add channel not rtsafe, moved to FIFO pipe */
{ case 61: /* remove channel not rtsafe, moved to FIFO pipe */
command_t cmd = { .type = CMD_ADD_CHANNEL, .channel = -1, .data = 0 }; /* no operation here */
queue_push(&cmd_queue_main, cmd); break;
} break;
case 61:
{
command_t cmd = { .type = CMD_REMOVE_CHANNEL, .channel = -1, .data = 0 };
queue_push(&cmd_queue_main, cmd);
} break;
default: default:
break; break;
} }