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: