bluetooth: Add missing can_be_supported check to is_codec_available

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/479>
This commit is contained in:
Marijn Suijten 2021-01-20 00:07:48 +01:00
parent 519052e77e
commit ac33a01f30
3 changed files with 8 additions and 7 deletions

View file

@ -89,15 +89,16 @@ void pa_bluetooth_a2dp_codec_gst_init(void) {
#endif
}
bool pa_bluetooth_a2dp_codec_is_codec_available(const pa_a2dp_codec_id *id, bool is_a2dp_sink) {
bool pa_bluetooth_a2dp_codec_is_available(const pa_a2dp_codec_id *id, bool is_a2dp_sink) {
unsigned int i;
unsigned int count = pa_bluetooth_a2dp_codec_count();
const pa_a2dp_codec *a2dp_codec;
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);
}
a2dp_codec = pa_bluetooth_a2dp_codec_iter(i);
if (memcmp(id, &a2dp_codec->id, sizeof(pa_a2dp_codec_id)) == 0
&& a2dp_codec->can_be_supported(is_a2dp_sink))
return true;
}
return false;