@@ -63,6 +63,11 @@ struct codec_cap_lookup_id_data {
63
63
64
64
static sys_slist_t sink_cbs = SYS_SLIST_STATIC_INIT (& sink_cbs );
65
65
66
+ /* The mod_src_param is and shall only be used by the BT RX thread. It is statically defined due to
67
+ * the size of it, and that it's configurable in size, and can cause stack overflow issues otherwise
68
+ */
69
+ static struct bt_bap_scan_delegator_mod_src_param mod_src_param ;
70
+
66
71
static void broadcast_sink_cleanup (struct bt_bap_broadcast_sink * sink );
67
72
68
73
static bool find_recv_state_by_sink_cb (const struct bt_bap_scan_delegator_recv_state * recv_state ,
@@ -103,7 +108,6 @@ static bool find_recv_state_by_pa_sync_cb(const struct bt_bap_scan_delegator_rec
103
108
static void update_recv_state_big_synced (const struct bt_bap_broadcast_sink * sink )
104
109
{
105
110
const struct bt_bap_scan_delegator_recv_state * recv_state ;
106
- struct bt_bap_scan_delegator_mod_src_param mod_src_param = {0 };
107
111
int err ;
108
112
109
113
recv_state = bt_bap_scan_delegator_find_state (find_recv_state_by_sink_cb , (void * )sink );
@@ -113,6 +117,8 @@ static void update_recv_state_big_synced(const struct bt_bap_broadcast_sink *sin
113
117
return ;
114
118
}
115
119
120
+ (void )memset (& mod_src_param , 0 , sizeof (mod_src_param ));
121
+
116
122
mod_src_param .num_subgroups = sink -> subgroup_count ;
117
123
for (uint8_t i = 0U ; i < sink -> subgroup_count ; i ++ ) {
118
124
struct bt_bap_bass_subgroup * subgroup_param = & mod_src_param .subgroups [i ];
@@ -145,7 +151,6 @@ static void update_recv_state_big_synced(const struct bt_bap_broadcast_sink *sin
145
151
static void update_recv_state_big_cleared (const struct bt_bap_broadcast_sink * sink ,
146
152
uint8_t reason )
147
153
{
148
- struct bt_bap_scan_delegator_mod_src_param mod_src_param = { 0 };
149
154
const struct bt_bap_scan_delegator_recv_state * recv_state ;
150
155
int err ;
151
156
@@ -157,6 +162,8 @@ static void update_recv_state_big_cleared(const struct bt_bap_broadcast_sink *si
157
162
return ;
158
163
}
159
164
165
+ (void )memset (& mod_src_param , 0 , sizeof (mod_src_param ));
166
+
160
167
if ((recv_state -> encrypt_state == BT_BAP_BIG_ENC_STATE_BCODE_REQ ||
161
168
recv_state -> encrypt_state == BT_BAP_BIG_ENC_STATE_DEC ) &&
162
169
reason == BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL ) {
@@ -488,7 +495,6 @@ static void broadcast_sink_add_src(struct bt_bap_broadcast_sink *sink)
488
495
489
496
static bool base_subgroup_meta_cb (const struct bt_bap_base_subgroup * subgroup , void * user_data )
490
497
{
491
- struct bt_bap_scan_delegator_mod_src_param * mod_src_param = user_data ;
492
498
struct bt_bap_bass_subgroup * subgroup_param ;
493
499
uint8_t * meta ;
494
500
int ret ;
@@ -498,19 +504,18 @@ static bool base_subgroup_meta_cb(const struct bt_bap_base_subgroup *subgroup, v
498
504
return false;
499
505
}
500
506
501
- subgroup_param = & mod_src_param -> subgroups [mod_src_param -> num_subgroups ++ ];
507
+ subgroup_param = & mod_src_param . subgroups [mod_src_param . num_subgroups ++ ];
502
508
subgroup_param -> metadata_len = (uint8_t )ret ;
503
509
memcpy (subgroup_param -> metadata , meta , subgroup_param -> metadata_len );
504
510
505
511
return true;
506
512
}
507
513
508
- static int update_recv_state_base_copy_meta (const struct bt_bap_base * base ,
509
- struct bt_bap_scan_delegator_mod_src_param * param )
514
+ static int update_recv_state_base_copy_meta (const struct bt_bap_base * base )
510
515
{
511
516
int err ;
512
517
513
- err = bt_bap_base_foreach_subgroup (base , base_subgroup_meta_cb , param );
518
+ err = bt_bap_base_foreach_subgroup (base , base_subgroup_meta_cb , NULL );
514
519
if (err != 0 ) {
515
520
LOG_DBG ("Failed to parse subgroups: %d" , err );
516
521
return err ;
@@ -522,7 +527,6 @@ static int update_recv_state_base_copy_meta(const struct bt_bap_base *base,
522
527
static void update_recv_state_base (const struct bt_bap_broadcast_sink * sink ,
523
528
const struct bt_bap_base * base )
524
529
{
525
- struct bt_bap_scan_delegator_mod_src_param mod_src_param = { 0 };
526
530
const struct bt_bap_scan_delegator_recv_state * recv_state ;
527
531
int err ;
528
532
@@ -533,7 +537,9 @@ static void update_recv_state_base(const struct bt_bap_broadcast_sink *sink,
533
537
return ;
534
538
}
535
539
536
- err = update_recv_state_base_copy_meta (base , & mod_src_param );
540
+ (void )memset (& mod_src_param , 0 , sizeof (mod_src_param ));
541
+
542
+ err = update_recv_state_base_copy_meta (base );
537
543
if (err != 0 ) {
538
544
LOG_WRN ("Failed to modify Receive State for sink %p: %d" , sink , err );
539
545
return ;
@@ -740,7 +746,6 @@ static void pa_term_cb(struct bt_le_per_adv_sync *sync,
740
746
741
747
static void update_recv_state_encryption (const struct bt_bap_broadcast_sink * sink )
742
748
{
743
- struct bt_bap_scan_delegator_mod_src_param mod_src_param = { 0 };
744
749
const struct bt_bap_scan_delegator_recv_state * recv_state ;
745
750
int err ;
746
751
@@ -753,6 +758,8 @@ static void update_recv_state_encryption(const struct bt_bap_broadcast_sink *sin
753
758
return ;
754
759
}
755
760
761
+ (void )memset (& mod_src_param , 0 , sizeof (mod_src_param ));
762
+
756
763
/* Only change the encrypt state, and leave the rest as is */
757
764
if (atomic_test_bit (sink -> flags ,
758
765
BT_BAP_BROADCAST_SINK_FLAG_BIG_ENCRYPTED )) {
0 commit comments