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().
This commit is contained in:
Alex P 2025-11-21 00:10:10 +02:00
parent a6cbf20f66
commit edd06e2346
1 changed files with 12 additions and 2 deletions

View File

@ -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