bluetooth: a2dp: remove the aborted stream callback
The `released` callback is enough indicate that the stream is
invalid/released, so remove the `aborted` callback.
Signed-off-by: Mark Wang <yichang.wang@nxp.com>
diff --git a/include/zephyr/bluetooth/classic/a2dp.h b/include/zephyr/bluetooth/classic/a2dp.h
index f14cbb9..c6cc20d 100644
--- a/include/zephyr/bluetooth/classic/a2dp.h
+++ b/include/zephyr/bluetooth/classic/a2dp.h
@@ -681,8 +681,12 @@
/**
* @brief Stream release callback
*
+ * The release procedure (bt_a2dp_stream_release, release_req, release_rsp and
+ * disconnect l2cap media channel), the abort procedure (bt_a2dp_stream_abort, abort_req,
+ * abort_rsp and disconnect l2cap media channel) and the error procedure (for example,
+ * the l2cap channel disconnected unexpectedly) will cause the stream to be released.
* The callback is called whenever an Audio Stream has been released.
- * After released, the stream becomes invalid.
+ * After released, the stream becomes invalid to control.
*
* @param stream Stream object that has been released.
*/
@@ -703,15 +707,6 @@
* @param stream Stream object that has been suspended.
*/
void (*suspended)(struct bt_a2dp_stream *stream);
- /**
- * @brief Stream abort callback
- *
- * The callback is called whenever an Audio Stream has been aborted.
- * After aborted, the stream becomes invalid.
- *
- * @param stream Stream object that has been aborted.
- */
- void (*aborted)(struct bt_a2dp_stream *stream);
#if defined(CONFIG_BT_A2DP_SINK)
/** @brief the media streaming data, only for sink
*
diff --git a/subsys/bluetooth/host/classic/a2dp.c b/subsys/bluetooth/host/classic/a2dp.c
index f19b08d..3ebbeea 100644
--- a/subsys/bluetooth/host/classic/a2dp.c
+++ b/subsys/bluetooth/host/classic/a2dp.c
@@ -498,14 +498,13 @@
static int a2dp_abort_ind(struct bt_avdtp *session, struct bt_avdtp_sep *sep, uint8_t *errcode)
{
- struct bt_a2dp_ep *ep = CONTAINER_OF(sep, struct bt_a2dp_ep, sep);
bt_a2dp_ctrl_req_cb req_cb;
- bt_a2dp_ctrl_done_cb done_cb;
__ASSERT(sep, "Invalid sep");
req_cb = a2dp_cb != NULL ? a2dp_cb->abort_req : NULL;
- done_cb = (ep->stream != NULL && ep->stream->ops != NULL) ? ep->stream->ops->aborted : NULL;
- return a2dp_ctrl_ind(session, sep, errcode, req_cb, done_cb, true);
+
+ /* When stream is released, the `stream->ops->released` will be called. */
+ return a2dp_ctrl_ind(session, sep, errcode, req_cb, NULL, true);
}
static int bt_a2dp_set_config_cb(struct bt_avdtp_req *req, struct net_buf *buf)
@@ -858,12 +857,10 @@
static int bt_a2dp_abort_cb(struct bt_avdtp_req *req, struct net_buf *buf)
{
- struct bt_a2dp_ep *ep = CONTAINER_OF(CTRL_REQ(req)->sep, struct bt_a2dp_ep, sep);
bt_a2dp_rsp_cb rsp_cb = a2dp_cb != NULL ? a2dp_cb->abort_rsp : NULL;
- bt_a2dp_done_cb done_cb =
- (ep->stream != NULL && ep->stream->ops != NULL) ? ep->stream->ops->aborted : NULL;
- return bt_a2dp_ctrl_cb(req, rsp_cb, done_cb, true);
+ /* When stream is released, the `stream->ops->released` will be called. */
+ return bt_a2dp_ctrl_cb(req, rsp_cb, NULL, true);
}
static int bt_a2dp_stream_ctrl_pre(struct bt_a2dp_stream *stream, bt_avdtp_func_t cb)
diff --git a/subsys/bluetooth/host/classic/shell/a2dp.c b/subsys/bluetooth/host/classic/shell/a2dp.c
index 515487f..a3078c0 100644
--- a/subsys/bluetooth/host/classic/shell/a2dp.c
+++ b/subsys/bluetooth/host/classic/shell/a2dp.c
@@ -433,11 +433,6 @@
bt_shell_print("stream suspended");
}
-void stream_aborted(struct bt_a2dp_stream *stream)
-{
- bt_shell_print("stream aborted");
-}
-
void sink_sbc_streamer_data(struct bt_a2dp_stream *stream, struct net_buf *buf,
uint16_t seq_num, uint32_t ts)
{
@@ -595,7 +590,6 @@
.released = stream_released,
.started = stream_started,
.suspended = stream_suspended,
- .aborted = stream_aborted,
#if defined(CONFIG_BT_A2DP_SINK)
.recv = stream_recv,
#endif