aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2022-02-25 13:38:24 +0000
committerSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2023-06-02 15:36:55 +0100
commit022cff9e3a77827e0cd537a3e35cf7a569d13c27 (patch)
tree344133d96718fed13bd7cc5d2662980a18f99b80
parentb55c9c69947cf351f6053fd4e3d88ff547e489ef (diff)
ALSA: compress: allow setting codec params after next trackaudioreach/compress-offload
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>
-rw-r--r--Documentation/sound/designs/compress-offload.rst62
-rw-r--r--sound/core/compress_offload.c7
2 files changed, 41 insertions, 28 deletions
diff --git a/Documentation/sound/designs/compress-offload.rst b/Documentation/sound/designs/compress-offload.rst
index 935f325dbc773..1ade8bb078eb3 100644
--- a/Documentation/sound/designs/compress-offload.rst
+++ b/Documentation/sound/designs/compress-offload.rst
@@ -256,32 +256,42 @@ 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 |
+ | +----------+ |
+ | compr_partial_drain | | |
+ | +------------------|NEXT_TRACK| |
+ | | | | |
+ | | +----------+ |
+ | | | |
+ | | +----------------------------+
+ | | | compr_set_params()
+ | V |
+ | | V
+ | | +----------+
+ | | | |
+ | | | SETUP |
+ | | | |
+ | | +----------+
+ | | |
+ | +-----------------------+
+ | |
+ | | compr_partial_drain()
+ | |
+ | V
+ | +----------+
+ | | |
+ +------------------------ | PARTIAL_ |
+ | DRAIN |
+ +----------+
Not supported
=============
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 243acad89fd3b..1a3e5154bedcf 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;
break;
default:
mutex_unlock(&stream->device->lock);
@@ -589,7 +592,8 @@ 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->runtime->state == SNDRV_PCM_STATE_RUNNING && stream->next_track)) {
/*
* we should allow parameter change only when stream has been
* opened not in other cases
@@ -956,7 +960,6 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
return retval;
}
- stream->next_track = false;
return snd_compress_wait_for_drain(stream);
}