From 8aaa9abadb89fb3af567fb31d85c312e86fc9ad7 Mon Sep 17 00:00:00 2001 From: Shawn Date: Wed, 17 Jun 2026 17:17:36 -0400 Subject: [PATCH] fix: also sync AudioConfig.period/rate before JACK restart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two-part fix for NAM audio dying after buffer change: 1. NAM block size sync moved BEFORE jack_client.start() so the NAM subprocess is reloaded before the process callback fires. 2. AudioConfig.period/rate must be updated BEFORE start_jack() reads latency_profile. Otherwise the stale boot-time override period stomps on the LATENCY_PROFILES entry set by the POST handler, causing JACK to start at the wrong period while NAM is at the new period — permanent JACK/NAM block size mismatch. Both bugs together: user changes buffer, JACK restarts with wrong period due to stale override, NAM subprocess gets mismatched pipe bytes, returns DI (direct input) for every subsequent callback. --- src/web/server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/web/server.py b/src/web/server.py index 6e4a69e..18a7c15 100644 --- a/src/web/server.py +++ b/src/web/server.py @@ -1491,6 +1491,12 @@ class WebServer: # Update LATENCY_PROFILES with custom entry so latency_profile resolves it LATENCY_PROFILES[effective_key] = target_profile + # Sync AudioConfig overrides BEFORE JACK restart so latency_profile + # used by start_jack() returns the correct period. Without this, the + # stale boot-time self.period override stomps on the LATENCY_PROFILES entry. + audio_sys.config.period = target_profile["period"] + audio_sys.config.rate = target_profile["rate"] + # ── Kill JACK server FIRST (breaks any client deadlock) ── # jack.Client.deactivate() is a synchronous JACK protocol call # that blocks until the RT callback thread acknowledges. If the