diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2024-02-29 10:17:55 -0500 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2024-03-04 10:01:02 -0500 |
commit | 0d82dd205023b867818e0b73ef78cc3eba352799 (patch) | |
tree | 195ace47077a97750e1ad5ecf54c4fbfd15f5314 | |
parent | 29fe7bd07fbd1311f3c256721c8c613157ae1e8d (diff) |
shared/bap: Remove bt_bap_stream_bcast_new
This is now handled internally by bt_bap_stream_new by detecting if an
ATT session has been attached.
-rw-r--r-- | profiles/audio/bap.c | 11 | ||||
-rw-r--r-- | src/shared/bap.c | 74 | ||||
-rw-r--r-- | src/shared/bap.h | 6 |
3 files changed, 24 insertions, 67 deletions
diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index b7e1837801..1b8a47c521 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -75,11 +75,6 @@ struct bap_setup { struct bt_bap_qos qos; int (*qos_parser)(struct bap_setup *setup, const char *key, int var, DBusMessageIter *iter); - struct bt_bap_stream* (*stream_new)(struct bt_bap *bap, - struct bt_bap_pac *lpac, - struct bt_bap_pac *rpac, - struct bt_bap_qos *pqos, - struct iovec *data); GIOChannel *io; unsigned int io_id; bool recreate; @@ -848,13 +843,11 @@ static struct bap_setup *setup_new(struct bap_ep *ep) setup->qos.bcast.bis = BT_ISO_QOS_BIS_UNSET; setup->qos_parser = setup_parse_bcast_qos; setup->destroy = setup_bcast_destroy; - setup->stream_new = bt_bap_stream_bcast_new; } else { /* Mark CIG and CIS to be auto assigned */ setup->qos.ucast.cig_id = BT_ISO_QOS_CIG_UNSET; setup->qos.ucast.cis_id = BT_ISO_QOS_CIS_UNSET; setup->qos_parser = setup_parse_ucast_qos; - setup->stream_new = bt_bap_stream_new; } if (!ep->setups) @@ -931,7 +924,7 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, bt_bap_pac_get_metadata(ep->rpac), 1); } - setup->stream = setup->stream_new(ep->data->bap, ep->lpac, ep->rpac, + setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac, &setup->qos, setup->caps); bt_bap_stream_set_user_data(setup->stream, ep->path); setup->id = bt_bap_stream_config(setup->stream, &setup->qos, @@ -1330,7 +1323,7 @@ static void setup_config(void *data, void *user_data) * and PHY. */ if (!setup->stream) - setup->stream = setup->stream_new(ep->data->bap, ep->lpac, + setup->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac, &setup->qos, setup->caps); diff --git a/src/shared/bap.c b/src/shared/bap.c index b84760da45..37fc1de4e1 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -5186,7 +5186,7 @@ int bt_bap_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, return 0; } -struct bt_bap_stream *bt_bap_stream_bcast_new(struct bt_bap *bap, +static struct bt_bap_stream *bap_bcast_stream_new(struct bt_bap *bap, struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, struct bt_bap_qos *pqos, @@ -5268,66 +5268,20 @@ struct bt_bap_stream *bt_bap_stream_bcast_new(struct bt_bap *bap, return stream; } -struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, +static struct bt_bap_stream *bap_ucast_stream_new(struct bt_bap *bap, struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, struct bt_bap_qos *pqos, struct iovec *data) { - struct bt_bap_stream *stream; - struct bt_bap_endpoint *ep; + struct bt_bap_stream *stream = NULL; + struct bt_bap_endpoint *ep = NULL; struct match_pac match; - if (!bap) - return NULL; - - if (!rpac && (lpac->type != BT_BAP_BCAST_SOURCE) - && queue_isempty(bap->remote_eps)) + if (!lpac || !rpac || !bap_codec_equal(&lpac->codec, &rpac->codec)) return NULL; - if (lpac && rpac) { - if ((rpac->type != BT_BAP_BCAST_SOURCE) - && (!bap_codec_equal(&lpac->codec, &rpac->codec))) - return NULL; - } else { - uint8_t type; - - match.lpac = lpac; - match.rpac = rpac; - memset(&match.codec, 0, sizeof(match.codec)); - - if (rpac) - type = rpac->type; - else if (lpac) { - switch (lpac->type) { - case BT_BAP_SINK: - type = BT_BAP_SOURCE; - break; - case BT_BAP_SOURCE: - type = BT_BAP_SINK; - break; - case BT_BAP_BCAST_SOURCE: - type = BT_BAP_BCAST_SINK; - break; - case BT_BAP_BCAST_SINK: - type = BT_BAP_BCAST_SOURCE; - break; - default: - return NULL; - } - } else - return NULL; - - bt_bap_foreach_pac(bap, type, match_pac, &match); - if ((!match.lpac) || (!lpac)) - return NULL; - if (!match.rpac && (lpac->type != BT_BAP_BCAST_SOURCE)) - return NULL; - - lpac = match.lpac; - rpac = match.rpac; - } - + memset(&match, 0, sizeof(match)); match.lpac = lpac; match.rpac = rpac; @@ -5349,6 +5303,22 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, return stream; } +struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, + struct bt_bap_pac *lpac, + struct bt_bap_pac *rpac, + struct bt_bap_qos *pqos, + struct iovec *data) +{ + if (!bap) + return NULL; + + /* Check if ATT is attached then it must be a unicast stream */ + if (bt_bap_get_att(bap)) + return bap_ucast_stream_new(bap, lpac, rpac, pqos, data); + + return bap_bcast_stream_new(bap, lpac, rpac, pqos, data); +} + struct bt_bap *bt_bap_stream_get_session(struct bt_bap_stream *stream) { if (!stream) diff --git a/src/shared/bap.h b/src/shared/bap.h index 76f3fb0ada..b2826719f8 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -248,12 +248,6 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, struct bt_bap_qos *pqos, struct iovec *data); -struct bt_bap_stream *bt_bap_stream_bcast_new(struct bt_bap *bap, - struct bt_bap_pac *lpac, - struct bt_bap_pac *rpac, - struct bt_bap_qos *pqos, - struct iovec *data); - struct bt_bap *bt_bap_stream_get_session(struct bt_bap_stream *stream); uint8_t bt_bap_stream_get_state(struct bt_bap_stream *stream); |