Skip to content

WIP: bluetooth/a2dp: Only list codecs with matching capabilities in list_codecs

Filter codecs to by their capabilities in addition to merely checking codec ID, when retrieved through the list-codecs message.

@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.


  • Turning it into a pointer might be weird when the "fallback" mechanism comes online and we have multiple theoretical applicable codecs for a single endpoint;
  • The extra loop introduced here is effectively choose_remote_endpoint.

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.

Edited by Marijn Suijten

Merge request reports