Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
	Richard Fitzgerald <rf@opensource.wolfsonmicro.com>,
	Charles Keepax <ckeepax@opensource.wolfsonmicro.com>,
	liam.r.girdwood@intel.com
Subject: Re: [PATCH] ALSA: compress: fix the states to check for allowing read
Date: Mon, 29 Apr 2013 14:15:31 +0530	[thread overview]
Message-ID: <20130429084531.GJ24632@intel.com> (raw)
In-Reply-To: <s5hmwsh1ztj.wl%tiwai@suse.de>

On Mon, Apr 29, 2013 at 10:55:04AM +0200, Takashi Iwai wrote:
> At Sun, 28 Apr 2013 13:35:22 +0530,
> Vinod Koul wrote:
> > 
> > for reading compressed data, we need to allow when we are paused, draining or
> > stopped.
> > 
> > Signed-off-by: Vinod Koul <vinod.koul@intel.com>
> > Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> > Cc: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> > 
> > ---
> >  sound/core/compress_offload.c |   10 ++++++++--
> >  1 files changed, 8 insertions(+), 2 deletions(-)
> > 
> > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> > index a0bc47f..5389b9a 100644
> > --- a/sound/core/compress_offload.c
> > +++ b/sound/core/compress_offload.c
> > @@ -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;
> 
> Aren't they "&&"?
Yup :(
> 
> 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

  reply	other threads:[~2013-04-29  9:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-28  8:05 [PATCH] ALSA: compress: fix the states to check for allowing read Vinod Koul
2013-04-29  8:55 ` Takashi Iwai
2013-04-29  8:45   ` Vinod Koul [this message]
2013-04-29  9:20     ` Takashi Iwai
2013-04-29  8:57       ` Vinod Koul
2013-04-29  9:29       ` Richard Fitzgerald
2013-04-29  9:00         ` Vinod Koul
2013-04-29 11:07 ` Mark Brown
2013-04-29 10:54   ` Vinod Koul

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=20130429084531.GJ24632@intel.com \
    --to=vinod.koul@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=liam.r.girdwood@intel.com \
    --cc=rf@opensource.wolfsonmicro.com \
    --cc=tiwai@suse.de \
    /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