From 61886858f6e2555d0b3da5bdc1c697b5d6738aaf Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 18 Jun 2026 17:26:52 -0400 Subject: [PATCH] fix: rollback must restore AudioConfig period/rate + LATENCY_PROFILES MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The profile change rollback only restored audio_sys.config.profile to old_key, but my earlier fix had started syncing period/rate to AudioConfig BEFORE start_jack(). This meant the rollback's start_jack() still used the NEW period/rate (via latency_profile) because self.period was never reverted — the same failing config was retried and failed again. Fix: capture old_period, old_rate, and old LATENCY_PROFILES['custom'] entry before applying the new profile, then restore all of them in the rollback path. --- src/web/server.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/web/server.py b/src/web/server.py index a43115f..7c3720d 100644 --- a/src/web/server.py +++ b/src/web/server.py @@ -1674,6 +1674,10 @@ class WebServer: return {"ok": True, "profile": effective_key, "restarted": False} # ── Apply new profile on the fly ───────────────────────── + # Capture old values for rollback + old_period = audio_sys.config.period + old_rate = audio_sys.config.rate + old_entry = LATENCY_PROFILES.get("custom") # Update AudioConfig — store named overrides inline in profile key audio_sys.config.profile = effective_key @@ -1719,8 +1723,15 @@ class WebServer: ok = await loop.run_in_executor(None, partial(audio_sys.start_jack, timeout=15)) audio_sys.config.auto_connect = saved_auto_connect if not ok: - # Rollback on failure + # Rollback on failure — restore AudioConfig fields too audio_sys.config.profile = old_key + audio_sys.config.period = old_period + audio_sys.config.rate = old_rate + # Restore the old LATENCY_PROFILES entry + if old_entry is not None: + LATENCY_PROFILES["custom"] = old_entry + elif "custom" in LATENCY_PROFILES: + del LATENCY_PROFILES["custom"] logger.warning("JACK restart failed — attempting rollback to %s", old_key) ok = await loop.run_in_executor(None, partial(audio_sys.start_jack, timeout=15)) if jack_client: