Bluetooth: audio: unicast_server: Do not store metadata if rejected

This moves copying of parameters after application return value
validation so that the metadata is not stored if rejected.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This commit is contained in:
Mariusz Skamra 2023-07-06 11:25:05 +02:00 committed by Fabio Baltieri
parent a2ebec5c64
commit bc710a49f1

View File

@ -129,16 +129,16 @@ int bt_bap_unicast_server_metadata(struct bt_bap_stream *stream, struct bt_audio
err = -ENOTSUP;
}
ep = stream->ep;
for (size_t i = 0U; i < meta_count; i++) {
(void)memcpy(&ep->codec_cfg.meta[i], &meta[i], sizeof(ep->codec_cfg.meta[i]));
}
if (err) {
LOG_ERR("Metadata failed: err %d, code %u, reason %u", err, rsp.code, rsp.reason);
return err;
}
ep = stream->ep;
for (size_t i = 0U; i < meta_count; i++) {
(void)memcpy(&ep->codec_cfg.meta[i], &meta[i], sizeof(ep->codec_cfg.meta[i]));
}
/* Set the state to the same state to trigger the notifications */
ascs_ep_set_state(ep, ep->status.state);