From 614f2fc800f52780a6a03c090de402ca7dbc8c33 Mon Sep 17 00:00:00 2001 From: Iulia Tanasescu Date: Fri, 20 Dec 2024 16:31:05 +0200 Subject: [PATCH] bass: Pass delegator reference to connect_cb The connect_cb callback should receive more generic user_data instead of the stream reference, since the event source is not removed after connected fds are notified, and the same event might be generated multiple times for the same io, expecting to connect different streams. --- profiles/audio/bass.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index 2984d7697..0904748a2 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -288,14 +288,31 @@ static bool link_io_unset(const void *data, const void *match_data) return !bt_bap_stream_get_io(link); } +static bool setup_find_enabling(const void *data, const void *match_data) +{ + const struct bass_setup *setup = data; + + return (bt_bap_stream_get_state(setup->stream) == + BT_BAP_STREAM_STATE_ENABLING); +} + static void connect_cb(GIOChannel *io, GError *err, void *user_data) { - struct bt_bap_stream *stream = user_data; - struct queue *links = bt_bap_stream_io_get_links(stream); + struct bass_delegator *dg = user_data; + struct bass_setup *setup; + struct bt_bap_stream *stream; + struct queue *links; int fd; DBG(""); + setup = queue_find(dg->setups, setup_find_enabling, NULL); + if (!setup || !setup->stream) + return; + + stream = setup->stream; + links = bt_bap_stream_io_get_links(stream); + /* Set fds for the stream and all its links. */ if (bt_bap_stream_get_io(stream)) stream = queue_find(links, link_io_unset, NULL); @@ -352,7 +369,7 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, } if (!bt_io_bcast_accept(dg->io, - connect_cb, stream, NULL, &gerr, + connect_cb, dg, NULL, &gerr, BT_IO_OPT_ISO_BC_NUM_BIS, iso_bc_addr.bc_num_bis, BT_IO_OPT_ISO_BC_BIS, iso_bc_addr.bc_bis, BT_IO_OPT_INVALID)) { -- 2.47.3