From 7c84b1251d205e0f8c884eeeafab171409284cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Wed, 16 Sep 2020 14:28:28 +0200 Subject: [PATCH] bluez5: backend-hsphfpd: Fix transport release on disconnection Release transport when endpoint connection property is updated to false. This also checks if the transport is already created when receiving endpoint properties update to prevent multiple transport creation. --- spa/plugins/bluez5/backend-hsphfpd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spa/plugins/bluez5/backend-hsphfpd.c b/spa/plugins/bluez5/backend-hsphfpd.c index 906266b3e..847ad2494 100644 --- a/spa/plugins/bluez5/backend-hsphfpd.c +++ b/spa/plugins/bluez5/backend-hsphfpd.c @@ -1009,6 +1009,17 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct spa_bt_backend return DBUS_HANDLER_RESULT_HANDLED; } + if ((t = spa_bt_transport_find(backend->monitor, endpoint->path)) != NULL) { + if (!endpoint->connected) { + spa_bt_transport_free(t); + spa_bt_device_check_profiles(d, false); + spa_log_debug(backend->log, "Transport released for %s", endpoint->path); + } else + spa_log_debug(backend->log, "Transport already configured for %s", endpoint->path); + + return DBUS_HANDLER_RESULT_HANDLED; + } + if (!endpoint->valid || !endpoint->connected) return DBUS_HANDLER_RESULT_HANDLED;