alsa: recover from snd_pcm_avail() returning -EPIPE

This commit is contained in:
Sam Lantinga 2025-06-20 16:33:30 -07:00
parent e68f5ca99a
commit 7d9fd48557
1 changed files with 6 additions and 2 deletions

View File

@ -356,9 +356,13 @@ static bool ALSA_WaitDevice(SDL_AudioDevice *device)
while (!SDL_GetAtomicInt(&device->shutdown)) { while (!SDL_GetAtomicInt(&device->shutdown)) {
const int rc = ALSA_snd_pcm_avail(device->hidden->pcm); const int rc = ALSA_snd_pcm_avail(device->hidden->pcm);
if (rc < 0) { if (rc < 0) {
const int status = ALSA_snd_pcm_recover(device->hidden->pcm, rc, 0);
if (status < 0) {
// Hmm, not much we can do - abort
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "ALSA wait failed (unrecoverable): %s", ALSA_snd_strerror(rc)); SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "ALSA wait failed (unrecoverable): %s", ALSA_snd_strerror(rc));
return false; return false;
} }
}
if (rc >= sample_frames) { if (rc >= sample_frames) {
break; break;
} }