alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: pcm: Fix avail to return error if stream is suspended
@ 2016-09-02 16:19 jeeja.kp
  2016-09-06 10:10 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: jeeja.kp @ 2016-09-02 16:19 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, patches.audio, broonie, liam.r.girdwood, Jeeja KP

From: Jeeja KP <jeeja.kp@intel.com>

When the stream is in suspended state some applications wait
on "Stream Pipe Error" in response to snd_pcm_avail call to
resume the stream.

In the current implementation snd_pcm_avail() returns zero
when the stream is in suspended state. This causes application
to enter in infinite loop for frames to be available.

"Stream pipe Error" code is getting returned for read/write
call when the stream is in suspended state. Similarly update
snd_pcm_avail to return -ESTRPIPE.

Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
---
 sound/core/pcm_native.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index c61fd50..9d33c1e 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2637,9 +2637,11 @@ static int snd_pcm_hwsync(struct snd_pcm_substream *substream)
 			break;
 		/* Fall through */
 	case SNDRV_PCM_STATE_PREPARED:
-	case SNDRV_PCM_STATE_SUSPENDED:
 		err = 0;
 		break;
+	case SNDRV_PCM_STATE_SUSPENDED:
+		err = -ESTRPIPE;
+		break;
 	case SNDRV_PCM_STATE_XRUN:
 		err = -EPIPE;
 		break;
-- 
2.5.0

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

* Re: [PATCH] ALSA: pcm: Fix avail to return error if stream is suspended
  2016-09-02 16:19 [PATCH] ALSA: pcm: Fix avail to return error if stream is suspended jeeja.kp
@ 2016-09-06 10:10 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2016-09-06 10:10 UTC (permalink / raw)
  To: jeeja.kp; +Cc: patches.audio, alsa-devel, broonie, liam.r.girdwood

On Fri, 02 Sep 2016 18:19:44 +0200,
jeeja.kp@intel.com wrote:
> 
> From: Jeeja KP <jeeja.kp@intel.com>
> 
> When the stream is in suspended state some applications wait
> on "Stream Pipe Error" in response to snd_pcm_avail call to
> resume the stream.
> 
> In the current implementation snd_pcm_avail() returns zero
> when the stream is in suspended state. This causes application
> to enter in infinite loop for frames to be available.
> 
> "Stream pipe Error" code is getting returned for read/write
> call when the stream is in suspended state. Similarly update
> snd_pcm_avail to return -ESTRPIPE.
> 
> Signed-off-by: Jeeja KP <jeeja.kp@intel.com>

Applied, thanks.


Takashi

> ---
>  sound/core/pcm_native.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index c61fd50..9d33c1e 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -2637,9 +2637,11 @@ static int snd_pcm_hwsync(struct snd_pcm_substream *substream)
>  			break;
>  		/* Fall through */
>  	case SNDRV_PCM_STATE_PREPARED:
> -	case SNDRV_PCM_STATE_SUSPENDED:
>  		err = 0;
>  		break;
> +	case SNDRV_PCM_STATE_SUSPENDED:
> +		err = -ESTRPIPE;
> +		break;
>  	case SNDRV_PCM_STATE_XRUN:
>  		err = -EPIPE;
>  		break;
> -- 
> 2.5.0
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

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

end of thread, other threads:[~2016-09-06 10:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-02 16:19 [PATCH] ALSA: pcm: Fix avail to return error if stream is suspended jeeja.kp
2016-09-06 10:10 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).