From 43317f67ba29f356f740d1bff7cb14d216186417 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 30 Mar 2021 09:24:35 +0200 Subject: [PATCH] a2dp-source: improve info parsing Make sure we handle NULL info. Simplify the property parsing. --- spa/plugins/bluez5/a2dp-source.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index f57d3f376..51f49565c 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -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; }