fix: split main command queue into per-source SPSC queues

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-09 23:32:21 +00:00
parent de0389e144
commit 7edd95d06e
3 changed files with 57 additions and 16 deletions

View File

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