From: Vinod Koul <vkoul@kernel.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Takashi Iwai <tiwai@suse.de>,
broonie@kernel.org, tiwai@suse.com, corbet@lwn.net,
alsa-devel@alsa-project.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, quic_plai@quicinc.com,
quic_mohs@quicinc.com
Subject: Re: [PATCH v2] ALSA: compress: allow setting codec params after next track
Date: Wed, 14 Jun 2023 17:59:28 +0530 [thread overview]
Message-ID: <ZImyqMsNUrzqjuk/@matsya> (raw)
In-Reply-To: <5e9e525a-690d-38ce-d80f-da433d4062fd@linaro.org>
On 14-06-23, 12:55, Srinivas Kandagatla wrote:
> Thanks Takashi for review,
>
> On 14/06/2023 08:04, Takashi Iwai wrote:
> > On Fri, 09 Jun 2023 17:04:16 +0200,
> > Srinivas Kandagatla wrote:
> > >
> > > For gapless playback it is possible that each track can have different
> > > codec profile with same decoder, for example we have WMA album,
> > > we may have different tracks as WMA v9, WMA v10 and so on
> > >
> > > Or if DSP's like QDSP have abililty to switch decoders on single stream
> > > for each track, then this call could be used to set new codec parameters.
> > >
> > > Existing code does not allow to change this profile while doing gapless
> > > playback.
> > >
> > > Reuse existing SNDRV_COMPRESS_SET_PARAMS to set this new track params along
> > > some additional checks to enforce proper state machine.
> > >
> > > With this new changes now the user can call SNDRV_COMPRESS_SET_PARAMS
> > > anytime after setting next track and additional check in write should
> > > also ensure that params are set before writing new data.
> > >
> > > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > > ---
> > > Changes since v1/RFC:
> > > - removed introduction of new IOCTL, as suggested.
> > > - update the state-machine doc.
> > >
> > > .../sound/designs/compress-offload.rst | 52 +++++++++----------
> > > sound/core/compress_offload.c | 10 ++--
> > > 2 files changed, 33 insertions(+), 29 deletions(-)
> > >
> > > diff --git a/Documentation/sound/designs/compress-offload.rst b/Documentation/sound/designs/compress-offload.rst
> > > index 935f325dbc77..205cadcabe70 100644
> > > --- a/Documentation/sound/designs/compress-offload.rst
> > > +++ b/Documentation/sound/designs/compress-offload.rst
> > > @@ -256,32 +256,32 @@ Gapless Playback SM
> > > For Gapless, we move from running state to partial drain and back, along
> > > with setting of meta_data and signalling for next track ::
> > > -
> > > - +----------+
> > > - compr_drain_notify() | |
> > > - +------------------------>| RUNNING |
> > > - | | |
> > > - | +----------+
> > > - | |
> > > - | |
> > > - | | compr_next_track()
> > > - | |
> > > - | V
> > > - | +----------+
> > > - | | |
> > > - | |NEXT_TRACK|
> > > - | | |
> > > - | +----------+
> > > - | |
> > > - | |
> > > - | | compr_partial_drain()
> > > - | |
> > > - | V
> > > - | +----------+
> > > - | | |
> > > - +------------------------ | PARTIAL_ |
> > > - | DRAIN |
> > > - +----------+
> > > + +----------+
> > > + compr_drain_notify() | | compr_set_params() iff next-track set.
> > > + +------------------------>| RUNNING |----------------------+
> > > + | | | |
> > > + | +----------+ |
> > > + | | |
> > > + | | |
> > > + | | compr_next_track() |
> > > + | | V
> > > + | V |
> > > + | +----------+ |
> > > + | | | |
> > > + | |NEXT_TRACK| |
> > > + | | | |
> > > + | +----------+ |
> > > + | | |
> > > + | +----------------------------+
> > > + | |
> > > + | | compr_partial_drain()
> > > + | |
> > > + | V
> > > + | +----------+
> > > + | | |
> > > + +------------------------ | PARTIAL_ |
> > > + | DRAIN |
> > > + +----------+
> > > Not supported
> > > =============
> > > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> > > index 243acad89fd3..fe67228e74b3 100644
> > > --- a/sound/core/compress_offload.c
> > > +++ b/sound/core/compress_offload.c
> > > @@ -294,6 +294,9 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf,
> > > case SNDRV_PCM_STATE_SETUP:
> > > case SNDRV_PCM_STATE_PREPARED:
> > > case SNDRV_PCM_STATE_RUNNING:
> > > + /* Make sure next track params are set before writing new data */
> > > + if (stream->next_track)
> > > + return -EPERM;
> >
> > Hm, does this logic correctly match with the comment above?
> Yes I agree, it bit confusing and also going to break the partial drain
> path.
> > Also, this misses the mutex unlock.
>
> Thinking about this again, Its not required have this check here to start
> with.
>
> Something like below works, I can send this as v3, if this looks fine.
>
> ------------------------->cut<----------------------------------
>
> diff --git a/Documentation/sound/designs/compress-offload.rst
> b/Documentation/sound/designs/compress-offload.rst
> index 935f325dbc77..655624f77092 100644
> --- a/Documentation/sound/designs/compress-offload.rst
> +++ b/Documentation/sound/designs/compress-offload.rst
> @@ -268,11 +268,12 @@ with setting of meta_data and signalling for next
> track ::
> | |
> | V
> | +----------+
> - | | |
> - | |NEXT_TRACK|
> - | | |
> - | +----------+
> - | |
> + | compr_set_params() | |
> + | +-----------|NEXT_TRACK|
> + | | | |
> + | | +--+-------+
> + | | | |
> + | +--------------+ |
> | |
> | | compr_partial_drain()
> | |
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index 243acad89fd3..30f73097447b 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -589,7 +589,7 @@ snd_compr_set_params(struct snd_compr_stream *stream,
> unsigned long arg)
> struct snd_compr_params *params;
> int retval;
>
> - if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
> + if (stream->runtime->state == SNDRV_PCM_STATE_OPEN ||
> stream->next_track) {
Yes this would be my idea for this as well, allow params to be set when
we have signalled partial drain
> /*
> * we should allow parameter change only when stream has
> been
> * opened not in other cases
> @@ -612,6 +612,9 @@ snd_compr_set_params(struct snd_compr_stream *stream,
> unsigned long arg)
> if (retval)
> goto out;
>
> + if (stream->next_track)
> + goto out;
> +
> stream->metadata_set = false;
> stream->next_track = false;
> ------------------------->cut<----------------------------------
>
> >
> >
> > thanks,
> >
> > Takashi
--
~Vinod
prev parent reply other threads:[~2023-06-14 12:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 15:04 [PATCH v2] ALSA: compress: allow setting codec params after next track Srinivas Kandagatla
2023-06-14 7:04 ` Takashi Iwai
2023-06-14 11:55 ` Srinivas Kandagatla
2023-06-14 12:29 ` Vinod Koul [this message]
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=ZImyqMsNUrzqjuk/@matsya \
--to=vkoul@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_mohs@quicinc.com \
--cc=quic_plai@quicinc.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.com \
--cc=tiwai@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).