42
42
#define UNICAST_SINK_SUPPORTED (CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0)
43
43
#define UNICAST_SRC_SUPPORTED (CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0)
44
44
45
- struct bt_cap_unicast_group * cap_unicast_group ;
46
-
47
45
#define CAP_UNICAST_CLIENT_STREAM_COUNT ARRAY_SIZE(unicast_streams)
48
46
49
47
static void cap_discover_cb (struct bt_conn * conn , int err ,
@@ -90,13 +88,14 @@ static void unicast_stop_complete_cb(int err, struct bt_conn *conn)
90
88
} else {
91
89
bt_shell_print ("Unicast stop completed" );
92
90
93
- if (cap_unicast_group != NULL ) {
94
- err = bt_cap_unicast_group_delete (cap_unicast_group );
91
+ if (default_unicast_group . is_cap && default_unicast_group . cap_group != NULL ) {
92
+ err = bt_cap_unicast_group_delete (default_unicast_group . cap_group );
95
93
if (err != 0 ) {
96
94
bt_shell_error ("Failed to delete unicast group %p: %d" ,
97
- cap_unicast_group , err );
95
+ default_unicast_group . cap_group , err );
98
96
} else {
99
- cap_unicast_group = NULL ;
97
+ default_unicast_group .cap_group = NULL ;
98
+ default_unicast_group .is_cap = false;
100
99
}
101
100
}
102
101
}
@@ -320,13 +319,15 @@ static int cmd_cap_initiator_unicast_start(const struct shell *sh, size_t argc,
320
319
group_param .params_count = pair_cnt ;
321
320
group_param .params = pair_params ;
322
321
323
- if (cap_unicast_group == NULL ) {
324
- err = bt_cap_unicast_group_create (& group_param , & cap_unicast_group );
322
+ if (default_unicast_group . cap_group == NULL ) {
323
+ err = bt_cap_unicast_group_create (& group_param , & default_unicast_group . cap_group );
325
324
if (err != 0 ) {
326
325
shell_print (sh , "Failed to create group: %d" , err );
327
326
328
327
return - ENOEXEC ;
329
328
}
329
+
330
+ default_unicast_group .is_cap = true;
330
331
}
331
332
332
333
shell_print (sh , "Starting %zu streams" , start_param .count );
@@ -754,6 +755,7 @@ static int cap_ac_create_unicast_group(const struct cap_unicast_ac_param *param,
754
755
size_t snk_stream_cnt = 0U ;
755
756
size_t src_stream_cnt = 0U ;
756
757
size_t pair_cnt = 0U ;
758
+ int err ;
757
759
758
760
for (size_t i = 0U ; i < snk_cnt ; i ++ ) {
759
761
snk_qos [i ] = & snk_uni_streams [i ]-> qos ;
@@ -803,7 +805,12 @@ static int cap_ac_create_unicast_group(const struct cap_unicast_ac_param *param,
803
805
group_param .params = pair_params ;
804
806
group_param .params_count = pair_cnt ;
805
807
806
- return bt_cap_unicast_group_create (& group_param , & default_unicast_group .cap_group );
808
+ err = bt_cap_unicast_group_create (& group_param , & default_unicast_group .cap_group );
809
+ if (err == 0 ) {
810
+ default_unicast_group .is_cap = true;
811
+ }
812
+
813
+ return err ;
807
814
}
808
815
809
816
int cap_ac_unicast (const struct shell * sh , const struct cap_unicast_ac_param * param )
@@ -817,7 +824,7 @@ int cap_ac_unicast(const struct shell *sh, const struct cap_unicast_ac_param *pa
817
824
size_t src_cnt = 0 ;
818
825
int err ;
819
826
820
- if (cap_unicast_group != NULL ) {
827
+ if (default_unicast_group . cap_group != NULL ) {
821
828
shell_error (sh , "Unicast Group already exist, please delete first" );
822
829
return - ENOEXEC ;
823
830
}
@@ -909,11 +916,12 @@ int cap_ac_unicast(const struct shell *sh, const struct cap_unicast_ac_param *pa
909
916
if (err != 0 ) {
910
917
shell_error (sh , "Failed to start unicast audio: %d" , err );
911
918
912
- err = bt_cap_unicast_group_delete (cap_unicast_group );
919
+ err = bt_cap_unicast_group_delete (default_unicast_group . cap_group );
913
920
if (err != 0 ) {
914
921
shell_error (sh , "Failed to delete group: %d" , err );
915
922
} else {
916
- cap_unicast_group = NULL ;
923
+ default_unicast_group .cap_group = NULL ;
924
+ default_unicast_group .is_cap = false;
917
925
}
918
926
919
927
return - ENOEXEC ;
0 commit comments