https://github.com/libsdl-org/SDL/commit/3482d1215a699a6aee3fc734c036e1bd899ec05d
From 3482d1215a699a6aee3fc734c036e1bd899ec05d Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 4 Jul 2023 19:27:10 -0400
Subject: [PATCH] alsa: Don't ever block in CaptureFromDevice.
---
src/audio/alsa/SDL_alsa_audio.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c
index d5bb90cf192f..4703eee4c5d2 100644
--- a/src/audio/alsa/SDL_alsa_audio.c
+++ b/src/audio/alsa/SDL_alsa_audio.c
@@ -405,7 +405,6 @@ static int ALSA_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, int buf
device->spec.channels;
const int total_frames = buflen / frame_size;
snd_pcm_uframes_t frames_left = total_frames;
- snd_pcm_uframes_t wait_time = frame_size / 2;
SDL_assert((buflen % frame_size) == 0);
@@ -414,8 +413,7 @@ static int ALSA_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, int buf
sample_buf, frames_left);
if (status == -EAGAIN) {
- ALSA_snd_pcm_wait(device->hidden->pcm_handle, wait_time);
- status = 0;
+ break; // Can this even happen? Go back to WaitCaptureDevice, where the device lock isn't held.
} else if (status < 0) {
/*printf("ALSA: capture error %d\n", status);*/
status = ALSA_snd_pcm_recover(device->hidden->pcm_handle, status, 0);
@@ -426,7 +424,7 @@ static int ALSA_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, int buf
ALSA_snd_strerror(status));
return -1;
}
- continue;
+ break; // Go back to WaitCaptureDevice, where the device lock isn't held.
}
/*printf("ALSA: captured %d bytes\n", status * frame_size);*/