Skip to content

Commit d3cc63a

Browse files
Yagoorfabiobaltieri
authored andcommitted
Bluetooth: PACS: Fix duplicated entries in client list
The client list is filled from the bonding table at registration but this should only be done once like the callback registration Signed-off-by: Yago Fontoura do Rosario <[email protected]>
1 parent d9f8206 commit d3cc63a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

subsys/bluetooth/audio/pacs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ static void add_bonded_addr_to_client_list(const struct bt_bond_info *info, void
13241324
int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap)
13251325
{
13261326
const struct bt_audio_codec_cap *codec_cap;
1327-
static bool callbacks_registered;
1327+
static bool first_register;
13281328
sys_slist_t *pac;
13291329

13301330
if (!cap || !cap->codec_cap) {
@@ -1338,18 +1338,18 @@ int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap)
13381338
return -EINVAL;
13391339
}
13401340

1341-
/* Restore bonding list */
1342-
bt_foreach_bond(BT_ID_DEFAULT, add_bonded_addr_to_client_list, NULL);
1343-
13441341
LOG_DBG("cap %p dir %s codec_cap id 0x%02x codec_cap cid 0x%04x codec_cap vid 0x%04x", cap,
13451342
bt_audio_dir_str(dir), codec_cap->id, codec_cap->cid, codec_cap->vid);
13461343

13471344
sys_slist_append(pac, &cap->_node);
13481345

1349-
if (!callbacks_registered) {
1346+
if (!first_register) {
13501347
bt_conn_auth_info_cb_register(&auth_callbacks);
13511348

1352-
callbacks_registered = true;
1349+
/* Restore bonding list */
1350+
bt_foreach_bond(BT_ID_DEFAULT, add_bonded_addr_to_client_list, NULL);
1351+
1352+
first_register = true;
13531353
}
13541354

13551355
if (IS_ENABLED(CONFIG_BT_PAC_SNK_NOTIFIABLE) && dir == BT_AUDIO_DIR_SINK) {

0 commit comments

Comments
 (0)