fix: guard against NULL audio ports and defer channel activation until port registration succeeds

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-08 21:08:37 +00:00
parent 96295fdb4c
commit b73719e8bc
2 changed files with 19 additions and 8 deletions

View File

@@ -35,6 +35,12 @@ int process_callback(jack_nframes_t nframes, void *arg)
for (int c = 0; c < MAX_CHANNELS; c++) {
if (!channels[c].active) continue;
/* Guard against NULL ports (e.g. if port registration failed) */
if (!channels[c].audio_in || !channels[c].audio_out) {
fprintf(stderr, "WARN: channel %d has NULL audio port(s), skipping\n", c);
continue;
}
jack_default_audio_sample_t *in = (jack_default_audio_sample_t *)
jack_port_get_buffer(channels[c].audio_in, nframes);
jack_default_audio_sample_t *out = (jack_default_audio_sample_t *)