diff --git a/src/system/audio.py b/src/system/audio.py index d91d567..cbc3872 100644 --- a/src/system/audio.py +++ b/src/system/audio.py @@ -323,19 +323,29 @@ class AudioSystem: logger.error("jackd not found — install jackd2") return False - # Wait for readiness via jack_wait + # Wait for readiness — verify JACK is actually operational + # (process exists AND SHM socket is created), not just that + # the jackd process spawned. jackd can start but fail to + # initialize the audio device, leaving a zombie process that + # pgrep finds but jack_lsp can't connect to. deadline = time.monotonic() + timeout while time.monotonic() < deadline: time.sleep(0.3) if _jack_is_running(): - logger.info( - "JACK started: period=%d, nperiods=%d, rate=%d", - profile["period"], profile["nperiods"], profile["rate"], - ) - # Auto-connect ports if enabled - if self.config.auto_connect: - self.connect_fx_ports() - return True + # Double-check JACK is actually operational by testing + # the SHM socket — jack_default_0_0 is created only + # after the ALSA device is successfully initialized. + if Path("/dev/shm/jack_default_0_0").is_socket(): + logger.info( + "JACK started: period=%d, nperiods=%d, rate=%d", + profile["period"], profile["nperiods"], profile["rate"], + ) + # Auto-connect ports if enabled + if self.config.auto_connect: + self.connect_fx_ports() + return True + # JACK process exists but SHM not ready yet — keep waiting + continue # Timed out — check for common issues poll = proc.poll()