diff mbox series

[v2,4/4] ALSA: compress: Be more restrictive about when a drain is allowed

Message ID 20190722092436.651-4-ckeepax@opensource.cirrus.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/4] ALSA: compress: Fix regression on compressed capture streams | expand

Commit Message

Charles Keepax July 22, 2019, 9:24 a.m. UTC
Draining makes little sense in the situation of hardware overrun, as the
hardware will have consumed all its available samples. Additionally,
draining whilst the stream is paused would presumably get stuck as no
data is being consumed on the DSP side.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---

No changes since v1.

Thanks,
Charles

 sound/core/compress_offload.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Takashi Iwai July 23, 2019, 10:08 a.m. UTC | #1
On Mon, 22 Jul 2019 11:24:36 +0200,
Charles Keepax wrote:
> 
> Draining makes little sense in the situation of hardware overrun, as the
> hardware will have consumed all its available samples. Additionally,
> draining whilst the stream is paused would presumably get stuck as no
> data is being consumed on the DSP side.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Applied, thanks.


Takashi

> ---
> 
> No changes since v1.
> 
> Thanks,
> Charles
> 
>  sound/core/compress_offload.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index 6cf5b8440cf30..41905afada63f 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -811,7 +811,10 @@ static int snd_compr_drain(struct snd_compr_stream *stream)
>  	case SNDRV_PCM_STATE_OPEN:
>  	case SNDRV_PCM_STATE_SETUP:
>  	case SNDRV_PCM_STATE_PREPARED:
> +	case SNDRV_PCM_STATE_PAUSED:
>  		return -EPERM;
> +	case SNDRV_PCM_STATE_XRUN:
> +		return -EPIPE;
>  	default:
>  		break;
>  	}
> @@ -860,7 +863,10 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
>  	case SNDRV_PCM_STATE_OPEN:
>  	case SNDRV_PCM_STATE_SETUP:
>  	case SNDRV_PCM_STATE_PREPARED:
> +	case SNDRV_PCM_STATE_PAUSED:
>  		return -EPERM;
> +	case SNDRV_PCM_STATE_XRUN:
> +		return -EPIPE;
>  	default:
>  		break;
>  	}
> -- 
> 2.11.0
> 
>
diff mbox series

Patch

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 6cf5b8440cf30..41905afada63f 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -811,7 +811,10 @@  static int snd_compr_drain(struct snd_compr_stream *stream)
 	case SNDRV_PCM_STATE_OPEN:
 	case SNDRV_PCM_STATE_SETUP:
 	case SNDRV_PCM_STATE_PREPARED:
+	case SNDRV_PCM_STATE_PAUSED:
 		return -EPERM;
+	case SNDRV_PCM_STATE_XRUN:
+		return -EPIPE;
 	default:
 		break;
 	}
@@ -860,7 +863,10 @@  static int snd_compr_partial_drain(struct snd_compr_stream *stream)
 	case SNDRV_PCM_STATE_OPEN:
 	case SNDRV_PCM_STATE_SETUP:
 	case SNDRV_PCM_STATE_PREPARED:
+	case SNDRV_PCM_STATE_PAUSED:
 		return -EPERM;
+	case SNDRV_PCM_STATE_XRUN:
+		return -EPIPE;
 	default:
 		break;
 	}