aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinod Koul <[email protected]>2013-04-29 14:25:23 +0530
committerTakashi Iwai <[email protected]>2013-04-29 13:33:18 +0200
commit754813473c1a8b7711802313125f0fafc60141f8 (patch)
tree3d948cec2f7b73756c4cbb548546db57f0a17b22
parenta555bb8c6bf6932c5706745bfdbad22df26324d9 (diff)
ALSA: compress: fix the states to check for allowing read
for reading compressed data, we need to allow when we are paused, draining or stopped. Signed-off-by: Vinod Koul <[email protected]> Cc: Charles Keepax <[email protected]> Cc: Richard Fitzgerald <[email protected]> Reviewed-by: Mark Brown <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
-rw-r--r--sound/core/compress_offload.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index a0bc47f8dcf7..99db892d7299 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -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;
}