mirror of https://github.com/jetkvm/kvm.git
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:
parent
a6cbf20f66
commit
edd06e2346
14
audio.go
14
audio.go
|
|
@ -262,7 +262,12 @@ func SetAudioOutputEnabled(enabled bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if enabled && activeConnections.Load() > 0 {
|
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()
|
stopOutputAudio()
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -274,7 +279,12 @@ func SetAudioInputEnabled(enabled bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if enabled && activeConnections.Load() > 0 {
|
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()
|
stopInputAudio()
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue