mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
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:
parent
8816b6b05b
commit
519052e77e
6 changed files with 37 additions and 38 deletions
|
|
@ -2108,21 +2108,21 @@ static DBusHandlerResult object_manager_handler(DBusConnection *c, DBusMessage *
|
|||
char *endpoint;
|
||||
|
||||
a2dp_codec = pa_bluetooth_a2dp_codec_iter(i);
|
||||
if (!a2dp_codec->can_be_supported())
|
||||
continue;
|
||||
|
||||
codec_id = a2dp_codec->id.codec_id;
|
||||
capabilities_size = a2dp_codec->fill_capabilities(capabilities);
|
||||
pa_assert(capabilities_size != 0);
|
||||
|
||||
if (a2dp_codec->decode_buffer != NULL) {
|
||||
if (a2dp_codec->can_be_supported(false)) {
|
||||
capabilities_size = a2dp_codec->fill_capabilities(capabilities);
|
||||
pa_assert(capabilities_size != 0);
|
||||
endpoint = pa_sprintf_malloc("%s/%s", A2DP_SINK_ENDPOINT, a2dp_codec->name);
|
||||
append_a2dp_object(&array, endpoint, PA_BLUETOOTH_UUID_A2DP_SINK, codec_id,
|
||||
capabilities, capabilities_size);
|
||||
pa_xfree(endpoint);
|
||||
}
|
||||
|
||||
if (a2dp_codec->encode_buffer != NULL) {
|
||||
if (a2dp_codec->can_be_supported(true)) {
|
||||
capabilities_size = a2dp_codec->fill_capabilities(capabilities);
|
||||
pa_assert(capabilities_size != 0);
|
||||
endpoint = pa_sprintf_malloc("%s/%s", A2DP_SOURCE_ENDPOINT, a2dp_codec->name);
|
||||
append_a2dp_object(&array, endpoint, PA_BLUETOOTH_UUID_A2DP_SOURCE, codec_id,
|
||||
capabilities, capabilities_size);
|
||||
|
|
@ -2222,16 +2222,13 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c, int headset_backe
|
|||
count = pa_bluetooth_a2dp_codec_count();
|
||||
for (i = 0; i < count; i++) {
|
||||
a2dp_codec = pa_bluetooth_a2dp_codec_iter(i);
|
||||
if (!a2dp_codec->can_be_supported())
|
||||
continue;
|
||||
|
||||
if (a2dp_codec->decode_buffer != NULL) {
|
||||
if (a2dp_codec->can_be_supported(false)) {
|
||||
endpoint = pa_sprintf_malloc("%s/%s", A2DP_SINK_ENDPOINT, a2dp_codec->name);
|
||||
endpoint_init(y, endpoint);
|
||||
pa_xfree(endpoint);
|
||||
}
|
||||
|
||||
if (a2dp_codec->encode_buffer != NULL) {
|
||||
if (a2dp_codec->can_be_supported(true)) {
|
||||
endpoint = pa_sprintf_malloc("%s/%s", A2DP_SOURCE_ENDPOINT, a2dp_codec->name);
|
||||
endpoint_init(y, endpoint);
|
||||
pa_xfree(endpoint);
|
||||
|
|
@ -2316,16 +2313,13 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
|
|||
for (i = 0; i < count; i++) {
|
||||
a2dp_codec = pa_bluetooth_a2dp_codec_iter(i);
|
||||
|
||||
if (!a2dp_codec->can_be_supported())
|
||||
continue;
|
||||
|
||||
if (a2dp_codec->decode_buffer != NULL) {
|
||||
if (a2dp_codec->can_be_supported(false)) {
|
||||
endpoint = pa_sprintf_malloc("%s/%s", A2DP_SINK_ENDPOINT, a2dp_codec->name);
|
||||
endpoint_done(y, endpoint);
|
||||
pa_xfree(endpoint);
|
||||
}
|
||||
|
||||
if (a2dp_codec->encode_buffer != NULL) {
|
||||
if (a2dp_codec->can_be_supported(true)) {
|
||||
endpoint = pa_sprintf_malloc("%s/%s", A2DP_SOURCE_ENDPOINT, a2dp_codec->name);
|
||||
endpoint_done(y, endpoint);
|
||||
pa_xfree(endpoint);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue