[alsa-devel] [PATCH 6/9] ALSA: compress: dont write when stream is paused

Vinod Koul vinod.koul at intel.com
Tue Aug 27 08:40:36 CEST 2013


and return bytes written as 0 and not error

Signed-off-by: Vinod Koul <vinod.koul at intel.com>
---
 sound/core/compress_offload.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 417a456..fb570c8 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -256,7 +256,7 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf,
 	struct snd_compr_file *data = f->private_data;
 	struct snd_compr_stream *stream;
 	size_t avail;
-	int retval;
+	int retval = 0;
 
 	if (snd_BUG_ON(!data))
 		return -EFAULT;
@@ -264,6 +264,14 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf,
 	stream = &data->stream;
 	mutex_lock(&stream->device->lock);
 	/* write is allowed when stream is running or has been steup */
+	 /*
+	  * if the stream is in paused state, return the
+	  * number of bytes consumed as 0
+	  */
+	if (stream->runtime->state == SNDRV_PCM_STATE_PAUSED) {
+		mutex_unlock(&stream->device->lock);
+		return retval;
+	}
 	if (stream->runtime->state != SNDRV_PCM_STATE_SETUP &&
 			stream->runtime->state != SNDRV_PCM_STATE_RUNNING) {
 		mutex_unlock(&stream->device->lock);
-- 
1.7.0.4



More information about the Alsa-devel mailing list