Skip to content

Commit c37a48a

Browse files
Thalleycarlescufi
authored andcommitted
Bluetooth: CAP: Revert order of CAP stream callbacks
Modify the CAP stream callbacks so that the application callbacks are called before the CAP initiator. This allows the application to abort/cancel a procedure before we send out any future request. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
1 parent 55d9d1c commit c37a48a

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

subsys/bluetooth/audio/cap_stream.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ static void cap_stream_configured_cb(struct bt_bap_stream *bap_stream,
5656

5757
LOG_DBG("%p", cap_stream);
5858

59+
if (ops != NULL && ops->configured != NULL) {
60+
ops->configured(bap_stream, pref);
61+
}
62+
5963
if (IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT) &&
6064
stream_is_central(bap_stream)) {
6165
bt_cap_initiator_codec_configured(cap_stream);
6266
}
63-
64-
if (ops != NULL && ops->configured != NULL) {
65-
ops->configured(bap_stream, pref);
66-
}
6767
}
6868

6969
static void cap_stream_qos_set_cb(struct bt_bap_stream *bap_stream)
@@ -75,14 +75,14 @@ static void cap_stream_qos_set_cb(struct bt_bap_stream *bap_stream)
7575

7676
LOG_DBG("%p", cap_stream);
7777

78+
if (ops != NULL && ops->qos_set != NULL) {
79+
ops->qos_set(bap_stream);
80+
}
81+
7882
if (IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT) &&
7983
stream_is_central(bap_stream)) {
8084
bt_cap_initiator_qos_configured(cap_stream);
8185
}
82-
83-
if (ops != NULL && ops->qos_set != NULL) {
84-
ops->qos_set(bap_stream);
85-
}
8686
}
8787

8888
static void cap_stream_enabled_cb(struct bt_bap_stream *bap_stream)
@@ -94,14 +94,14 @@ static void cap_stream_enabled_cb(struct bt_bap_stream *bap_stream)
9494

9595
LOG_DBG("%p", cap_stream);
9696

97+
if (ops != NULL && ops->enabled != NULL) {
98+
ops->enabled(bap_stream);
99+
}
100+
97101
if (IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT) &&
98102
stream_is_central(bap_stream)) {
99103
bt_cap_initiator_enabled(cap_stream);
100104
}
101-
102-
if (ops != NULL && ops->enabled != NULL) {
103-
ops->enabled(bap_stream);
104-
}
105105
}
106106

107107
static void cap_stream_metadata_updated_cb(struct bt_bap_stream *bap_stream)
@@ -113,14 +113,14 @@ static void cap_stream_metadata_updated_cb(struct bt_bap_stream *bap_stream)
113113

114114
LOG_DBG("%p", cap_stream);
115115

116+
if (ops != NULL && ops->metadata_updated != NULL) {
117+
ops->metadata_updated(bap_stream);
118+
}
119+
116120
if (IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT) &&
117121
stream_is_central(bap_stream)) {
118122
bt_cap_initiator_metadata_updated(cap_stream);
119123
}
120-
121-
if (ops != NULL && ops->metadata_updated != NULL) {
122-
ops->metadata_updated(bap_stream);
123-
}
124124
}
125125

126126
static void cap_stream_disabled_cb(struct bt_bap_stream *bap_stream)
@@ -146,16 +146,16 @@ static void cap_stream_released_cb(struct bt_bap_stream *bap_stream)
146146

147147
LOG_DBG("%p", cap_stream);
148148

149+
if (ops != NULL && ops->released != NULL) {
150+
ops->released(bap_stream);
151+
}
152+
149153
/* Here we cannot use stream_is_central as bap_stream->conn is NULL, so fall back to
150154
* a more generic, less accurate check
151155
*/
152156
if (IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT)) {
153157
bt_cap_initiator_released(cap_stream);
154158
}
155-
156-
if (ops != NULL && ops->released != NULL) {
157-
ops->released(bap_stream);
158-
}
159159
}
160160

161161
#endif /* CONFIG_BT_BAP_UNICAST */
@@ -169,14 +169,14 @@ static void cap_stream_started_cb(struct bt_bap_stream *bap_stream)
169169

170170
LOG_DBG("%p", cap_stream);
171171

172+
if (ops != NULL && ops->started != NULL) {
173+
ops->started(bap_stream);
174+
}
175+
172176
if (IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT) &&
173177
stream_is_central(bap_stream)) {
174178
bt_cap_initiator_started(cap_stream);
175179
}
176-
177-
if (ops != NULL && ops->started != NULL) {
178-
ops->started(bap_stream);
179-
}
180180
}
181181

182182
static void cap_stream_stopped_cb(struct bt_bap_stream *bap_stream, uint8_t reason)
@@ -228,14 +228,14 @@ static void cap_stream_connected_cb(struct bt_bap_stream *bap_stream)
228228
CONTAINER_OF(bap_stream, struct bt_cap_stream, bap_stream);
229229
struct bt_bap_stream_ops *ops = cap_stream->ops;
230230

231+
if (ops != NULL && ops->connected != NULL) {
232+
ops->connected(bap_stream);
233+
}
234+
231235
if (IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT) &&
232236
stream_is_central(bap_stream)) {
233237
bt_cap_initiator_connected(cap_stream);
234238
}
235-
236-
if (ops != NULL && ops->connected != NULL) {
237-
ops->connected(bap_stream);
238-
}
239239
}
240240

241241
static void cap_stream_disconnected_cb(struct bt_bap_stream *bap_stream, uint8_t reason)

0 commit comments

Comments
 (0)