fix: defer port unregistration to avoid race condition in channel removal

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-09 10:00:33 +00:00
parent c0a0a6e968
commit b0dda3d8ed
2 changed files with 19 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ void channel_add(jack_client_t *client, int idx)
if (!channels[idx].audio_in || !channels[idx].audio_out) {
fprintf(stderr, "Failed to register ports for channel %d\n", next_channel_id);
/* Do NOT mark channel active process loop will skip it */
channels[idx].active = 0;
atomic_store(&channels[idx].active, 0);
return;
}
@@ -36,8 +36,7 @@ void channel_add(jack_client_t *client, int idx)
void channel_remove(jack_client_t *client, int idx)
{
jack_port_unregister(client, channels[idx].audio_in);
jack_port_unregister(client, channels[idx].audio_out);
(void)client;
atomic_store(&channels[idx].active, 0);
channel_count--;
}