From: Takashi Iwai Subject: Re: [PATCH v2 1/4] ALSA: compress: Fix regression on compressed capture streams Date: Tue, 23 Jul 2019 12:08:23 +0200 Message-ID: References: <20190722092436.651-1-ckeepax@opensource.cirrus.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 mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7AD95F80227 for ; Tue, 23 Jul 2019 12:08:25 +0200 (CEST) In-Reply-To: <20190722092436.651-1-ckeepax@opensource.cirrus.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: Charles Keepax Cc: patches@opensource.cirrus.com, vkoul@kernel.org, alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org On Mon, 22 Jul 2019 11:24:33 +0200, Charles Keepax wrote: > > A previous fix to the stop handling on compressed capture streams causes > some knock on issues. The previous fix updated snd_compr_drain_notify to > set the state back to PREPARED for capture streams. This causes some > issues however as the handling for snd_compr_poll differs between the > two states and some user-space applications were relying on the poll > failing after the stream had been stopped. > > To correct this regression whilst still fixing the original problem the > patch was addressing, update the capture handling to skip the PREPARED > state rather than skipping the SETUP state as it has done until now. > > Fixes: 4f2ab5e1d13d ("ALSA: compress: Fix stop handling on compressed capture streams") > Signed-off-by: Charles Keepax Applied, thanks. Takashi > --- > > No changes since v1. > > Thanks, > Charles > > include/sound/compress_driver.h | 5 +---- > sound/core/compress_offload.c | 16 +++++++++++----- > 2 files changed, 12 insertions(+), 9 deletions(-) > > diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h > index c5188ff724d12..bc88d6f964da9 100644 > --- a/include/sound/compress_driver.h > +++ b/include/sound/compress_driver.h > @@ -173,10 +173,7 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) > if (snd_BUG_ON(!stream)) > return; > > - if (stream->direction == SND_COMPRESS_PLAYBACK) > - stream->runtime->state = SNDRV_PCM_STATE_SETUP; > - else > - stream->runtime->state = SNDRV_PCM_STATE_PREPARED; > + stream->runtime->state = SNDRV_PCM_STATE_SETUP; > > wake_up(&stream->runtime->sleep); > } > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c > index 99b8821587053..d79aee6b9edd2 100644 > --- a/sound/core/compress_offload.c > +++ b/sound/core/compress_offload.c > @@ -574,10 +574,7 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) > stream->metadata_set = false; > stream->next_track = false; > > - if (stream->direction == SND_COMPRESS_PLAYBACK) > - stream->runtime->state = SNDRV_PCM_STATE_SETUP; > - else > - stream->runtime->state = SNDRV_PCM_STATE_PREPARED; > + stream->runtime->state = SNDRV_PCM_STATE_SETUP; > } else { > return -EPERM; > } > @@ -693,8 +690,17 @@ static int snd_compr_start(struct snd_compr_stream *stream) > { > int retval; > > - if (stream->runtime->state != SNDRV_PCM_STATE_PREPARED) > + switch (stream->runtime->state) { > + case SNDRV_PCM_STATE_SETUP: > + if (stream->direction != SND_COMPRESS_CAPTURE) > + return -EPERM; > + break; > + case SNDRV_PCM_STATE_PREPARED: > + break; > + default: > return -EPERM; > + } > + > retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_START); > if (!retval) > stream->runtime->state = SNDRV_PCM_STATE_RUNNING; > -- > 2.11.0 > >