bluez5: bap: use BD address for per-adapter BIG config

HCI indexed names are not stable. The adapters BD address is here a
better approach to map the configuration.
This commit is contained in:
Alexander Sarmanow 2026-02-10 18:36:45 +01:00 committed by Wim Taymans
parent 5f12dd99a3
commit 5c9b3ee05a
2 changed files with 14 additions and 13 deletions

View file

@ -1211,7 +1211,7 @@ PipeWire Opus Pro audio profile duplex max bitrate.
PipeWire Opus Pro audio profile duplex frame duration (1/10 ms). PipeWire Opus Pro audio profile duplex frame duration (1/10 ms).
@PAR@ monitor-prop bluez5.bcast_source.config = [] # JSON @PAR@ monitor-prop bluez5.bcast_source.config = [] # JSON
For a per-adapter configuration of multiple BIGs use an "adapter" entry in the BIG with the HCI device name (e.g. hci0). For a per-adapter configuration of multiple BIGs use an "adapter" entry in the BIG with the BD address.
\parblock \parblock
Example: Example:
``` ```

View file

@ -196,7 +196,7 @@ struct spa_bt_bis {
}; };
#define BROADCAST_CODE_LEN 16 #define BROADCAST_CODE_LEN 16
#define HCI_DEV_NAME_LEN 8 #define BD_ADDR_STR_LEN 17
struct spa_bt_big { struct spa_bt_big {
struct spa_list link; struct spa_list link;
@ -205,7 +205,7 @@ struct spa_bt_big {
struct spa_list bis_list; struct spa_list bis_list;
int big_id; int big_id;
int sync_factor; int sync_factor;
char adapter[HCI_DEV_NAME_LEN]; char adapter[BD_ADDR_STR_LEN + 3];
}; };
/* /*
@ -6269,6 +6269,7 @@ static void configure_bis(struct spa_bt_monitor *monitor,
} }
static void configure_bcast_source(struct spa_bt_monitor *monitor, static void configure_bcast_source(struct spa_bt_monitor *monitor,
struct spa_bt_remote_endpoint *ep,
const struct media_codec *codec, const struct media_codec *codec,
DBusConnection *conn, DBusConnection *conn,
const char *object_path, const char *object_path,
@ -6277,15 +6278,19 @@ static void configure_bcast_source(struct spa_bt_monitor *monitor,
{ {
struct spa_bt_big *big; struct spa_bt_big *big;
struct spa_bt_bis *bis; struct spa_bt_bis *bis;
char *pos;
/* Configure each BIS from a BIG */ /* Configure each BIS from a BIG */
spa_list_for_each(big, &monitor->bcast_source_config_list, link) { spa_list_for_each(big, &monitor->bcast_source_config_list, link) {
/* Apply per adapter configuration if BIG has an adapter value stated, /* Apply per adapter configuration if BIG has an adapter value stated,
* otherwise apply the BIG config angnostically to each adapter * otherwise apply the BIG config angnostically to each adapter
*/ */
if (strlen(big->adapter) > 0) { if ((strlen(big->adapter) > 0) && (ep->adapter != NULL)) {
pos = strstr(object_path, big->adapter); if (!ep->adapter->address) {
if (pos == NULL) spa_log_warn(monitor->log, "this adapter is not associated with any BD address. BIG config will applied agnostically to any adapter!");
continue;
}
if (strcasecmp(ep->adapter->address, big->adapter))
continue; continue;
spa_log_debug(monitor->log, "configuring BIG for adapter=%s", big->adapter); spa_log_debug(monitor->log, "configuring BIG for adapter=%s", big->adapter);
@ -6414,7 +6419,7 @@ static void interface_added(struct spa_bt_monitor *monitor,
} }
if (local_endpoint != NULL) if (local_endpoint != NULL)
configure_bcast_source(monitor, monitor->media_codecs[i], conn, object_path, interface_name, local_endpoint); configure_bcast_source(monitor, ep, monitor->media_codecs[i], conn, object_path, interface_name, local_endpoint);
} }
} }
} }
@ -7034,7 +7039,6 @@ static void parse_broadcast_source_config(struct spa_bt_monitor *monitor, const
char bis_key[256]; char bis_key[256];
char qos_key[256]; char qos_key[256];
char bcode[BROADCAST_CODE_LEN + 3]; char bcode[BROADCAST_CODE_LEN + 3];
char adapter[HCI_DEV_NAME_LEN + 3];
int cursor; int cursor;
int big_id = 0; int big_id = 0;
struct spa_json it[3], it_array[4]; struct spa_json it[3], it_array[4];
@ -7071,11 +7075,8 @@ static void parse_broadcast_source_config(struct spa_bt_monitor *monitor, const
memcpy(big_entry->broadcast_code, bcode, strlen(bcode)); memcpy(big_entry->broadcast_code, bcode, strlen(bcode));
spa_log_debug(monitor->log, "big_entry->broadcast_code %s", big_entry->broadcast_code); spa_log_debug(monitor->log, "big_entry->broadcast_code %s", big_entry->broadcast_code);
} else if (spa_streq(key, "adapter")) { } else if (spa_streq(key, "adapter")) {
if (spa_json_get_string(&it[1], adapter, sizeof(adapter)) <= 0) if (spa_json_get_string(&it[1], big_entry->adapter, sizeof(big_entry->adapter)) <= 0)
goto parse_failed; goto parse_failed;
if (strlen(adapter) > HCI_DEV_NAME_LEN)
goto parse_failed;
memcpy(big_entry->adapter, adapter, strlen(adapter));
spa_log_debug(monitor->log, "big_entry->adapter %s", big_entry->adapter); spa_log_debug(monitor->log, "big_entry->adapter %s", big_entry->adapter);
} else if (spa_streq(key, "encryption")) { } else if (spa_streq(key, "encryption")) {
if (spa_json_get_bool(&it[0], &big_entry->encryption) <= 0) if (spa_json_get_bool(&it[0], &big_entry->encryption) <= 0)