From: Takashi Iwai Subject: Re: [PATCH] compress: fix the states to check for allowing read Date: Mon, 29 Apr 2013 11:56:25 +0200 Message-ID: References: <1367225723-10145-1-git-send-email-vinod.koul@intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 05347261A08 for ; Mon, 29 Apr 2013 11:56:14 +0200 (CEST) In-Reply-To: <1367225723-10145-1-git-send-email-vinod.koul@intel.com> 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: Vinod Koul 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 At Mon, 29 Apr 2013 14:25:23 +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 Thanks, applied. Takashi > --- > sound/core/compress_offload.c | 12 ++++++++++-- > 1 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c > index a0bc47f..7b774b7 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; > } > -- > 1.7.0.4 >