Skip to content

Commit 7d9fd48

Browse files
committed
alsa: recover from snd_pcm_avail() returning -EPIPE
1 parent e68f5ca commit 7d9fd48

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/audio/alsa/SDL_alsa_audio.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,12 @@ static bool ALSA_WaitDevice(SDL_AudioDevice *device)
356356
while (!SDL_GetAtomicInt(&device->shutdown)) {
357357
const int rc = ALSA_snd_pcm_avail(device->hidden->pcm);
358358
if (rc < 0) {
359-
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "ALSA wait failed (unrecoverable): %s", ALSA_snd_strerror(rc));
360-
return false;
359+
const int status = ALSA_snd_pcm_recover(device->hidden->pcm, rc, 0);
360+
if (status < 0) {
361+
// Hmm, not much we can do - abort
362+
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "ALSA wait failed (unrecoverable): %s", ALSA_snd_strerror(rc));
363+
return false;
364+
}
361365
}
362366
if (rc >= sample_frames) {
363367
break;

0 commit comments

Comments
 (0)