bluetooth: Check support for encoding and decoding separately

As suggested in [1]:

This way it is possible for a codec to have both the encoding and
decoding part optional, instead of getting both or nothing (where PA
theoretically supports both).

In addition this cleans up code that was previously checking the
existence of a function pointer, or nothing at all (switch_codec).

[1]: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/440#note_768146

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/479>
This commit is contained in:
Marijn Suijten 2021-01-19 23:20:07 +01:00
parent 8816b6b05b
commit 519052e77e
6 changed files with 37 additions and 38 deletions

View file

@ -2307,7 +2307,7 @@ static char *list_codecs(struct userdata *u) {
a2dp_codec = pa_bluetooth_a2dp_codec_iter(i);
if (memcmp(key, &a2dp_codec->id, sizeof(pa_a2dp_codec_id)) == 0) {
if (a2dp_codec->can_be_supported()) {
if (a2dp_codec->can_be_supported(is_a2dp_sink)) {
pa_message_params_begin_list(param);
pa_message_params_write_string(param, a2dp_codec->name);
@ -2383,13 +2383,13 @@ static int bluez5_device_message_handler(const char *object_path, const char *me
return -PA_ERR_INVALID;
}
if (!codec->can_be_supported()) {
is_a2dp_sink = u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK;
if (!u->a2dp_codec->can_be_supported(is_a2dp_sink)) {
pa_log_info("Codec not found on system");
return -PA_ERR_NOTSUPPORTED;
}
is_a2dp_sink = u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK;
/*
* We need to check if we have valid sink or source endpoints which
* were registered during the negotiation process. If we do, then we