fix: also sync AudioConfig.period/rate before JACK restart

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.
This commit is contained in:
2026-06-17 17:17:36 -04:00
parent 6008776e3c
commit 8aaa9abadb
+6
View File
@@ -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