Bluetooth: Audio: Fix issue with deleting unicast groups
There was a bug in bt_audio_iso_unbind_ep that caused an assert, missing unbinding on stream released callback and missing state check in bt_audio_unicast_group_delete Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
346836b24b
commit
4c058402a5
2 changed files with 22 additions and 5 deletions
|
@ -184,7 +184,8 @@ void bt_audio_iso_unbind_ep(struct bt_audio_iso *iso, struct bt_audio_ep *ep)
|
|||
|
||||
__ASSERT_NO_MSG(ep != NULL);
|
||||
__ASSERT_NO_MSG(iso != NULL);
|
||||
__ASSERT(ep->iso == iso, "ep %p not bound with iso", iso, ep);
|
||||
__ASSERT(ep->iso == iso, "ep %p not bound with iso %p, was bound to %p",
|
||||
ep, iso, ep->iso);
|
||||
__ASSERT(ep->dir == BT_AUDIO_DIR_SINK || ep->dir == BT_AUDIO_DIR_SOURCE,
|
||||
"Invalid dir: %u", ep->dir);
|
||||
|
||||
|
@ -194,12 +195,12 @@ void bt_audio_iso_unbind_ep(struct bt_audio_iso *iso, struct bt_audio_ep *ep)
|
|||
bt_audio_ep_is_unicast_client(ep)) {
|
||||
/* For the unicast client, the direction and tx/rx is reversed */
|
||||
if (ep->dir == BT_AUDIO_DIR_SOURCE) {
|
||||
__ASSERT(iso->rx.ep == NULL,
|
||||
"iso %p not bound with ep %p", iso, iso->rx.ep);
|
||||
__ASSERT(iso->rx.ep == ep,
|
||||
"iso %p not bound with ep %p", iso, ep);
|
||||
iso->rx.ep = NULL;
|
||||
} else {
|
||||
__ASSERT(iso->tx.ep == NULL,
|
||||
"iso %p not bound with ep %p", iso, iso->tx.ep);
|
||||
__ASSERT(iso->tx.ep == ep,
|
||||
"iso %p not bound with ep %p", iso, ep);
|
||||
iso->tx.ep = NULL;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -324,6 +324,10 @@ void bt_audio_stream_reset(struct bt_audio_stream *stream)
|
|||
return;
|
||||
}
|
||||
|
||||
if (stream->ep != NULL && stream->ep->iso != NULL) {
|
||||
bt_audio_iso_unbind_ep(stream->ep->iso, stream->ep);
|
||||
}
|
||||
|
||||
bt_audio_stream_detach(stream);
|
||||
}
|
||||
|
||||
|
@ -1139,11 +1143,23 @@ fail:
|
|||
|
||||
int bt_audio_unicast_group_delete(struct bt_audio_unicast_group *unicast_group)
|
||||
{
|
||||
struct bt_audio_stream *stream;
|
||||
|
||||
CHECKIF(unicast_group == NULL) {
|
||||
LOG_DBG("unicast_group is NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&unicast_group->streams, stream, _node) {
|
||||
/* If a stream has an endpoint, it is not ready to be removed
|
||||
* from a group, as it is not in an idle state
|
||||
*/
|
||||
if (stream->ep != NULL) {
|
||||
LOG_DBG("stream %p is not released", stream);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (unicast_group->cig != NULL) {
|
||||
const int err = bt_audio_cig_terminate(unicast_group);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue