From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vinod Koul Subject: Re: [PATCH] ALSA: compress: fix the states to check for allowing read Date: Mon, 29 Apr 2013 14:15:31 +0530 Message-ID: <20130429084531.GJ24632@intel.com> References: <1367136322-24531-1-git-send-email-vinod.koul@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by alsa0.perex.cz (Postfix) with ESMTP id A2A5B261A09 for ; Mon, 29 Apr 2013 11:18:23 +0200 (CEST) Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Takashi Iwai Cc: alsa-devel@alsa-project.org, broonie@kernel.org, Richard Fitzgerald , Charles Keepax , liam.r.girdwood@intel.com List-Id: alsa-devel@alsa-project.org 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 > > Cc: Charles Keepax > > Cc: Richard Fitzgerald > > > > --- > > 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