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.