From: Vinod Koul <vkoul@kernel.org> To: Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz> Cc: "Vinod Koul" <vkoul@kernel.org>, "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>, "Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>, "Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>, "Charles Keepax" <ckeepax@opensource.cirrus.com>, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] ALSA: compress: fix partial_drain completion state Date: Mon, 29 Jun 2020 19:17:37 +0530 [thread overview] Message-ID: <20200629134737.105993-4-vkoul@kernel.org> (raw) In-Reply-To: <20200629134737.105993-1-vkoul@kernel.org> On partial_drain completion we should be in SNDRV_PCM_STATE_RUNNING state, so set that for partially draining streams in snd_compr_drain_notify() and use a flag for partially draining streams While at it, add locks for stream state change in snd_compr_drain_notify() as well. Fixes: f44f2a5417b2 ("ALSA: compress: fix drain calls blocking other compress functions (v6)") Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Vinod Koul <vkoul@kernel.org> --- include/sound/compress_driver.h | 10 +++++++++- sound/core/compress_offload.c | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h index 3df8d8c90191..8d23351f7ad7 100644 --- a/include/sound/compress_driver.h +++ b/include/sound/compress_driver.h @@ -66,6 +66,7 @@ struct snd_compr_runtime { * @direction: stream direction, playback/recording * @metadata_set: metadata set flag, true when set * @next_track: has userspace signal next track transition, true when set + * @partial_drain: undergoing partial_drain for stream, true when set * @private_data: pointer to DSP private data * @dma_buffer: allocated buffer if any */ @@ -78,6 +79,7 @@ struct snd_compr_stream { enum snd_compr_direction direction; bool metadata_set; bool next_track; + bool partial_drain; void *private_data; struct snd_dma_buffer dma_buffer; }; @@ -187,7 +189,13 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) if (snd_BUG_ON(!stream)) return; - stream->runtime->state = SNDRV_PCM_STATE_SETUP; + /* for partial_drain case we are back to running state on success */ + if (stream->partial_drain) { + stream->runtime->state = SNDRV_PCM_STATE_RUNNING; + stream->partial_drain = false; /* clear this flag as well */ + } else { + 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 e618580feac4..1c4b2cf450a0 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -803,6 +803,9 @@ static int snd_compr_stop(struct snd_compr_stream *stream) retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); if (!retval) { + /* clear flags and stop any drain wait */ + stream->partial_drain = false; + stream->metadata_set = false; snd_compr_drain_notify(stream); stream->runtime->total_bytes_available = 0; stream->runtime->total_bytes_transferred = 0; @@ -960,6 +963,7 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) if (stream->next_track == false) return -EPERM; + stream->partial_drain = true; retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN); if (retval) { pr_debug("Partial drain returned failure\n"); -- 2.26.2
WARNING: multiple messages have this Message-ID (diff)
From: Vinod Koul <vkoul@kernel.org> To: Takashi Iwai <tiwai@suse.com>, Jaroslav Kysela <perex@perex.cz> Cc: alsa-devel@alsa-project.org, "Charles Keepax" <ckeepax@opensource.cirrus.com>, "Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>, linux-kernel@vger.kernel.org, "Vinod Koul" <vkoul@kernel.org>, "Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>, "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com> Subject: [PATCH v5 3/3] ALSA: compress: fix partial_drain completion state Date: Mon, 29 Jun 2020 19:17:37 +0530 [thread overview] Message-ID: <20200629134737.105993-4-vkoul@kernel.org> (raw) In-Reply-To: <20200629134737.105993-1-vkoul@kernel.org> On partial_drain completion we should be in SNDRV_PCM_STATE_RUNNING state, so set that for partially draining streams in snd_compr_drain_notify() and use a flag for partially draining streams While at it, add locks for stream state change in snd_compr_drain_notify() as well. Fixes: f44f2a5417b2 ("ALSA: compress: fix drain calls blocking other compress functions (v6)") Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Tested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Vinod Koul <vkoul@kernel.org> --- include/sound/compress_driver.h | 10 +++++++++- sound/core/compress_offload.c | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h index 3df8d8c90191..8d23351f7ad7 100644 --- a/include/sound/compress_driver.h +++ b/include/sound/compress_driver.h @@ -66,6 +66,7 @@ struct snd_compr_runtime { * @direction: stream direction, playback/recording * @metadata_set: metadata set flag, true when set * @next_track: has userspace signal next track transition, true when set + * @partial_drain: undergoing partial_drain for stream, true when set * @private_data: pointer to DSP private data * @dma_buffer: allocated buffer if any */ @@ -78,6 +79,7 @@ struct snd_compr_stream { enum snd_compr_direction direction; bool metadata_set; bool next_track; + bool partial_drain; void *private_data; struct snd_dma_buffer dma_buffer; }; @@ -187,7 +189,13 @@ static inline void snd_compr_drain_notify(struct snd_compr_stream *stream) if (snd_BUG_ON(!stream)) return; - stream->runtime->state = SNDRV_PCM_STATE_SETUP; + /* for partial_drain case we are back to running state on success */ + if (stream->partial_drain) { + stream->runtime->state = SNDRV_PCM_STATE_RUNNING; + stream->partial_drain = false; /* clear this flag as well */ + } else { + 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 e618580feac4..1c4b2cf450a0 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -803,6 +803,9 @@ static int snd_compr_stop(struct snd_compr_stream *stream) retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); if (!retval) { + /* clear flags and stop any drain wait */ + stream->partial_drain = false; + stream->metadata_set = false; snd_compr_drain_notify(stream); stream->runtime->total_bytes_available = 0; stream->runtime->total_bytes_transferred = 0; @@ -960,6 +963,7 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) if (stream->next_track == false) return -EPERM; + stream->partial_drain = true; retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN); if (retval) { pr_debug("Partial drain returned failure\n"); -- 2.26.2
next prev parent reply other threads:[~2020-06-29 21:40 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-29 13:47 [PATCH v5 0/3] ALSA: compress: Document stream states and fix gapless SM Vinod Koul 2020-06-29 13:47 ` Vinod Koul 2020-06-29 13:47 ` [PATCH v5 1/3] ALSA: compress: document the compress audio state machine Vinod Koul 2020-06-29 13:47 ` Vinod Koul 2020-07-07 9:54 ` Takashi Iwai 2020-07-07 9:54 ` Takashi Iwai 2020-06-29 13:47 ` [PATCH v5 2/3] ALSA: compress: document the compress gapless " Vinod Koul 2020-06-29 13:47 ` Vinod Koul 2020-07-07 9:54 ` Takashi Iwai 2020-07-07 9:54 ` Takashi Iwai 2020-06-29 13:47 ` Vinod Koul [this message] 2020-06-29 13:47 ` [PATCH v5 3/3] ALSA: compress: fix partial_drain completion state Vinod Koul 2020-07-01 14:20 ` Charles Keepax 2020-07-01 14:20 ` Charles Keepax 2020-07-01 15:04 ` Vinod Koul 2020-07-01 15:04 ` Vinod Koul 2020-07-07 9:55 ` Takashi Iwai 2020-07-07 9:55 ` Takashi Iwai
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=20200629134737.105993-4-vkoul@kernel.org \ --to=vkoul@kernel.org \ --cc=alsa-devel@alsa-project.org \ --cc=amadeuszx.slawinski@linux.intel.com \ --cc=ckeepax@opensource.cirrus.com \ --cc=linux-kernel@vger.kernel.org \ --cc=perex@perex.cz \ --cc=pierre-louis.bossart@linux.intel.com \ --cc=srinivas.kandagatla@linaro.org \ --cc=tiwai@suse.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.