From 32990f974422ce383527200dc2fade401b559dac Mon Sep 17 00:00:00 2001 From: Shawn Date: Thu, 18 Jun 2026 18:04:06 -0400 Subject: [PATCH] fix: _jack_is_operational() must check jack_lsp stdout, not exit code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit jack_lsp on JACK 1.9.22 always exits 0 even when JACK is dead — it prints error to stderr but returns success. Check for non-empty stdout (port names) instead, which only appears when JACK is truly operational. --- src/system/audio.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/system/audio.py b/src/system/audio.py index e2f5fa7..1548a02 100644 --- a/src/system/audio.py +++ b/src/system/audio.py @@ -854,20 +854,19 @@ def _jack_is_running() -> bool: def _jack_is_operational() -> bool: """Check if JACK is actually accepting client connections. - Uses ``jack_lsp`` to verify the JACK server is operational beyond - just having a running process. ``jack_lsp`` connects to the JACK - server via shared memory and lists ports — it only succeeds when - JACK has fully initialized the ALSA device and IPC is live. - - On JACK 1.9.22 there is no ``/dev/shm/jack_default_0_0`` socket, - so ``jack_lsp`` is the most reliable readiness check. + Uses ``jack_lsp`` and checks stdout is non-empty (port names). + ``jack_lsp`` always exits 0 on JACK 1.9.22 even when dead — + only stdout content distinguishes 'JACK running' from + 'JACK inaccessible'. """ try: result = subprocess.run( ["jack_lsp"], capture_output=True, timeout=3, ) - return result.returncode == 0 + # jack_lsp exits 0 even when dead on JACK 1.9.22 — + # only non-empty stdout means ports were actually listed + return bool(result.stdout.strip()) except (FileNotFoundError, subprocess.TimeoutExpired): return False