From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Jaroslav Kysela <perex@perex.cz>, vkoul@kernel.org
Cc: tiwai@suse.com, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org, broonie@kernel.org
Subject: Re: [RFC PATCH] ALSA: compress: Fix gapless playback state machine
Date: Wed, 10 Jun 2020 11:56:58 +0100 [thread overview]
Message-ID: <683a67bc-44e8-1e2b-b9a4-29e71ce86fdc@linaro.org> (raw)
In-Reply-To: <817d009e-fa09-e897-cfc3-997bf1dd5e30@perex.cz>
On 10/06/2020 11:40, Jaroslav Kysela wrote:
> Dne 10. 06. 20 v 12:07 Srinivas Kandagatla napsal(a):
>> For gapless playback call to snd_compr_drain_notify() after
>> partial drain should put the state to SNDRV_PCM_STATE_RUNNING
>> rather than SNDRV_PCM_STATE_SETUP as the driver is ready to
>> process the buffers for new track.
>>
>> With existing code, if we are playing 3 tracks in gapless, after
>> partial drain finished on previous track 1 the state is set to
>> SNDRV_PCM_STATE_SETUP which is then moved to SNDRV_PCM_STATE_PREPARED
>> after data write. With this state calls to snd_compr_next_track() and
>> few other calls will fail as they expect the state to be in
>> SNDRV_PCM_STATE_RUNNING.
>>
>> Here is the sequence of events and state transitions:
>>
>> 1. set_params (Track 1), state = SNDRV_PCM_STATE_SETUP
>> 2. set_metadata (Track 1), no state change, state = SNDRV_PCM_STATE_SETUP
>> 3. fill and trigger start (Track 1), state = SNDRV_PCM_STATE_RUNNING
>> 4. set_next_track (Track 2), state = SNDRV_PCM_STATE_RUNNING
>> 5. partial_drain (Track 1), state = SNDRV_PCM_STATE_SETUP
>> 6 snd_compr_drain_notify (Track 1), state = SNDRV_PCM_STATE_SETUP
>> 7. fill data (Track 2), state = SNDRV_PCM_STATE_PREPARED
>> 8. set_metadata (Track 3), no state change, state =
>> SNDRV_PCM_STATE_PREPARED
>> 9. set_next_track (Track 3), !! FAILURE as state !=
>> SNDRV_PCM_STATE_RUNNING
>
>
> The snd_compr_drain_notify() is called only from snd_compr_stop().
> Something is missing in this sequence?
snd_compr_drain_notify() can also be called by drivers to notify when
partial drain is finished. In this case its called from qcom compress
driver.
--srini
>
> Jaroslav
>
>
>
>>
>> Fixes: f44f2a5417b2 ("ALSA: compress: fix drain calls blocking other
>> compress functions (v6)")
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>>
>> I wonder who did gapless work on upstream so far?
>>
>> include/sound/compress_driver.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/sound/compress_driver.h
>> b/include/sound/compress_driver.h
>> index 6ce8effa0b12..eabac33864c2 100644
>> --- a/include/sound/compress_driver.h
>> +++ b/include/sound/compress_driver.h
>> @@ -182,7 +182,7 @@ 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;
>> + stream->runtime->state = SNDRV_PCM_STATE_RUNNING;
>> wake_up(&stream->runtime->sleep);
>> }
>>
>
>
next prev parent reply other threads:[~2020-06-10 10:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 10:07 Srinivas Kandagatla
2020-06-10 10:40 ` Jaroslav Kysela
2020-06-10 10:56 ` Srinivas Kandagatla [this message]
2020-06-10 10:58 ` Vinod Koul
2020-06-11 8:46 ` Charles Keepax
2020-06-11 9:09 ` Jaroslav Kysela
2020-06-11 9:44 ` Vinod Koul
2020-06-11 10:40 ` Jaroslav Kysela
2020-06-11 11:02 ` Vinod Koul
2020-06-11 10:42 ` Charles Keepax
2020-06-11 11:05 ` Vinod Koul
2020-06-10 12:56 ` Pierre-Louis Bossart
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=683a67bc-44e8-1e2b-b9a4-29e71ce86fdc@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=vkoul@kernel.org \
/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
all inboxes | Powered by JetHome®