bluetooth: Register an endpoint according to encode or decode support

As we now support codecs other than SBC, we might have codec which does
not have an encode or a decode capability. Specifically, in the case of
LDAC there isn't a known decoder implementation available. For such a
case, we should not register the corresponding endpoint.

In case of LDAC, as decoding cannot be supported, we should not register
a sink endpoint or vice versa in the other scenario.

To do this, we check if encode_buffer or decode_buffer entry for a codec
has been set in pa_a2dp_codec and accordingly prevent or allow it's
registration.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440>
This commit is contained in:
Sanchayan Maity 2021-01-07 17:52:22 +05:30
parent 366bd5615c
commit ed44fa1856
3 changed files with 54 additions and 20 deletions

View file

@ -88,3 +88,17 @@ void pa_bluetooth_a2dp_codec_gst_init(void) {
pa_log_info("GStreamer initialisation done");
#endif
}
bool pa_bluetooth_a2dp_codec_is_codec_available(const pa_a2dp_codec_id *id, bool is_a2dp_sink) {
unsigned int i;
unsigned int count = pa_bluetooth_a2dp_codec_count();
for (i = 0; i < count; i++) {
if (memcmp(id, &pa_a2dp_codecs[i]->id, sizeof(pa_a2dp_codec_id)) == 0) {
return (is_a2dp_sink && pa_a2dp_codecs[i]->encode_buffer != NULL)
|| (!is_a2dp_sink && pa_a2dp_codecs[i]->decode_buffer != NULL);
}
}
return false;
}