diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c
index b420354..6be6ff8 100644
--- a/profiles/audio/bap.c
+++ b/profiles/audio/bap.c
return setup;
}
+static void release_stream(struct bt_bap_stream *stream)
+{
+ switch (bt_bap_stream_get_state(stream)) {
+ case BT_BAP_STREAM_STATE_IDLE:
+ case BT_BAP_STREAM_STATE_RELEASING:
+ break;
+ default:
+ bt_bap_stream_release(stream, NULL, NULL);
+ }
+}
+
static void setup_free(void *data)
{
struct bap_setup *setup = data;
if (setup->destroy)
setup->destroy(setup);
+ bt_bap_stream_unlock(setup->stream);
+
+ release_stream(setup->stream);
+
free(setup);
}
setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac,
&setup->qos, setup->caps);
+ bt_bap_stream_lock(setup->stream);
bt_bap_stream_set_user_data(setup->stream, ep->path);
setup->config_pending = true;
setup->id = bt_bap_stream_config(setup->stream, &setup->qos,
/* Create and configure stream */
setup->stream = bt_bap_stream_new(bap_data->bap,
lpac, NULL, &setup->qos, caps);
+ bt_bap_stream_lock(setup->stream);
setup->sid = sid;
bt_bap_stream_set_user_data(setup->stream, path);
/* TODO: Check if stream capabilities match add support for Latency
* and PHY.
*/
- if (!setup->stream)
+ if (!setup->stream) {
setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac,
ep->rpac, &setup->qos,
setup->caps);
+ bt_bap_stream_lock(setup->stream);
+ }
setup->config_pending = true;
setup->id = bt_bap_stream_config(setup->stream, &setup->qos,