Ticket #616: 0001-Tell-user-that-stream-to-be-rewound-is-suspended.patch

File 0001-Tell-user-that-stream-to-be-rewound-is-suspended.patch, 2.1 KB (added by lkundrak, 3 years ago)

This is the kernel part - just for illustration, it has already been submitted to lkml & alsa-devel, just seems to be pending in greylist now

  • sound/core/pcm_native.c

    From 7402d155b5ba6551241cdde9724c2c49dd6cc7ea Mon Sep 17 00:00:00 2001
    From: Lubomir Rintel <lkundrak@v3.sk>
    Date: Sun, 2 Aug 2009 17:41:28 +0200
    Subject: [PATCH] Tell user that stream to be rewound is suspended
    
    Return STRPIPE instead of EBADF when userspace attempts to rewind
    of forward a stream that was suspended in meanwhile, so that it
    can be recovered by snd_pcm_recover().
    
    This was causing Pulseaudio to unload the ALSA sink module under a race
    condition when it attempted to rewind the stream right after resume from
    suspend, before writing to the stream which would cause it to revive the
    stream otherwise. Tested to work with Pulseaudio patched to attempt to
    snd_pcm_recover() upon receiving an error from snd_pcm_rewind().
    
    Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
    ---
     sound/core/pcm_native.c |   12 ++++++++++++
     1 files changed, 12 insertions(+), 0 deletions(-)
    
    diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
    index ac2150e..d89c816 100644
    a b  
    22082208    case SNDRV_PCM_STATE_XRUN: 
    22092209        ret = -EPIPE; 
    22102210        goto __end; 
     2211    case SNDRV_PCM_STATE_SUSPENDED: 
     2212        ret = -ESTRPIPE; 
     2213        goto __end; 
    22112214    default: 
    22122215        ret = -EBADFD; 
    22132216        goto __end; 
     
    22532256    case SNDRV_PCM_STATE_XRUN: 
    22542257        ret = -EPIPE; 
    22552258        goto __end; 
     2259    case SNDRV_PCM_STATE_SUSPENDED: 
     2260        ret = -ESTRPIPE; 
     2261        goto __end; 
    22562262    default: 
    22572263        ret = -EBADFD; 
    22582264        goto __end; 
     
    22992305    case SNDRV_PCM_STATE_XRUN: 
    23002306        ret = -EPIPE; 
    23012307        goto __end; 
     2308    case SNDRV_PCM_STATE_SUSPENDED: 
     2309        ret = -ESTRPIPE; 
     2310        goto __end; 
    23022311    default: 
    23032312        ret = -EBADFD; 
    23042313        goto __end; 
     
    23452354    case SNDRV_PCM_STATE_XRUN: 
    23462355        ret = -EPIPE; 
    23472356        goto __end; 
     2357    case SNDRV_PCM_STATE_SUSPENDED: 
     2358        ret = -ESTRPIPE; 
     2359        goto __end; 
    23482360    default: 
    23492361        ret = -EBADFD; 
    23502362        goto __end;