From 166d472085f9da73bd79a38120994ffee1325abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gallet?= Date: Fri, 19 Nov 2021 19:44:18 +0100 Subject: [PATCH] snd_pcm_recover() now supports underrun --- CHANGELOG.md | 1 + src/library/audio/alsa/pcm.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a5c2916..94c558cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Support binding keys to mouse buttons * Add a toggle fast-forward hotkey * Implements alGetString() (#447) +* snd_pcm_recover() now supports underrun ### Changed ### Fixed diff --git a/src/library/audio/alsa/pcm.cpp b/src/library/audio/alsa/pcm.cpp index 0b5e857f..cae51f5a 100644 --- a/src/library/audio/alsa/pcm.cpp +++ b/src/library/audio/alsa/pcm.cpp @@ -508,7 +508,18 @@ int snd_pcm_recover(snd_pcm_t *pcm, int err, int silent) } DEBUGLOGCALL(LCF_SOUND); - return 0; + + if (err == -EPIPE) { + int sourceId = reinterpret_cast(pcm); + auto source = audiocontext.getSource(sourceId); + + if (source->state == AudioSource::SOURCE_UNDERRUN) + source->state = AudioSource::SOURCE_PREPARED; + + return 0; + } + + return err; } int snd_pcm_reset(snd_pcm_t *pcm)