Filter codecs to by their capabilities in addition to merely checking codec ID, when retrieved through the
@SanchayanMaity this MR is just to showcase what I intended to say at !440 (comment 770673); right now when there is a single endpoint that supports a given codec, all quality variants for that codec will be emitted by the loop over static codecs - even if the device might not support some of those capabilities.
Note that these loops emit duplicates if the peer exposes multiple endpoints for identical codecs whose capabilities match multiple codecs on our side (for the time being we only have multiple quality variants for LDAC).
EDIT: We should really invert it by looping over codecs instead, and emit+break when the first matching endpoint is found. The second commit introduces
pa_bluetooth_a2dp_codec_find_first to make that possible.
But how about simply adding a pointer to static
pa_a2dp_codec in the endpoint, so that we only have to perform lookup and compatibility checking once in
parse_remote_endpoint_properties? Then we don't need to perform any such filtering in
list_codecs and other places either.
We can also make the codec list two-deep: a unique mapping of codec ids on the first leve to objects containing the generic functions, all containing a list of codec variants (capabilities). Perhaps we should look into that as part of the SBC-variations that are also being worked on in parallel?
EDIT2: Pushed the pointer way, including more rigorous matching of codecs against the provided endpoint by means of capability support.