Make use of new set_codec_params callback to allow decoder switching
during gapless playback.
Signed-off-by: Srinivas Kandagatla <[email protected]>
---
sound/soc/qcom/qdsp6/q6asm-dai.c | 33 ++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
index b5c719682919..a8cfb1996614 100644
--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -876,6 +876,37 @@ static int __q6asm_dai_compr_set_codec_params(struct snd_soc_component *componen
return 0;
}
+static int q6asm_dai_compr_set_codec_params(struct snd_soc_component *component,
+ struct snd_compr_stream *stream,
+ struct snd_codec *codec)
+{
+ struct snd_compr_runtime *runtime = stream->runtime;
+ struct q6asm_dai_rtd *prtd = runtime->private_data;
+ int ret;
+
+ ret = q6asm_open_write(prtd->audio_client, prtd->next_track_stream_id,
+ codec->id, codec->profile, prtd->bits_per_sample,
+ true);
+ if (ret < 0) {
+ pr_err("q6asm_open_write failed\n");
+ return ret;
+ }
+
+ ret = __q6asm_dai_compr_set_codec_params(component, stream, codec,
+ prtd->next_track_stream_id);
+ if (ret < 0) {
+ pr_err("q6asm_open_write failed\n");
+ return ret;
+ }
+
+ ret = q6asm_stream_remove_initial_silence(prtd->audio_client,
+ prtd->next_track_stream_id,
+ prtd->initial_samples_drop);
+ prtd->next_track_stream_id = 0;
+
+ return ret;
+}
+
static int q6asm_dai_compr_set_params(struct snd_soc_component *component,
struct snd_compr_stream *stream,
struct snd_compr_params *params)
@@ -1144,6 +1175,7 @@ static int q6asm_dai_compr_get_caps(struct snd_soc_component *component,
caps->max_fragment_size = COMPR_PLAYBACK_MAX_FRAGMENT_SIZE;
caps->min_fragments = COMPR_PLAYBACK_MIN_NUM_FRAGMENTS;
caps->max_fragments = COMPR_PLAYBACK_MAX_NUM_FRAGMENTS;
+ caps->flags = SND_COMPR_CAP_FLAGS_DSP_CAN_SWITCH_DECODER;
caps->num_codecs = 5;
caps->codecs[0] = SND_AUDIOCODEC_MP3;
caps->codecs[1] = SND_AUDIOCODEC_FLAC;
@@ -1173,6 +1205,7 @@ static struct snd_compress_ops q6asm_dai_compress_ops = {
.open = q6asm_dai_compr_open,
.free = q6asm_dai_compr_free,
.set_params = q6asm_dai_compr_set_params,
+ .set_codec_params = q6asm_dai_compr_set_codec_params,
.set_metadata = q6asm_dai_compr_set_metadata,
.pointer = q6asm_dai_compr_pointer,
.trigger = q6asm_dai_compr_trigger,
--
2.21.0
On 7/21/20 12:00 PM, Srinivas Kandagatla wrote:
> Make use of new set_codec_params callback to allow decoder switching
> during gapless playback.
>
> Signed-off-by: Srinivas Kandagatla <[email protected]>
> ---
> sound/soc/qcom/qdsp6/q6asm-dai.c | 33 ++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
> index b5c719682919..a8cfb1996614 100644
> --- a/sound/soc/qcom/qdsp6/q6asm-dai.c
> +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
> @@ -876,6 +876,37 @@ static int __q6asm_dai_compr_set_codec_params(struct snd_soc_component *componen
> return 0;
> }
>
> +static int q6asm_dai_compr_set_codec_params(struct snd_soc_component *component,
> + struct snd_compr_stream *stream,
> + struct snd_codec *codec)
> +{
> + struct snd_compr_runtime *runtime = stream->runtime;
> + struct q6asm_dai_rtd *prtd = runtime->private_data;
> + int ret;
> +
> + ret = q6asm_open_write(prtd->audio_client, prtd->next_track_stream_id,
> + codec->id, codec->profile, prtd->bits_per_sample,
> + true);
> + if (ret < 0) {
> + pr_err("q6asm_open_write failed\n");
> + return ret;
> + }
> +
> + ret = __q6asm_dai_compr_set_codec_params(component, stream, codec,
> + prtd->next_track_stream_id);
> + if (ret < 0) {
> + pr_err("q6asm_open_write failed\n");
> + return ret;
> + }
> +
> + ret = q6asm_stream_remove_initial_silence(prtd->audio_client,
> + prtd->next_track_stream_id,
> + prtd->initial_samples_drop);
> + prtd->next_track_stream_id = 0;
same comment as in the other patchset, the stream_id toggles between 1
and 2, it's not clear to me what 0 means.
off-by-one bug or feature?
Thanks Pierre for quick review.
On 21/07/2020 21:09, Pierre-Louis Bossart wrote:
>
>
> On 7/21/20 12:00 PM, Srinivas Kandagatla wrote:
>> Make use of new set_codec_params callback to allow decoder switching
>> during gapless playback.
>>
>> Signed-off-by: Srinivas Kandagatla <[email protected]>
>> ---
>> sound/soc/qcom/qdsp6/q6asm-dai.c | 33 ++++++++++++++++++++++++++++++++
>> 1 file changed, 33 insertions(+)
>>
>> diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c
>> b/sound/soc/qcom/qdsp6/q6asm-dai.c
>> index b5c719682919..a8cfb1996614 100644
>> --- a/sound/soc/qcom/qdsp6/q6asm-dai.c
>> +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
>> @@ -876,6 +876,37 @@ static int
>> __q6asm_dai_compr_set_codec_params(struct snd_soc_component *componen
>> return 0;
>> }
>> +static int q6asm_dai_compr_set_codec_params(struct snd_soc_component
>> *component,
>> + struct snd_compr_stream *stream,
>> + struct snd_codec *codec)
>> +{
>> + struct snd_compr_runtime *runtime = stream->runtime;
>> + struct q6asm_dai_rtd *prtd = runtime->private_data;
>> + int ret;
>> +
>> + ret = q6asm_open_write(prtd->audio_client,
>> prtd->next_track_stream_id,
>> + codec->id, codec->profile, prtd->bits_per_sample,
>> + true);
>> + if (ret < 0) {
>> + pr_err("q6asm_open_write failed\n");
>> + return ret;
>> + }
>> +
>> + ret = __q6asm_dai_compr_set_codec_params(component, stream, codec,
>> + prtd->next_track_stream_id);
>> + if (ret < 0) {
>> + pr_err("q6asm_open_write failed\n");
>> + return ret;
>> + }
>> +
>> + ret = q6asm_stream_remove_initial_silence(prtd->audio_client,
>> + prtd->next_track_stream_id,
>> + prtd->initial_samples_drop);
>> + prtd->next_track_stream_id = 0;
>
> same comment as in the other patchset, the stream_id toggles between 1
> and 2, it's not clear to me what 0 means.
Valid stream ids start from 1. to achieve gapless we toggle between 1 and 2.
--srini
>
> off-by-one bug or feature?
On Tue, Jul 21, 2020 at 8:03 PM Srinivas Kandagatla
<[email protected]> wrote:
>
> Make use of new set_codec_params callback to allow decoder switching
> during gapless playback.
>
> Signed-off-by: Srinivas Kandagatla <[email protected]>
> ---
> sound/soc/qcom/qdsp6/q6asm-dai.c | 33 ++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/sound/soc/qcom/qdsp6/q6asm-dai.c b/sound/soc/qcom/qdsp6/q6asm-dai.c
> index b5c719682919..a8cfb1996614 100644
> --- a/sound/soc/qcom/qdsp6/q6asm-dai.c
> +++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
> @@ -876,6 +876,37 @@ static int __q6asm_dai_compr_set_codec_params(struct snd_soc_component *componen
> return 0;
> }
>
> +static int q6asm_dai_compr_set_codec_params(struct snd_soc_component *component,
> + struct snd_compr_stream *stream,
> + struct snd_codec *codec)
> +{
> + struct snd_compr_runtime *runtime = stream->runtime;
> + struct q6asm_dai_rtd *prtd = runtime->private_data;
> + int ret;
> +
> + ret = q6asm_open_write(prtd->audio_client, prtd->next_track_stream_id,
> + codec->id, codec->profile, prtd->bits_per_sample,
> + true);
> + if (ret < 0) {
> + pr_err("q6asm_open_write failed\n");
Since you have component->dev here I think it is worth it to use
dev_err instead of pr_err.
Same for the rest of the code.