refactor: improve TUI polling, FIFO reliability, and add stress tests

This commit is contained in:
Loic Coenen
2026-05-23 12:29:13 +00:00
committed by Loic Coenen (aider)
parent 7c289e1496
commit d6bd31fed5
6 changed files with 418 additions and 122 deletions

View File

@@ -4,6 +4,7 @@
#include <stdatomic.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
/* Helper: zero a scene and set its state to IDLE */
void init_scene(scene_t *sc) {
@@ -14,8 +15,9 @@ void init_scene(scene_t *sc) {
void channel_add(jack_client_t *client, int idx) {
char in_name[64], out_name[64];
snprintf(in_name, sizeof(in_name), "channel%d_input", next_channel_id);
snprintf(out_name, sizeof(out_name), "channel%d_output", next_channel_id);
pid_t pid = getpid();
snprintf(in_name, sizeof(in_name), "ch%din_%d", next_channel_id, (int)pid);
snprintf(out_name, sizeof(out_name), "ch%dout_%d", next_channel_id, (int)pid);
/* Always register audio ports (needed for pass-through even for MIDI
* channels?) */
@@ -34,10 +36,10 @@ void channel_add(jack_client_t *client, int idx) {
/* If this is a MIDI channel, register MIDI ports */
if (channels[idx].type == CHANNEL_MIDI) {
char midi_in_name[64], midi_out_name[64];
snprintf(midi_in_name, sizeof(midi_in_name), "channel%d_midi_in",
next_channel_id);
snprintf(midi_out_name, sizeof(midi_out_name), "channel%d_midi_out",
next_channel_id);
snprintf(midi_in_name, sizeof(midi_in_name), "ch%dmidiin_%d",
next_channel_id, (int)pid);
snprintf(midi_out_name, sizeof(midi_out_name), "ch%dmidiout_%d",
next_channel_id, (int)pid);
channels[idx].midi_in = jack_port_register(
client, midi_in_name, JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0);
channels[idx].midi_out = jack_port_register(