From a49d2d41af6b729b3630dd22f934c9a8db06c505 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Thu, 16 Mar 2023 19:02:09 +0200 Subject: [PATCH] bluez5: ensure nodes are removed on disconnect Emit any remove node events before resetting initial profile. It indicates to the session manager that nodes if any went away before device disconnected. Usually the profile is removed first which removes the nodes. This depends on ordering of events from bluez, which apparently can be different depending on how remote device disconnects. --- spa/plugins/bluez5/bluez5-device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spa/plugins/bluez5/bluez5-device.c b/spa/plugins/bluez5/bluez5-device.c index 692f12dc0..854fc0186 100644 --- a/spa/plugins/bluez5/bluez5-device.c +++ b/spa/plugins/bluez5/bluez5-device.c @@ -1038,13 +1038,16 @@ static void profiles_changed(void *userdata, uint32_t prev_profiles, uint32_t pr static void set_initial_profile(struct impl *this); -static void device_connected(void *userdata, bool connected) { +static void device_connected(void *userdata, bool connected) +{ struct impl *this = userdata; spa_log_debug(this->log, "connected: %d", connected); - if (connected ^ (this->profile != DEVICE_PROFILE_OFF)) + if (connected ^ (this->profile != DEVICE_PROFILE_OFF)) { + emit_remove_nodes(this); set_initial_profile(this); + } } static const struct spa_bt_device_events bt_dev_events = {