diff --git a/src/shared/bap.c b/src/shared/bap.c
index 41b39f8..c0f35e1 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
stream_set_state(stream, BT_BAP_STREAM_STATE_IDLE);
}
+static void bap_req_detach(void *data)
+{
+ struct bt_bap_req *req = data;
+
+ bap_req_complete(req, NULL);
+}
+
void bt_bap_detach(struct bt_bap *bap)
{
DBG(bap, "%p", bap);
if (!queue_remove(sessions, bap))
return;
+ /* Cancel ongoing request */
+ if (bap->req) {
+ bap_req_detach(bap->req);
+ bap->req = NULL;
+ }
+
+ /* Cancel queued requests */
+ queue_remove_all(bap->reqs, NULL, NULL, bap_req_detach);
+
bt_gatt_client_unref(bap->client);
bap->client = NULL;