From 0f9db419ba97387abef93ec16d0a23d3133a0a31 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Sun, 2 Aug 2009 17:52:05 +0200
Subject: [PATCH] Recover stream when it's suspended upon rewind
Error from snd_pcm_rewind() might mean we just woke up from suspend and
didn't have a chance to try to recover the stream since we didn't write
to it in between. Call try_recover() in such cases.
Note that for this to work kernel must return ESTRPIPE instead of EBADF
for rewind/forward attempts on suspended streams, so that
snd_pcm_recover() can recognize it should snd_pcm_resume() the stream.
This is not the case yet (2.6.31-rc5), patch is available.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
src/modules/alsa/alsa-sink.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 7fc602b..2a734e3 100644
|
a
|
b
|
|
| 340 | 340 | if (err == -EPIPE) |
| 341 | 341 | pa_log_debug("%s: Buffer underrun!", call); |
| 342 | 342 | |
| | 343 | if (err == -EBADFD) |
| | 344 | pa_log_debug("%s: Stream suspended!", call); |
| | 345 | |
| 343 | 346 | if ((err = snd_pcm_recover(u->pcm_handle, err, 1)) < 0) { |
| 344 | 347 | pa_log("%s: %s", call, pa_alsa_strerror(err)); |
| 345 | 348 | return -1; |
| … |
… |
|
| 1199 | 1202 | pa_log_debug("before: %lu", (unsigned long) in_frames); |
| 1200 | 1203 | if ((out_frames = snd_pcm_rewind(u->pcm_handle, (snd_pcm_uframes_t) in_frames)) < 0) { |
| 1201 | 1204 | pa_log("snd_pcm_rewind() failed: %s", pa_alsa_strerror((int) out_frames)); |
| 1202 | | return -1; |
| | 1205 | if (try_recover(u, "process_rewind", out_frames) < 0) |
| | 1206 | return -1; |
| | 1207 | out_frames = 0; |
| 1203 | 1208 | } |
| | 1209 | |
| 1204 | 1210 | pa_log_debug("after: %lu", (unsigned long) out_frames); |
| 1205 | 1211 | |
| 1206 | 1212 | rewind_nbytes = (size_t) out_frames * u->frame_size; |