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?
This commit is contained in:
Marijn Suijten 2021-01-19 23:05:22 +01:00
parent f2b748e851
commit 36e036db22

View file

@ -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);