@@ -31,6 +31,7 @@ static atomic_t flag_stream_qos_configured;
31
31
CREATE_FLAG (flag_stream_enabled );
32
32
CREATE_FLAG (flag_stream_started );
33
33
CREATE_FLAG (flag_stream_released );
34
+ CREATE_FLAG (flag_operation_success );
34
35
35
36
static void stream_configured (struct bt_bap_stream * stream ,
36
37
const struct bt_codec_qos_pref * pref )
@@ -112,9 +113,98 @@ static void available_contexts_cb(struct bt_conn *conn,
112
113
printk ("snk ctx %u src ctx %u\n" , snk_ctx , src_ctx );
113
114
}
114
115
116
+
117
+ static void config_cb (struct bt_bap_stream * stream , enum bt_bap_ascs_rsp_code rsp_code ,
118
+ enum bt_bap_ascs_reason reason )
119
+ {
120
+ printk ("stream %p config operation rsp_code %u reason %u\n" , stream , rsp_code , reason );
121
+
122
+ if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS ) {
123
+ SET_FLAG (flag_operation_success );
124
+ }
125
+ }
126
+
127
+ static void qos_cb (struct bt_bap_stream * stream , enum bt_bap_ascs_rsp_code rsp_code ,
128
+ enum bt_bap_ascs_reason reason )
129
+ {
130
+ printk ("stream %p qos operation rsp_code %u reason %u\n" , stream , rsp_code , reason );
131
+
132
+ if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS ) {
133
+ SET_FLAG (flag_operation_success );
134
+ }
135
+ }
136
+
137
+ static void enable_cb (struct bt_bap_stream * stream , enum bt_bap_ascs_rsp_code rsp_code ,
138
+ enum bt_bap_ascs_reason reason )
139
+ {
140
+ printk ("stream %p enable operation rsp_code %u reason %u\n" , stream , rsp_code , reason );
141
+
142
+ if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS ) {
143
+ SET_FLAG (flag_operation_success );
144
+ }
145
+ }
146
+
147
+ static void start_cb (struct bt_bap_stream * stream , enum bt_bap_ascs_rsp_code rsp_code ,
148
+ enum bt_bap_ascs_reason reason )
149
+ {
150
+ printk ("stream %p start operation rsp_code %u reason %u\n" , stream , rsp_code , reason );
151
+
152
+ if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS ) {
153
+ SET_FLAG (flag_operation_success );
154
+ }
155
+ }
156
+
157
+ static void stop_cb (struct bt_bap_stream * stream , enum bt_bap_ascs_rsp_code rsp_code ,
158
+ enum bt_bap_ascs_reason reason )
159
+ {
160
+ printk ("stream %p stop operation rsp_code %u reason %u\n" , stream , rsp_code , reason );
161
+
162
+ if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS ) {
163
+ SET_FLAG (flag_operation_success );
164
+ }
165
+ }
166
+
167
+ static void disable_cb (struct bt_bap_stream * stream , enum bt_bap_ascs_rsp_code rsp_code ,
168
+ enum bt_bap_ascs_reason reason )
169
+ {
170
+ printk ("stream %p disable operation rsp_code %u reason %u\n" , stream , rsp_code , reason );
171
+
172
+ if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS ) {
173
+ SET_FLAG (flag_operation_success );
174
+ }
175
+ }
176
+
177
+ static void metadata_cb (struct bt_bap_stream * stream , enum bt_bap_ascs_rsp_code rsp_code ,
178
+ enum bt_bap_ascs_reason reason )
179
+ {
180
+ printk ("stream %p metadata operation rsp_code %u reason %u\n" , stream , rsp_code , reason );
181
+
182
+ if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS ) {
183
+ SET_FLAG (flag_operation_success );
184
+ }
185
+ }
186
+
187
+ static void release_cb (struct bt_bap_stream * stream , enum bt_bap_ascs_rsp_code rsp_code ,
188
+ enum bt_bap_ascs_reason reason )
189
+ {
190
+ printk ("stream %p release operation rsp_code %u reason %u\n" , stream , rsp_code , reason );
191
+
192
+ if (rsp_code == BT_BAP_ASCS_RSP_CODE_SUCCESS ) {
193
+ SET_FLAG (flag_operation_success );
194
+ }
195
+ }
196
+
115
197
const struct bt_bap_unicast_client_cb unicast_client_cbs = {
116
198
.location = unicast_client_location_cb ,
117
199
.available_contexts = available_contexts_cb ,
200
+ .config = config_cb ,
201
+ .qos = qos_cb ,
202
+ .enable = enable_cb ,
203
+ .start = start_cb ,
204
+ .stop = stop_cb ,
205
+ .disable = disable_cb ,
206
+ .metadata = metadata_cb ,
207
+ .release = release_cb ,
118
208
};
119
209
120
210
static void add_remote_sink (struct bt_bap_ep * ep , uint8_t index )
@@ -267,6 +357,7 @@ static int codec_configure_stream(struct bt_bap_stream *stream, struct bt_bap_ep
267
357
int err ;
268
358
269
359
UNSET_FLAG (flag_stream_codec_configured );
360
+ UNSET_FLAG (flag_operation_success );
270
361
271
362
err = bt_bap_stream_config (default_conn , stream , ep ,
272
363
& preset_16_2_1 .codec );
@@ -276,6 +367,7 @@ static int codec_configure_stream(struct bt_bap_stream *stream, struct bt_bap_ep
276
367
}
277
368
278
369
WAIT_FOR_FLAG (flag_stream_codec_configured );
370
+ WAIT_FOR_FLAG (flag_operation_success );
279
371
280
372
return 0 ;
281
373
}
@@ -393,6 +485,7 @@ static size_t release_streams(size_t stream_cnt)
393
485
break ;
394
486
}
395
487
488
+ UNSET_FLAG (flag_operation_success );
396
489
UNSET_FLAG (flag_stream_released );
397
490
398
491
err = bt_bap_stream_release (& g_streams [i ]);
@@ -401,6 +494,7 @@ static size_t release_streams(size_t stream_cnt)
401
494
return 0 ;
402
495
}
403
496
497
+ WAIT_FOR_FLAG (flag_operation_success );
404
498
WAIT_FOR_FLAG (flag_stream_released );
405
499
}
406
500
0 commit comments