From ebb79600b0d753871e105da42b126fa0d7b2765e Mon Sep 17 00:00:00 2001 From: Alex P Date: Tue, 16 Sep 2025 00:32:19 +0300 Subject: [PATCH] Fix: pcm_snd_wait won't work when device is busy --- internal/audio/c/audio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/audio/c/audio.c b/internal/audio/c/audio.c index d848ae8c..43709028 100644 --- a/internal/audio/c/audio.c +++ b/internal/audio/c/audio.c @@ -364,9 +364,14 @@ retry_read: } else { // Other errors - limited retry for transient issues recovery_attempts++; - if (recovery_attempts <= 1 && (pcm_rc == -EINTR || pcm_rc == -EBUSY)) { + if (recovery_attempts <= 1 && pcm_rc == -EINTR) { + // Interrupted system call - use device-aware wait snd_pcm_wait(pcm_capture_handle, sleep_microseconds / 2000); goto retry_read; + } else if (recovery_attempts <= 1 && pcm_rc == -EBUSY) { + // Device busy - simple sleep to allow other operations to complete + usleep(sleep_microseconds / 2); + goto retry_read; } return -1; }