a2dp-source: improve info parsing

Make sure we handle NULL info.
Simplify the property parsing.
This commit is contained in:
Wim Taymans 2021-03-30 09:24:35 +02:00
parent e7f2f450ff
commit 43317f67ba

View file

@ -1309,8 +1309,12 @@ impl_init(const struct spa_handle_factory *factory,
spa_list_init(&port->ready);
spa_list_init(&port->free);
if (info && (str = spa_dict_lookup(info, SPA_KEY_API_BLUEZ5_TRANSPORT)))
sscanf(str, "pointer:%p", &this->transport);
if (info != NULL) {
if ((str = spa_dict_lookup(info, SPA_KEY_API_BLUEZ5_TRANSPORT)) != NULL)
sscanf(str, "pointer:%p", &this->transport);
if ((str = spa_dict_lookup(info, "bluez5.a2dp-source-role")) != NULL)
this->is_input = strcmp(str, "input") == 0;
}
if (this->transport == NULL) {
spa_log_error(this->log, "a transport is needed");
@ -1325,13 +1329,6 @@ impl_init(const struct spa_handle_factory *factory,
this->codec_props = this->codec->init_props(this->codec,
this->transport->device->settings);
const char *a2dp_source_role = spa_dict_lookup(info, "bluez5.a2dp-source-role");
if (a2dp_source_role != NULL && !strcmp("input", a2dp_source_role))
this->is_input = true;
else
this->is_input = false;
return 0;
}