Ticket #616: 0001-Recover-stream-when-it-s-suspended-upon-rewind.patch

File 0001-Recover-stream-when-it-s-suspended-upon-rewind.patch, 2.0 KB (added by lkundrak, 3 years ago)

Recover stream when it's suspended upon rewind

  • src/modules/alsa/alsa-sink.c

    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  
    340340    if (err == -EPIPE) 
    341341        pa_log_debug("%s: Buffer underrun!", call); 
    342342 
     343    if (err == -EBADFD) 
     344        pa_log_debug("%s: Stream suspended!", call); 
     345 
    343346    if ((err = snd_pcm_recover(u->pcm_handle, err, 1)) < 0) { 
    344347        pa_log("%s: %s", call, pa_alsa_strerror(err)); 
    345348        return -1; 
     
    11991202        pa_log_debug("before: %lu", (unsigned long) in_frames); 
    12001203        if ((out_frames = snd_pcm_rewind(u->pcm_handle, (snd_pcm_uframes_t) in_frames)) < 0) { 
    12011204            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; 
    12031208        } 
     1209 
    12041210        pa_log_debug("after: %lu", (unsigned long) out_frames); 
    12051211 
    12061212        rewind_nbytes = (size_t) out_frames * u->frame_size;