alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: vkoul@kernel.org, tiwai@suse.com
Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org
Subject: [PATCH 4/4] ALSA: compress: Be more restrictive about when a drain is allowed
Date: Tue, 9 Jul 2019 11:52:11 +0100	[thread overview]
Message-ID: <20190709105211.11741-4-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20190709105211.11741-1-ckeepax@opensource.cirrus.com>

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>
---
 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 c7d56cee0d510..9fcd06395a046 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -824,7 +824,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;
 	}
@@ -877,7 +880,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

      parent reply	other threads:[~2019-07-09 10:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09 10:52 [PATCH 1/4] ALSA: compress: Fix regression on compressed capture streams Charles Keepax
2019-07-09 10:52 ` [PATCH 2/4] ALSA: compress: Prevent bypasses of set_params Charles Keepax
2019-07-09 10:52 ` [PATCH 3/4] ALSA: compress: Don't allow drain operations on capture streams Charles Keepax
2019-07-09 11:36   ` Vinod Koul
2019-07-09 12:58     ` Charles Keepax
2019-07-09 10:52 ` Charles Keepax [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190709105211.11741-4-ckeepax@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=patches@opensource.cirrus.com \
    --cc=tiwai@suse.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).