From 2fc7aea2dc6e4b58730af310b2930e810b41620f 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 5f941f03c..b0a16182c 100644 --- a/src/modules/bluetooth/bluez5-util.c +++ b/src/modules/bluetooth/bluez5-util.c @@ -436,7 +436,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; @@ -451,13 +450,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);