Skip to contentSkip to conversation

compress: fix the states to check for allowing read

PATCH Applied Vinod Koul 2 participants 2 messages Apr 29, 2013

Subsystems (2)
lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

PATCH 1/1 compress: fix the states to check for allowing read

for reading compressed data, we need to allow when we are paused, draining or stopped.

Cc Charles Keepax <[email protected]>
Cc Richard Fitzgerald <[email protected]>
---
 sound/core/compress_offload.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
sound/core/compress_offload.c +10 -2
index a0bc47f..7b774b7 100644
@@ -311,8 +311,16 @@ static ssize_t snd_compr_read(struct file *f, char __user *buf,
 	stream = &data->stream;
 	mutex_lock(&stream->device->lock);
 
-	/* read is allowed when stream is running */
-	if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) {
+	/* read is allowed when stream is running, paused, draining and setup
+	 * (yes setup is state which we transition to after stop, so if user
+	 * wants to read data after stop we allow that
+	 */
+	switch (stream->runtime->state) {
+	case SNDRV_PCM_STATE_OPEN:
+	case SNDRV_PCM_STATE_PREPARED:
+	case SNDRV_PCM_STATE_XRUN:
+	case SNDRV_PCM_STATE_SUSPENDED:
+	case SNDRV_PCM_STATE_DISCONNECTED:
 		retval = -EBADFD;
 		goto out;
 	}
Signature · 1 line
1.7.0.4
Applied
#1 lore raw

At Mon, 29 Apr 2013 14:25:23 +0530,

Quoted 7 lines · Vinod Koul

for reading compressed data, we need to allow when we are paused, draining or stopped.

Cc Charles Keepax <[email protected]>
Cc Richard Fitzgerald <[email protected]>

Thanks, applied.

Takashi

Quoted 30 lines
---
 sound/core/compress_offload.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
sound/core/compress_offload.c +10 -2
index a0bc47f..7b774b7 100644
@@ -311,8 +311,16 @@ static ssize_t snd_compr_read(struct file *f, char __user *buf,
 	stream = &data->stream;
 	mutex_lock(&stream->device->lock);
 
-	/* read is allowed when stream is running */
-	if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) {
+	/* read is allowed when stream is running, paused, draining and setup
+	 * (yes setup is state which we transition to after stop, so if user
+	 * wants to read data after stop we allow that
+	 */
+	switch (stream->runtime->state) {
+	case SNDRV_PCM_STATE_OPEN:
+	case SNDRV_PCM_STATE_PREPARED:
+	case SNDRV_PCM_STATE_XRUN:
+	case SNDRV_PCM_STATE_SUSPENDED:
+	case SNDRV_PCM_STATE_DISCONNECTED:
 		retval = -EBADFD;
 		goto out;
 	}
Signature · 1 line
1.7.0.4