From 36e036db228a9a8b8bff084ec7c5d5bf232b0eb4 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 19 Jan 2021 23:05:22 +0100 Subject: [PATCH] bluetooth: Do not re-retrieve codecs in switch_codec The desired list of capabilities is provided by the caller; if an endpoint is successfully selected that endpoint resides in this hashmap. Perhaps choose_remote_endpoint should return the key-value pair instead? --- src/modules/bluetooth/bluez5-util.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c index 2431b3831..76e20f487 100644 --- a/src/modules/bluetooth/bluez5-util.c +++ b/src/modules/bluetooth/bluez5-util.c @@ -447,7 +447,6 @@ bool pa_bluetooth_device_switch_codec(pa_bluetooth_device *device, pa_bluetooth_ uint8_t config[MAX_A2DP_CAPS_SIZE]; uint8_t config_size; bool is_a2dp_sink; - pa_hashmap *all_endpoints; char *pa_endpoint; const char *endpoint; @@ -462,13 +461,8 @@ bool pa_bluetooth_device_switch_codec(pa_bluetooth_device *device, pa_bluetooth_ is_a2dp_sink = profile == PA_BLUETOOTH_PROFILE_A2DP_SINK; - all_endpoints = NULL; - all_endpoints = pa_hashmap_get(is_a2dp_sink ? device->a2dp_sink_endpoints : device->a2dp_source_endpoints, - &endpoint_conf->id); - pa_assert(all_endpoints); - pa_assert_se(endpoint = endpoint_conf->choose_remote_endpoint(capabilities_hashmap, &device->discovery->core->default_sample_spec, is_a2dp_sink)); - pa_assert_se(capabilities = pa_hashmap_get(all_endpoints, endpoint)); + pa_assert_se(capabilities = pa_hashmap_get(capabilities_hashmap, endpoint)); config_size = endpoint_conf->fill_preferred_configuration(&device->discovery->core->default_sample_spec, capabilities->buffer, capabilities->size, config);