ALSA: compress: fix the states to check for allowing read
Subsystems (2)
PATCH 1/1 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.
--- sound/core/compress_offload.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
sound/core/compress_offload.c +8 -2
@@ -311,8 +311,14 @@ 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 transistion to after stop, so if user +* wants to read data after stop we allow that +*/ +if (stream->runtime->state !=SNDRV_PCM_STATE_RUNNING || + stream->runtime->state !=SNDRV_PCM_STATE_DRAINING || + stream->runtime->state !=SNDRV_PCM_STATE_PAUSED || + stream->runtime->state !=SNDRV_PCM_STATE_SETUP ) { retval = -EBADFD ; goto out; }
Signature · 1 line
1.7.0.4
At Sun, 28 Apr 2013 13:35:22 +0530,
Quoted 21 lines · Vinod Koul
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]>--- sound/core/compress_offload.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)sound/core/compress_offload.c +0
-1@@ -311,8 +311,14 @@ 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 */
sound/core/compress_offload.c static ssize_t snd_compr_read(struct file *f, char __user *buf, · line 322
Quoted 10 lines
sound/core/compress_offload.c +8
-1-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 transistion to after stop, so if user +* wants to read data after stop we allow that +*/ +if (stream->runtime->state !=SNDRV_PCM_STATE_RUNNING || + stream->runtime->state !=SNDRV_PCM_STATE_DRAINING || + stream->runtime->state !=SNDRV_PCM_STATE_PAUSED || + stream->runtime->state !=SNDRV_PCM_STATE_SETUP ) { retval = -EBADFD ;
Aren't they "&&"?
Maybe better to use switch for avoiding such a trivial error...
Takashi
Quoted 22 lines · Takashi Iwai
At Sun, 28 Apr 2013 13:35:22 +0530,
Quoted 20 lines · Vinod Koul
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]>--- sound/core/compress_offload.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)sound/core/compress_offload.c +0
-0@@ -311,8 +311,14 @@ static ssize_t snd_compr_read(struct file *f, char __user *buf, stream = &data->stream;mutex_lock (&stream->device->lock);
Quoted 13 lines
sound/core/compress_offload.c static ssize_t snd_compr_read(struct file *f, char __user *buf, · line 322
Quoted 11 lines
sound/core/compress_offload.c +8
-2-/* 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 transistion to after stop, so if user +* wants to read data after stop we allow that +*/ +if (stream->runtime->state !=SNDRV_PCM_STATE_RUNNING || + stream->runtime->state !=SNDRV_PCM_STATE_DRAINING || + stream->runtime->state !=SNDRV_PCM_STATE_PAUSED || + stream->runtime->state !=SNDRV_PCM_STATE_SETUP ) { retval = -EBADFD ;Aren't they "&&"?
Yup :(
Quoted 2 lines
Maybe better to use switch for avoiding such a trivial error...
I started with switch and then didnt want to code for all the PCM_STATES... but yes that makes more sense, i will send that right away.
Is it okay if this get in for 3.10...
--
~Vinod
At Mon, 29 Apr 2013 14:15:31 +0530,
Quoted 37 lines · Vinod Koul
Quoted 22 lines · Takashi Iwai
At Sun, 28 Apr 2013 13:35:22 +0530,
Quoted 20 lines · Vinod Koul
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]>--- sound/core/compress_offload.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)sound/core/compress_offload.c +0
-0@@ -311,8 +311,14 @@ static ssize_t snd_compr_read(struct file *f, char __user *buf, stream = &data->stream;mutex_lock (&stream->device->lock);Quoted 13 lines
sound/core/compress_offload.c static ssize_t snd_compr_read(struct file *f, char __user *buf, · line 322
Quoted 11 lines
sound/core/compress_offload.c +8
-2-/* 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 transistion to after stop, so if user +* wants to read data after stop we allow that +*/ +if (stream->runtime->state !=SNDRV_PCM_STATE_RUNNING || + stream->runtime->state !=SNDRV_PCM_STATE_DRAINING || + stream->runtime->state !=SNDRV_PCM_STATE_PAUSED || + stream->runtime->state !=SNDRV_PCM_STATE_SETUP ) { retval = -EBADFD ;Aren't they "&&"?
Quoted 5 lines
Yup :(
Quoted 2 lines
Maybe better to use switch for avoiding such a trivial error...
I started with switch and then didnt want to code for all the
PCM_STATES... but yes that makes more sense, i will send that right away.
You can code like
switch (stream->runtime->state) {
case SNDRV_PCM_STATE_RUNNING:
case SNDRV_PCM_STATE_DRAINING:
case SNDRV_PCM_STATE_PAUSED:
case SNDRV_PCM_STATE_SETUP:
break; /* OK */
default:
retval = -EBADFD;
break;
}Quoted 1 line
Is it okay if this get in for 3.10...
Yes. It's just a damn simple fix.
thanks,
Takashi
Quoted 58 lines · Takashi Iwai
At Mon, 29 Apr 2013 14:15:31 +0530,
Quoted 37 lines · Vinod Koul
Quoted 22 lines · Takashi Iwai
At Sun, 28 Apr 2013 13:35:22 +0530,
Quoted 20 lines · Vinod Koul
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]>--- sound/core/compress_offload.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)sound/core/compress_offload.c +0
-0@@ -311,8 +311,14 @@ static ssize_t snd_compr_read(struct file *f, char __user *buf, stream = &data->stream;mutex_lock (&stream->device->lock);Quoted 13 lines
sound/core/compress_offload.c static ssize_t snd_compr_read(struct file *f, char __user *buf, · line 322
Quoted 11 lines
sound/core/compress_offload.c +8
-2-/* 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 transistion to after stop, so if user +* wants to read data after stop we allow that +*/ +if (stream->runtime->state !=SNDRV_PCM_STATE_RUNNING || + stream->runtime->state !=SNDRV_PCM_STATE_DRAINING || + stream->runtime->state !=SNDRV_PCM_STATE_PAUSED || + stream->runtime->state !=SNDRV_PCM_STATE_SETUP ) { retval = -EBADFD ;Aren't they "&&"?
Quoted 5 lines
Yup :(
Quoted 2 lines
Maybe better to use switch for avoiding such a trivial error...
I started with switch and then didnt want to code for all the
PCM_STATES... but yes that makes more sense, i will send that right away.You can code like
switch (stream->runtime->state) { case SNDRV_PCM_STATE_RUNNING: case SNDRV_PCM_STATE_DRAINING: case SNDRV_PCM_STATE_PAUSED: case SNDRV_PCM_STATE_SETUP: break; /* OK */ default: retval = -EBADFD; break; }
Quoted 8 lines
Quoted 1 line
Is it okay if this get in for 3.10...
Yes. It's just a damn simple fix.
thanks,
Takashi
Ok with me too.
(You beat me to it with this fix)
Quoted 2 lines · Richard Fitzgerald
Ok with me too.
(You beat me to it with this fix)
Blame it on merge window :) Wanted to ensure 3.10 compress record is fine
--
~Vinod
Quoted 4 lines · Takashi Iwai
Quoted 2 lines
I started with switch and then didnt want to code for all the
PCM_STATES... but yes that makes more sense, i will send that right away.You can code like
Quoted 10 lines
switch (stream->runtime->state) {
case SNDRV_PCM_STATE_RUNNING:
case SNDRV_PCM_STATE_DRAINING:
case SNDRV_PCM_STATE_PAUSED:
case SNDRV_PCM_STATE_SETUP:
break; /* OK */
default:
retval = -EBADFD;
break;
}Yup, and i did exactly opposite, let me know if you want like this :)
--
~Vinod
Quoted 2 lines · Vinod Koul
for reading compressed data, we need to allow when we are paused, draining or stopped.
sound/core/compress_offload.c static ssize_t snd_compr_read(struct file *f, char __user *buf, · line 317
Quoted 4 lines
sound/core/compress_offload.c +4
-0+/* read is allowed when stream is running, paused, draining and setup +* (yes setup is state which we transistion to after stop, so if user +* wants to read data after stop we allow that +*/
but I think there's a ) missing in here!
Quoted 4 lines · Mark Brown
Quoted 2 lines · Vinod Koul
for reading compressed data, we need to allow when we are paused, draining or stopped.
Quoted 8 lines
Reviewed-by Mark Brown <[email protected]>sound/core/compress_offload.c static ssize_t snd_compr_read(struct file *f, char __user *buf, · line 317
Quoted 4 lines
sound/core/compress_offload.c +4
-0+/* read is allowed when stream is running, paused, draining and setup +* (yes setup is state which we transistion to after stop, so if user +* wants to read data after stop we allow that +*/ but I think there's a ) missing in here!
Yup :( I guess since Takshi applied it he can fixup it at end of para, and I will owe him a beer next time we meet :)
--
~Vinod