From 3be019d7a80e29851962fd113bb7cda79584c7a3 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Mon, 25 Apr 2022 20:11:44 +0300 Subject: [PATCH] bluez5: stop running codec switch on disconnect When device is disconnected, running codec switches are not meaningful, and should be stopped. The codec switch callback may also trigger A2DP profile switch, which may reconnect the device. Fix it so this does not happen. See #2334 --- spa/plugins/bluez5/bluez5-dbus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spa/plugins/bluez5/bluez5-dbus.c b/spa/plugins/bluez5/bluez5-dbus.c index 1f4dc90c1..b81868294 100644 --- a/spa/plugins/bluez5/bluez5-dbus.c +++ b/spa/plugins/bluez5/bluez5-dbus.c @@ -1307,6 +1307,11 @@ static void device_set_connected(struct spa_bt_device *device, int connected) if (connected) spa_bt_device_check_profiles(device, false); else { + /* Stop codec switch on disconnect */ + struct spa_bt_a2dp_codec_switch *sw; + spa_list_consume(sw, &device->codec_switch_list, device_link) + a2dp_codec_switch_free(sw); + if (device->reconnect_state != BT_DEVICE_RECONNECT_INIT) device_stop_timer(device); device_connected(monitor, device, BT_DEVICE_DISCONNECTED);