kvm/internal/audio
Alex P a6b7ac50ef Eliminate hang completely by making ALSA interruption immediate
Problem:
Previous fix reduced but didn't eliminate the hang when switching audio
sources. The C layer was still blocking on snd_pcm_readi()/snd_pcm_writei()
while holding the mutex, preventing cleanup from proceeding.

Solution:
Call snd_pcm_drop() BEFORE acquiring the mutex in close functions. This
immediately interrupts any blocking ALSA read/write operations, causing them
to return with -EBADFD or -ESTRPIPE. The sequence is now:

1. Set stop_requested flag
2. Call snd_pcm_drop() to interrupt blocking I/O (no mutex needed - thread-safe)
3. Acquire mutex for cleanup
4. Close handles and free resources
5. Release mutex

This makes audio source switching instantaneous with zero hang.

Changes:
- jetkvm_audio_capture_close(): Drop PCM before mutex
- jetkvm_audio_playback_close(): Drop PCM before mutex

Tested: USB↔HDMI switching now happens instantly with no delay.
2025-11-18 01:46:29 +02:00
..
c Eliminate hang completely by making ALSA interruption immediate 2025-11-18 01:46:29 +02:00
cgo_source.go Fix critical deadlock when switching audio sources 2025-11-18 01:41:46 +02:00
cgo_source_stub.go Add runtime configurable audio parameters with UI controls 2025-11-17 21:51:08 +02:00
relay.go Add runtime configurable audio parameters with UI controls 2025-11-17 21:51:08 +02:00
source.go Fix: improve EDID compatibility and add audio configuration options 2025-11-18 00:53:15 +02:00