The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] Tell user that stream to be rewound is suspended
@ 2009-08-02 16:14 Lubomir Rintel
  2009-08-02 16:32 ` Lubomir Rintel
  2009-08-03  6:53 ` Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Lubomir Rintel @ 2009-08-02 16:14 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jaroslav Kysela, Takashi Iwai, Lennart Poettering, stable,
	alsa-devel, Lubomir Rintel

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/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2208,6 +2208,9 @@ static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *subst
 	case SNDRV_PCM_STATE_XRUN:
 		ret = -EPIPE;
 		goto __end;
+	case SNDRV_PCM_STATE_SUSPENDED:
+		ret = -ESTRPIPE;
+		goto __end;
 	default:
 		ret = -EBADFD;
 		goto __end;
@@ -2253,6 +2256,9 @@ static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substr
 	case SNDRV_PCM_STATE_XRUN:
 		ret = -EPIPE;
 		goto __end;
+	case SNDRV_PCM_STATE_SUSPENDED:
+		ret = -ESTRPIPE;
+		goto __end;
 	default:
 		ret = -EBADFD;
 		goto __end;
@@ -2299,6 +2305,9 @@ static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *subs
 	case SNDRV_PCM_STATE_XRUN:
 		ret = -EPIPE;
 		goto __end;
+	case SNDRV_PCM_STATE_SUSPENDED:
+		ret = -ESTRPIPE;
+		goto __end;
 	default:
 		ret = -EBADFD;
 		goto __end;
@@ -2345,6 +2354,9 @@ static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *subst
 	case SNDRV_PCM_STATE_XRUN:
 		ret = -EPIPE;
 		goto __end;
+	case SNDRV_PCM_STATE_SUSPENDED:
+		ret = -ESTRPIPE;
+		goto __end;
 	default:
 		ret = -EBADFD;
 		goto __end;
-- 
1.6.2.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Tell user that stream to be rewound is suspended
  2009-08-02 16:14 [PATCH] Tell user that stream to be rewound is suspended Lubomir Rintel
@ 2009-08-02 16:32 ` Lubomir Rintel
  2009-08-03  6:53 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Lubomir Rintel @ 2009-08-02 16:32 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jaroslav Kysela, Takashi Iwai, Lennart Poettering, stable,
	alsa-devel

On Sun, 2009-08-02 at 18:14 +0200, Lubomir Rintel wrote:
> 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().

The userspace part is filed here:
http://www.pulseaudio.org/ticket/616

-- 
"Excuse all the blood" -- Dead


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Tell user that stream to be rewound is suspended
  2009-08-02 16:14 [PATCH] Tell user that stream to be rewound is suspended Lubomir Rintel
  2009-08-02 16:32 ` Lubomir Rintel
@ 2009-08-03  6:53 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2009-08-03  6:53 UTC (permalink / raw)
  To: Lubomir Rintel
  Cc: linux-kernel, Jaroslav Kysela, Lennart Poettering, stable,
	alsa-devel

At Sun,  2 Aug 2009 18:14:44 +0200,
Lubomir Rintel wrote:
> 
> 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>

The change looks fine, but I think this isn't for stable kernel since
this is actually an ABI extension.

For testing, I'm going to apply this to sound-unstable tree for the
time being.  I'll merge to the main sound tree soon later, though.


thanks,

Takashi

> ---
>  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/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -2208,6 +2208,9 @@ static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *subst
>  	case SNDRV_PCM_STATE_XRUN:
>  		ret = -EPIPE;
>  		goto __end;
> +	case SNDRV_PCM_STATE_SUSPENDED:
> +		ret = -ESTRPIPE;
> +		goto __end;
>  	default:
>  		ret = -EBADFD;
>  		goto __end;
> @@ -2253,6 +2256,9 @@ static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substr
>  	case SNDRV_PCM_STATE_XRUN:
>  		ret = -EPIPE;
>  		goto __end;
> +	case SNDRV_PCM_STATE_SUSPENDED:
> +		ret = -ESTRPIPE;
> +		goto __end;
>  	default:
>  		ret = -EBADFD;
>  		goto __end;
> @@ -2299,6 +2305,9 @@ static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *subs
>  	case SNDRV_PCM_STATE_XRUN:
>  		ret = -EPIPE;
>  		goto __end;
> +	case SNDRV_PCM_STATE_SUSPENDED:
> +		ret = -ESTRPIPE;
> +		goto __end;
>  	default:
>  		ret = -EBADFD;
>  		goto __end;
> @@ -2345,6 +2354,9 @@ static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *subst
>  	case SNDRV_PCM_STATE_XRUN:
>  		ret = -EPIPE;
>  		goto __end;
> +	case SNDRV_PCM_STATE_SUSPENDED:
> +		ret = -ESTRPIPE;
> +		goto __end;
>  	default:
>  		ret = -EBADFD;
>  		goto __end;
> -- 
> 1.6.2.5
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-03  6:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-02 16:14 [PATCH] Tell user that stream to be rewound is suspended Lubomir Rintel
2009-08-02 16:32 ` Lubomir Rintel
2009-08-03  6:53 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox