Skip to content

Commit bc4a2f3

Browse files
larsgkkartben
authored andcommitted
Bluetooth: BAP: Remove ISO limitation on BASE parsing
BASE is now parsed on-the-fly on sink sync, removing unnecessary restriction in intermediate parsed storage and without requiring an excessive amount of memory. Signed-off-by: Lars Knudsen <[email protected]>
1 parent d619fd6 commit bc4a2f3

File tree

4 files changed

+224
-216
lines changed

4 files changed

+224
-216
lines changed

include/zephyr/bluetooth/audio/bap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ extern "C" {
4747
#define BT_BAP_BASS_MAX_SUBGROUPS 0
4848
#endif /* CONFIG_BT_BAP_BASS_MAX_SUBGROUPS*/
4949

50+
/** Maximum size of BASE excluding service data header */
51+
#define BT_BASE_MAX_SIZE (UINT8_MAX - 1 /* type */ - BT_UUID_SIZE_16)
52+
5053
/** An invalid Broadcast ID */
5154
#define BT_BAP_INVALID_BROADCAST_ID 0xFFFFFFFFU
5255

subsys/bluetooth/audio/bap_base.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ LOG_MODULE_REGISTER(bt_bap_base, CONFIG_BT_BAP_BASE_LOG_LEVEL);
3030
/* The BASE and the following defines are defined by BAP v1.0.1, section 3.7.2.2 Basic Audio
3131
* Announcements
3232
*/
33-
#define BASE_MAX_SIZE (UINT8_MAX - 1 /* type */ - BT_UUID_SIZE_16)
3433
#define BASE_CODEC_ID_SIZE (1 /* id */ + 2 /* cid */ + 2 /* vid */)
3534
#define BASE_PD_SIZE 3
3635
#define BASE_SUBGROUP_COUNT_SIZE 1
@@ -39,14 +38,14 @@ LOG_MODULE_REGISTER(bt_bap_base, CONFIG_BT_BAP_BASE_LOG_LEVEL);
3938
#define BASE_META_LEN_SIZE 1
4039
#define BASE_BIS_INDEX_SIZE 1
4140
#define BASE_BIS_CC_LEN_SIZE 1
42-
#define BASE_SUBGROUP_MAX_SIZE (BASE_MAX_SIZE - BASE_PD_SIZE - BASE_SUBGROUP_COUNT_SIZE)
41+
#define BASE_SUBGROUP_MAX_SIZE (BT_BASE_MAX_SIZE - BASE_PD_SIZE - BASE_SUBGROUP_COUNT_SIZE)
4342
#define BASE_SUBGROUP_MIN_SIZE \
4443
(BASE_NUM_BIS_SIZE + BASE_CODEC_ID_SIZE + BASE_CC_LEN_SIZE + BASE_META_LEN_SIZE + \
4544
BASE_BIS_INDEX_SIZE + BASE_BIS_CC_LEN_SIZE)
4645
#define BASE_MIN_SIZE \
4746
(BT_UUID_SIZE_16 + BASE_PD_SIZE + BASE_SUBGROUP_COUNT_SIZE + BASE_SUBGROUP_MIN_SIZE)
4847
#define BASE_SUBGROUP_MAX_COUNT \
49-
((BASE_MAX_SIZE - BASE_PD_SIZE - BASE_SUBGROUP_COUNT_SIZE) / BASE_SUBGROUP_MIN_SIZE)
48+
((BT_BASE_MAX_SIZE - BASE_PD_SIZE - BASE_SUBGROUP_COUNT_SIZE) / BASE_SUBGROUP_MIN_SIZE)
5049

5150
static uint32_t base_pull_pd(struct net_buf_simple *net_buf)
5251
{
@@ -233,7 +232,7 @@ int bt_bap_base_get_size(const struct bt_bap_base *base)
233232
return -EINVAL;
234233
}
235234

236-
net_buf_simple_init_with_data(&net_buf, (void *)base, BASE_MAX_SIZE);
235+
net_buf_simple_init_with_data(&net_buf, (void *)base, BT_BASE_MAX_SIZE);
237236
base_pull_pd(&net_buf);
238237
size += BASE_PD_SIZE;
239238
subgroup_count = net_buf_simple_pull_u8(&net_buf);
@@ -301,7 +300,7 @@ int bt_bap_base_get_subgroup_count(const struct bt_bap_base *base)
301300
return -EINVAL;
302301
}
303302

304-
net_buf_simple_init_with_data(&net_buf, (void *)base, BASE_MAX_SIZE);
303+
net_buf_simple_init_with_data(&net_buf, (void *)base, BT_BASE_MAX_SIZE);
305304
base_pull_pd(&net_buf);
306305
subgroup_count = net_buf_simple_pull_u8(&net_buf);
307306

@@ -329,7 +328,7 @@ int bt_bap_base_foreach_subgroup(const struct bt_bap_base *base,
329328
return -EINVAL;
330329
}
331330

332-
net_buf_simple_init_with_data(&net_buf, (void *)base, BASE_MAX_SIZE);
331+
net_buf_simple_init_with_data(&net_buf, (void *)base, BT_BASE_MAX_SIZE);
333332
base_pull_pd(&net_buf);
334333
subgroup_count = net_buf_simple_pull_u8(&net_buf);
335334

0 commit comments

Comments
 (0)