This fixes rare condition when pulseaudio client tries to rewind, but a device previously reached underrun and was changed to XRUN state. --- src/modules/alsa/alsa-sink.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index b6c7d09..a912259 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -1628,8 +1628,14 @@ static int process_rewind(struct userdata *u) { pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) rewind_nbytes); if (PA_UNLIKELY((unused = pa_alsa_safe_avail(u->pcm_handle, u->hwbuf_size, &u->sink->sample_spec)) < 0)) { + int ret; pa_log("snd_pcm_avail() failed: %s", pa_alsa_strerror((int) unused)); - return -1; + if ((ret = try_recover(u, "snd_pcm_avail", (int) unused)) == 0) { + pa_log("try recover in process_rewind() succeed (ret = %d)", ret); + } else { + pa_log("try recover in process_rewind() failed! (ret = %d)", ret); + return -1; + } } unused_nbytes = (size_t) unused * u->frame_size; -- 2.1.4