ALSA: compress: allow setting codec params after next track
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Mon, 19 Jun 2023 09:28:05 +0000 (10:28 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 21 Jun 2023 05:28:31 +0000 (07:28 +0200)
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>
Acked-by: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20230619092805.21649-1-srinivas.kandagatla@linaro.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Documentation/sound/designs/compress-offload.rst
sound/core/compress_offload.c

index 935f325dbc773a8b63edaf84f86e05315a1e315d..655624f770921ba0445251e89a9b17be3f9e5764 100644 (file)
@@ -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()
               |                              |
index 243acad89fd3bc01d6171c56779ee7699560891f..30f73097447ba89a6a550357003605eaaf8dab4d 100644 (file)
@@ -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) {
                /*
                 * 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;