From edd06e23469a02ce198bcb6faf1200a11465a9c0 Mon Sep 17 00:00:00 2001 From: Alex P Date: Fri, 21 Nov 2025 00:10:10 +0200 Subject: [PATCH] Fix UI hanging when toggling audio output enable/disable Make audio start asynchronous to prevent blocking the RPC response. Previously, enabling audio would block until ALSA initialization completed, which can take 30-60 seconds for HDMI audio due to TC358743 hardware. This also fixes the -1 decode errors that occurred when packets arrived during the synchronous restart window. Matches the existing async pattern used in SetAudioOutputSource(). --- audio.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/audio.go b/audio.go index f2f3f325..c52428ab 100644 --- a/audio.go +++ b/audio.go @@ -262,7 +262,12 @@ func SetAudioOutputEnabled(enabled bool) error { } if enabled && activeConnections.Load() > 0 { - return startAudio() + go func() { + if err := startAudio(); err != nil { + audioLogger.Error().Err(err).Msg("Failed to start output audio after enable") + } + }() + return nil } stopOutputAudio() return nil @@ -274,7 +279,12 @@ func SetAudioInputEnabled(enabled bool) error { } if enabled && activeConnections.Load() > 0 { - return startAudio() + go func() { + if err := startAudio(); err != nil { + audioLogger.Error().Err(err).Msg("Failed to start input audio after enable") + } + }() + return nil } stopInputAudio() return nil