Fix: pcm_snd_wait won't work when device is busy

This commit is contained in:
Alex P 2025-09-16 00:32:19 +03:00
parent b040b8feaf
commit ebb79600b0
1 changed files with 6 additions and 1 deletions

View File

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