Re: [PATCH 10/11] ASoC: qdsp6-dai: add gapless support

From: Pierre-Louis Bossart
Date: Wed Jul 08 2020 - 12:58:32 EST



right, but the key point is 'switch between streams'. That means a more complex/capable implementation that should be advertised as such to applications. This is not the default behavior assumed initially: to allow for minimal implementations in memory-constrained devices, we assumed gapless was supported with a single decoder.

Maybe the right way to do this is extend the snd_compr_caps structure:

/**
ÂÂ* struct snd_compr_caps - caps descriptor
ÂÂ* @codecs: pointer to array of codecs
ÂÂ* @direction: direction supported. Of type snd_compr_direction
ÂÂ* @min_fragment_size: minimum fragment supported by DSP
ÂÂ* @max_fragment_size: maximum fragment supported by DSP
ÂÂ* @min_fragments: min fragments supported by DSP
ÂÂ* @max_fragments: max fragments supported by DSP
ÂÂ* @num_codecs: number of codecs supported
ÂÂ* @reserved: reserved field
ÂÂ*/
struct snd_compr_caps {
ÂÂÂÂÂ__u32 num_codecs;
ÂÂÂÂÂ__u32 direction;
ÂÂÂÂÂ__u32 min_fragment_size;
ÂÂÂÂÂ__u32 max_fragment_size;
ÂÂÂÂÂ__u32 min_fragments;
ÂÂÂÂÂ__u32 max_fragments;
ÂÂÂÂÂ__u32 codecs[MAX_NUM_CODECS];
ÂÂÂÂÂ__u32 reserved[11];
} __attribute__((packed, aligned(4)));


and use a reserved field to provide info on capabilities, and filter the set_codec_params() addition based this capability - i.e. return -ENOTSUP in 'traditional' implementations based on a single 'stream'/decoder instance.

I think this is also what Mark was referring to earlier.

Sounds good!
I will give it a go and see how it ends up!

Glad to see this discussion progressing.

We may also want to document the 3 possible ways of supporting gapless playback while we are at it:
a) with the existing single decoder assumption
b) with your suggested solution with a switch at the DSP level
c) with 2 streams at the userspace level and a switch/x-fade at the DSP level - which may simplify userspace quite a bit and was the initial design in a non-Linux OS.