From 822037fe74503fe87c3dc0b11dc69f2e9efa2376 Mon Sep 17 00:00:00 2001 From: Yang Li Date: Mon, 30 Jun 2025 16:02:39 +0800 Subject: [PATCH] shared/bap: Set stream to idle when I/O is disconnected When BIG sync is lost, the stream status transitions from Streaming to Idle. > HCI Event: LE Meta Event (0x3e) plen 3 #3189 [hci0] 118.870863 LE Broadcast Isochronous Group Sync Lost (0x1e) BIG Handle: 0x00 Reason: Remote User Terminated Connection (0x13) = bluetoothd: src/shared/bap.c:stream_io_disconnected() stream 0.. 118.871183 = bluetoothd: src/shared/bap.c:bap_bcast_set_state() stream 0xdf.. 118.871227 = bluetoothd: profiles/audio/bap.c:bap_state_bcast_sink() stream.. 118.871258 = bluetoothd: profiles/audio/bass.c:bap_state_changed() stream 0.. 118.871307 = bluetoothd: src/gatt-database.c:send_notification_to_device()... 118.871384 = bluetoothd: profiles/audio/transport.c:bap_state_changed() str.. 118.871452 = bluetoothd: profiles/audio/transport.c:transport_bap_update_li.. 118.871509 = bluetoothd: profiles/audio/transport.c:transport_update_playin.. 118.871555 = bluetoothd: profiles/audio/transport.c:transport_set_state() S.. 118.871610 = bluetoothd: src/shared/bap.c:bap_bcast_sink_detach() stream 0x.. 118.871660 = bluetoothd: profiles/audio/media.c:pac_clear() endpoint 0xdd25.. 118.871689 Fixes: https://github.com/bluez/bluez/issues/1343 --- src/shared/bap.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index bccbc73ff..40e1c974b 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -6584,6 +6584,15 @@ static bool stream_io_disconnected(struct io *io, void *user_data) DBG(stream->bap, "stream %p io disconnected", stream); + /* If the IO is for a broadcast sink has been disconnected both BIG Sync + * and PA Sync have been lost so switch to idle state to cleanup the + * stream. + */ + if (stream->lpac->type == BT_BAP_BCAST_SINK) { + stream_set_state(stream, BT_BAP_STREAM_STATE_IDLE); + return false; + } + if (stream->ep->state == BT_ASCS_ASE_STATE_RELEASING) stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG); -- 2.47.3