From ebdf98076ae14e0086a1ef31c357efa8ae72a2bb Mon Sep 17 00:00:00 2001 From: Shawn Date: Wed, 17 Jun 2026 17:28:47 -0400 Subject: [PATCH] fix: skip JACK client deactivate() if server is already dead jack.Client.deactivate() is a synchronous protocol call that hangs indefinitely on a broken server socket. In the audio profile change handler, stop_jack() kills the jackd process first, then tries jack_client.stop() which calls deactivate() on the now-dead socket. Fix: check if jackd is still running via pidof before calling deactivate(). If the server is already gone, skip directly to close() which just closes the local file descriptor (safe and fast). This was causing the POST /api/audio/profile endpoint to hang for 30+ seconds on every buffer change. --- src/system/audio.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/system/audio.py b/src/system/audio.py index 128d2bb..5ed7358 100644 --- a/src/system/audio.py +++ b/src/system/audio.py @@ -913,8 +913,12 @@ class JackAudioClient: """Deactivate and close the JACK client.""" if not self._active or self._client is None: return + # Skip deactivate() if JACK server is already dead — it hangs + # on a broken server socket (Broken pipe). try: - self._client.deactivate() + import subprocess + if subprocess.run(["pidof", "jackd"], capture_output=True).returncode == 0: + self._client.deactivate() except Exception as exc: logger.warning("JACK deactivate error: %s", exc) try: