Commit 3ead1cfa authored by Emil Gydesen's avatar Emil Gydesen Committed by Stephanos Ioannidis
Browse files

Bluetooth: Audio: Call stream released on ACL disconnect



If the ACL disconnects, then the unicast server cannot send
a notification to the client about the endpoint and
stream being released. We now call the released callback
if the stream's endpoint was not idle before the disconnection.

Similarly the unicast server (ASCS) did also not call the
released callback if the ACL disconnection causes a endpoint
release.

Signed-off-by: default avatarEmil Gydesen <emil.gydesen@nordicsemi.no>
parent 67db251f
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -941,6 +941,18 @@ static void disconnected(struct bt_conn *conn, uint8_t reason)
			 * state, where the ase finally will be deallocated
			 */
			ase_release(ase);

			if (stream != NULL) {
				const struct bt_audio_stream_ops *ops;

				/* Notify upper layer */
				ops = stream->ops;
				if (ops != NULL && ops->released != NULL) {
					ops->released(stream);
				} else {
					LOG_WRN("No callback for released set");
				}
			}
		}

		if (stream != NULL && stream->conn != NULL) {
+14 −1
Original line number Diff line number Diff line
@@ -1529,10 +1529,23 @@ int bt_unicast_client_ep_send(struct bt_conn *conn, struct bt_audio_ep *ep,
static void unicast_client_reset(struct bt_audio_ep *ep)
{
	struct bt_unicast_client_ep *client_ep = CONTAINER_OF(ep, struct bt_unicast_client_ep, ep);
	struct bt_audio_stream *stream = ep->stream;

	LOG_DBG("ep %p", ep);

	bt_audio_stream_reset(ep->stream);
	if (stream != NULL && ep->status.state != BT_AUDIO_EP_STATE_IDLE) {
		const struct bt_audio_stream_ops *ops;

		/* Notify upper layer */
		ops = stream->ops;
		if (ops != NULL && ops->released != NULL) {
			ops->released(stream);
		} else {
			LOG_WRN("No callback for released set");
		}
	}

	bt_audio_stream_reset(stream);

	(void)memset(ep, 0, sizeof(*ep));