Skip to contentSkip to conversation

bap: Start BIG sync after receiving BIGInfo

PATCH Applied Yang Li 3 participants 4 messages Jul 28 – Jul 29 Bluetooth drivers

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH v3 1/1 bap: Start BIG sync after receiving BIGInfo

The current implementation starts BIG sync before receiving a BIGInfo report. According to the Bluetooth Core Specification, BIG sync should only be initiated after BIGInfo has been received.

Starting BIG sync too early may cause unexpected controller behavior.

Trigger BIG sync from the BIGInfo callback, following the same approach used by the short PA flow.

---
Changes in v3:
- Fixed coding style warning.
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Fixed build error.
- Link to v1: https://patch.msgid.link/[email protected]

---
 profiles/audio/bap.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
profiles/audio/bap.c +21 -4
index dd4b3c8ff..473e4cfc2 100644
@@ -3650,7 +3650,8 @@ static void setup_refresh_qos(void *data, void *user_data)
 	setup->qos = *bt_bap_stream_get_qos(stream);
 }
 
-static void iso_do_big_sync(GIOChannel *io, void *user_data)
+static gboolean iso_do_big_sync(GIOChannel *io, GIOCondition cond,
+						void *user_data)
 {
 	GError *err = NULL;
 	struct bap_setup *setup = user_data;
@@ -3659,7 +3660,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)
 	struct bt_iso_qos qos;
 	struct queue *links = bt_bap_stream_io_get_links(setup->stream);
 
-	DBG("PA Sync done");
+	DBG("BIG info received, do BIG sync");
 
 	g_io_channel_unref(data->listen_io);
 	g_io_channel_shutdown(data->listen_io, TRUE, NULL);
@@ -3682,6 +3683,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)
 			BT_IO_OPT_INVALID)) {
 		error("bt_io_set: %s", err->message);
 		g_error_free(err);
+		return FALSE;
 	}
 
 	if (!bt_io_bcast_accept(io,
@@ -3692,16 +3694,31 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data)
 			iso_bc_addr.bc_bis, BT_IO_OPT_INVALID)) {
 		error("bt_io_bcast_accept: %s", err->message);
 		g_error_free(err);
+		return FALSE;
 	}
