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.
This commit is contained in:
Pauli Virtanen 2023-03-16 19:02:09 +02:00
parent 8a9e7dc1c7
commit a49d2d41af

View file

@ -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 = {