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
This commit is contained in:
Pauli Virtanen 2022-04-25 20:11:44 +03:00
parent 4bcc93b68e
commit 3be019d7a8

View file

@ -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);