+
+	return TRUE;
+}
+
+static void long_pa_sync_confirm_cb(GIOChannel *io, void *user_data)
+{
+	struct bap_setup *setup = user_data;
+	struct bap_data *data = setup->data;
+
+	DBG("Long PA Sync done");
+
+	/* store io and add watch that will call iso_do_big_sync */
+	data->io_id = g_io_add_watch(io, G_IO_OUT, iso_do_big_sync,
+							setup);
 }
 
 static void pa_and_big_sync(struct bap_setup *setup)
 {
 	GError *err = NULL;
 	struct bap_data *bap_data = setup->data;
-
 	DBG("Create PA sync with this source");
-	bap_data->listen_io = bt_io_listen(NULL, iso_do_big_sync, setup,
+
+	bap_data->listen_io = bt_io_listen(NULL, long_pa_sync_confirm_cb, setup,
 			NULL, &err,
 			BT_IO_OPT_SOURCE_BDADDR,
 			btd_adapter_get_address(bap_data->adapter),

---
base-commit: 89d477bb5494eef0b24e5667be62f854da250a97
change-id: 20260724-big_sync-45c24ec09121

Best regards,

Signature · 1 line
Yang Li <[email protected]>
#1 lore raw
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 9 lines · On Tue, 28 Jul 2026 14:26:42 +0800 you wrote:

From: Yang Li <[email protected]>

The current implementation starts BIG sync before receiving a BIGInfo report. According to the Bluetooth Core Specification, BIG sync should only be initiated after BIGInfo has been received.

Starting BIG sync too early may cause unexpected controller behavior.

[...]

Here is the summary with links:
- [BlueZ,bluez,v3] bap: Start BIG sync after receiving BIGInfo

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=322c39a64323

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#2 lore raw
In reply to Yang Li
Quoted 39 lines · On Tue, 2026-07-28 at 14:26 +0800, Yang Li via B4 Relay wrote:

From: Yang Li <[email protected]>

The current implementation starts BIG sync before receiving a BIGInfo report. According to the Bluetooth Core Specification, BIG sync should
only be initiated after BIGInfo has been received.

Starting BIG sync too early may cause unexpected controller behavior.

Trigger BIG sync from the BIGInfo callback, following the same approach
used by the short PA flow.

---
Changes in v3:
- Fixed coding style warning.
- Link to v2:
https://patch.msgid.link/[email protected]

Changes in v2:
- Fixed build error.
- Link to v1:
https://patch.msgid.link/[email protected]
---
 profiles/audio/bap.c | 25 +++++++++++++++++++++----

 1 file changed, 21 insertions(+), 4 deletions(-)
profiles/audio/bap.c +0 -0
index dd4b3c8ff..473e4cfc2 100644
@@ -3650,7 +3650,8 @@ static void setup_refresh_qos(void *data, void
 *user_data)
  	setup->qos = *bt_bap_stream_get_qos(stream);
  }

profiles/audio/bap.c static void setup_refresh_qos(void *data, void *user_data) · line 3654

Quoted 3 lines
profiles/audio/bap.c +2 -1
-static void iso_do_big_sync(GIOChannel *io, void *user_data)
+static gboolean iso_do_big_sync(GIOChannel *io, GIOCondition cond,
+						void *user_data)

The return here is for:
"The function should return FALSE if the event source should be removed."
Not success or failure.

See:
https://docs.gtk.org/glib/callback.IOFunc.html
https://docs.gtk.org/glib/func.io_add_watch.html

Quoted 15 lines

 {
  GError *err = NULL;
  struct bap_setup *setup = user_data;

profiles/audio/bap.c +0 -0
@@ -3659,7 +3660,7 @@ static void iso_do_big_sync(GIOChannel *io,
 void *user_data)
  	struct bt_iso_qos qos;

  struct queue *links = bt_bap_stream_io_get_links(setup-

Quoted 1 line

stream);

profiles/audio/bap.c +1 -1
-	DBG("PA Sync done");
+	DBG("BIG info received, do BIG sync");


  g_io_channel_unref(data->listen_io); g_io_channel_shutdown(data->listen_io, TRUE, NULL);

profiles/audio/bap.c static void iso_do_big_sync(GIOChannel *io, · line 3687

Quoted 5 lines
profiles/audio/bap.c +1 -0
@@ -3682,6 +3683,7 @@ static void iso_do_big_sync(GIOChannel *io,
 void *user_data)
  			BT_IO_OPT_INVALID)) {
  		error("bt_io_set: %s", err->message);
  		g_error_free(err);
+		return FALSE;

This is wrong, this should be TRUE or better G_SOURCE_REMOVE.

profiles/audio/bap.c static void iso_do_big_sync(GIOChannel *io, · line 3698

Quoted 9 lines
profiles/audio/bap.c +0 -0
  	}


  if (!bt_io_bcast_accept(io,

profiles/audio/bap.c +1 -0
@@ -3692,16 +3694,31 @@ static void iso_do_big_sync(GIOChannel *io,
 void *user_data)
  			iso_bc_addr.bc_bis, BT_IO_OPT_INVALID)) {
  		error("bt_io_bcast_accept: %s", err->message);
  		g_error_free(err);
+		return FALSE;

Here too.

Quoted 37 lines
profiles/audio/bap.c +14 -0
  	}
+
+	return TRUE;
+}
+
+static void long_pa_sync_confirm_cb(GIOChannel *io, void *user_data)
+{
+	struct bap_setup *setup = user_data;
+	struct bap_data *data = setup->data;
+
+	DBG("Long PA Sync done");
+
+	/* store io and add watch that will call iso_do_big_sync */
+	data->io_id = g_io_add_watch(io, G_IO_OUT, iso_do_big_sync,
+							setup);
  }


 static void pa_and_big_sync(struct bap_setup *setup) {
  GError *err = NULL;
  struct bap_data *bap_data = setup->data; -
  DBG("Create PA sync with this source");

profiles/audio/bap.c +0 -1
-	bap_data->listen_io = bt_io_listen(NULL, iso_do_big_sync,

setup,

profiles/audio/bap.c +2 -0
+
+	bap_data->listen_io = bt_io_listen(NULL,

long_pa_sync_confirm_cb, setup,
  NULL, &err, BT_IO_OPT_SOURCE_BDADDR, btd_adapter_get_address(bap_data->adapter),

---
base-commit: 89d477bb5494eef0b24e5667be62f854da250a97
change-id: 20260724-big_sync-45c24ec09121

Best regards,

author
#3 lore raw

Hi,

Quoted 50 lines

[ EXTERNAL EMAIL ]

Quoted 35 lines · On Tue, 2026-07-28 at 14:26 +0800, Yang Li via B4 Relay wrote:

From: Yang Li <[email protected]>

The current implementation starts BIG sync before receiving a BIGInfo report. According to the Bluetooth Core Specification, BIG sync should
only be initiated after BIGInfo has been received.

Starting BIG sync too early may cause unexpected controller behavior.

Trigger BIG sync from the BIGInfo callback, following the same approach
used by the short PA flow.

---
Changes in v3:
- Fixed coding style warning.
- Link to v2:
https://patch.msgid.link/[email protected]

Changes in v2:
- Fixed build error.
- Link to v1:
https://patch.msgid.link/[email protected]

---
  profiles/audio/bap.c | 25 +++++++++++++++++++++----
  1 file changed, 21 insertions(+), 4 deletions(-)
profiles/audio/bap.c +0 -0
index dd4b3c8ff..473e4cfc2 100644

profiles/audio/bap.c static void setup_refresh_qos(void *data, void · line 3655

Quoted 7 lines
profiles/audio/bap.c +2 -1
@@ -3650,7 +3650,8 @@ static void setup_refresh_qos(void *data, void
 *user_data)
       setup->qos = *bt_bap_stream_get_qos(stream);
  }
 
-static void iso_do_big_sync(GIOChannel *io, void *user_data)
+static gboolean iso_do_big_sync(GIOChannel *io, GIOCondition cond,
+                                             void *user_data)

The return here is for:
"The function should return FALSE if the event source should be removed."
Not success or failure.

Quoted 3 lines

See:
https://docs.gtk.org/glib/callback.IOFunc.html
https://docs.gtk.org/glib/func.io_add_watch.html

Well, I got it, but this patch has been applied, I will send the new one to fix it.

Quoted 70 lines
Quoted 15 lines
profiles/audio/bap.c +0 -0
  {
       GError *err = NULL;
       struct bap_setup *setup = user_data;
profiles/audio/bap.c +1 -1
@@ -3659,7 +3660,7 @@ static void iso_do_big_sync(GIOChannel *io,
 void *user_data)
       struct bt_iso_qos qos;
       struct queue *links = bt_bap_stream_io_get_links(setup-
 > stream);
-     DBG("PA Sync done");
+     DBG("BIG info received, do BIG sync");
 
       g_io_channel_unref(data->listen_io);
       g_io_channel_shutdown(data->listen_io, TRUE, NULL);

profiles/audio/bap.c static void iso_do_big_sync(GIOChannel *io, · line 3687

Quoted 5 lines
profiles/audio/bap.c +1 -0
@@ -3682,6 +3683,7 @@ static void iso_do_big_sync(GIOChannel *io,
 void *user_data)
                       BT_IO_OPT_INVALID)) {
               error("bt_io_set: %s", err->message);
               g_error_free(err);
+             return FALSE;

This is wrong, this should be TRUE or better G_SOURCE_REMOVE.

profiles/audio/bap.c static void iso_do_big_sync(GIOChannel *io, · line 3698

Quoted 9 lines
profiles/audio/bap.c +0 -0
       }
 
       if (!bt_io_bcast_accept(io,
profiles/audio/bap.c +1 -0
@@ -3692,16 +3694,31 @@ static void iso_do_big_sync(GIOChannel *io,
 void *user_data)
                       iso_bc_addr.bc_bis, BT_IO_OPT_INVALID)) {
               error("bt_io_bcast_accept: %s", err->message);
               g_error_free(err);
+             return FALSE;

Here too.

Quoted 37 lines
profiles/audio/bap.c +16 -2
       }
+
+     return TRUE;
+}
+
+static void long_pa_sync_confirm_cb(GIOChannel *io, void *user_data)
+{
+     struct bap_setup *setup = user_data;
+     struct bap_data *data = setup->data;
+
+     DBG("Long PA Sync done");
+
+     /* store io and add watch that will call iso_do_big_sync */
+     data->io_id = g_io_add_watch(io, G_IO_OUT, iso_do_big_sync,
+                                                     setup);
  }
 
  static void pa_and_big_sync(struct bap_setup *setup)
  {
       GError *err = NULL;
       struct bap_data *bap_data = setup->data;
-
       DBG("Create PA sync with this source");
-     bap_data->listen_io = bt_io_listen(NULL, iso_do_big_sync,
 setup,
+
+     bap_data->listen_io = bt_io_listen(NULL,
 long_pa_sync_confirm_cb, setup,
                       NULL, &err,
                       BT_IO_OPT_SOURCE_BDADDR,
                       btd_adapter_get_address(bap_data->adapter),

---
base-commit: 89d477bb5494eef0b24e5667be62f854da250a97
change-id: 20260724-big_sync-45c24ec09121

Best regards,