From patchwork Fri Oct 25 12:21:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838807 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B9482036EE for ; Fri, 25 Oct 2024 12:22:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858940; cv=fail; b=SKSqBTnJaL53MpB7tTb5RZG8WAsqWUkhnwWKGjqTCG68jkCE6k2c1mtHka1IqcwOhYQUBnvv6E+nGV9iQw/9INM9ZfS6+WMHPqkMOOOh9irQun3+L0s2uj6+EGrSyh4kRluoFdvD5HB3n8if5SBW0K2dLMlsuLuGHM7aNz6yt8k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858940; c=relaxed/simple; bh=v3yn1+9S/OBVpoKXu+nEbzLp4IIM3dvjfpbKIGwLGxw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=HY3MmzzVL3+PfF+xmihtNR8Tlvy7FtaKrYUuL9RRuQnrhMdDzmAgEG5UJnF0Ras20ei8AzhM6uwANo77eHxmA91Sau7FWyIzpb1/iV+Wu4xi4Hy/krH+xlxFLMcHm0QwqcRNKFo9/ogjr50qIoJdAb2DtPcmJBzKdXljbZMZP0c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=euxkHnnr; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="euxkHnnr" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cmTuX3tNjvvRqmd7fnPRyGhOw/3ACQo/nqu9mFZmwmRcecAtZMly2XNygYx8ouanSsX7jfsdfW8g7Yvhqe9UiS0qScFeEiSEDaODXgyGGMbWEP/rNehg5T/kr+cAFWFJOC48du2SdEc5Ey7si0p2unjWrJc4G6KBUATLrusCoYXjopnqlINlpsiIu7hN4YDw26DW8psGB+6r6H9nJvsK0uTEIwME7J+VUeHkgMCmjEyxtgZ8eHzAqwBvXnx9q0Bg7fZZu1Qe/4cJhZT+QXJ9atmf5S3UawfgcLvSZflP54hBEzooLa9P9b9Dpj3Vyri7SNUdOxjmAj6OWN7jCNfLlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qDHyKfTuDytPTaU7MQs8CrrrgX+6fFMAFGruoAnBAGM=; b=t2JTmbTQH1aKK6+t5DnX6POS7ex0S0dEVzNn91llwPZO2Qm5HD/JZeYS1IabWcFLXWbLNF8iMQcDaQZJ6O2WVc8JIOFjSxtD153YdqSiV/Y9ucu8UiR18LnPoG1Y1c03Un4XoAhYHx64tZOFuWmxUKGxR+ODU3NJJRDGyZKBBYCUYWQ6ZRMA7AdbNQl3kLYbrEEklABdWBvtwWkSV/+A63fq38bTYi5djaYkfhEjE4jf9hGrWh39BeqrWGXvvuv68TH8+WCNYiECEU3sTKnvcTozJoxHq9ONBwaXWYTX0dT9SJ3BSCpAQ54avblt4C9RT29yLMq1mVF1jSyOJHakPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qDHyKfTuDytPTaU7MQs8CrrrgX+6fFMAFGruoAnBAGM=; b=euxkHnnr7lDHvr1raNES8vwGIOuI7hGrY/gTIqSnD7Ra9iwwTEzyuyAkiZGsRZzEoyWlmetMtWU4JkvaSrkw2B1YWjakbtur50sXYUPSrW1EXf58NbpqNOApdxGc8k+DrPrtu50E+dFsZj+Jyp+HbCXMdE+IaJm92rg8XwyspohEUoGAVqavD6Yzn1fWpziHB6lueKEK5sEMOcqjppBN7DuMxIaWbxgJmCm03ePu4o3I4IcprSykd4xn03D+Q5W0tE+hQubPkeorTGAEkUhhqBi6WvsWSbA/bLpTbvPAwpyLYpbbj5/L6vdzeKVP/1EHtxLdi9KQFmfo+QNIXXZrjw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:13 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:13 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 01/14] shared/bap: Allow multiple links per stream Date: Fri, 25 Oct 2024 15:21:33 +0300 Message-ID: <20241025122146.17925-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: 84e16d7e-1e85-4c7a-946b-08dcf4efa7cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: UnwhnRnGoRpkyyqDxftD6Zk+dzfKsU0xxyFNDIGOJ+LBNHKZsMB9JunZzGnRAsfuwoyPsZDEX3Rf2U1Z2SPYR0AWIZQrceGTZf3fijGFxUdbzfG0jhL/KrOOqfJv6Dtve1MXkcaiUhv9Pl+Ho1vbUnXrf/i4fp/asDpFRiH1cMpVUtErleHAf0oUnG3Kq0oCjfbROSNMBTrXxd6R4m1vIfg2vOc1ijOeeoqS0B9rfeE0Q58WF/69K2hgfomR4+giDg3cUD7cQFE3HUuq21+IsE3FJcqqCrv/sgu5ILoX8WF+D3pCOQ+qgyzb9yaCkR8rob4RaYSCSsZh562nEgHDMleOvRWZAxnoKU3R0YZCMbC90KHwz7aHZ/7P5yJnnmk0E4syU0r5TV51NsAh3Qaw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prd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nqnjTB/w3vaovfkjPMnbzexu4g6Z9m0A4NnIYl0OGypWlp6g9Wl+JtSqhtcB5XNUv9IK6LXVDoJYsp4BbC2eHwoJPeoP2fhFK7uXTtpnYmOfBeChjMandVKhdav413L114IRzlusB4wsqDkMFk1mM3NgJuyPpJju1oEa/LLBRbv0Lga/3QdOKPPTqzPgMFbH5yf2E22mRq+65+NlY8ZdR54EIW9x2pVKx9SNTVlcev+Ugfm4nbTyGU7vkGj/KI+VOcPvM6tfa33RBUiCdz4OU9RLkdgCuSeDMDOb2ojfAaGrKrPoLx9i3GCB4EzKMp98XIvcw5WDMbvNCG/x2yekBR29sql9soecdr1jYX6q8vH3OfPkqNXqyPyh8Y2fVQwa46G6DI3Jh+LIlx4sua0XMdS38LJu3YkhTGjHuZI7lyICJMZVE97RO+Mh9Pwp4avMHQzw6F0664vx90IfAi3MUDmpCDlYR5XKc/B8DyPU3IJRl5w1gorpyNfXptgt5YOZkF8UbQKihM0coOyrzQMB+tUv/yjs8Z/uMYfz+Z6VD8YioMfskrtt016hQW/xg2vw3s2cB9HjZe+psBQP9eCTIIfRxTNN+18TkbZdLKaSWW1t9br+UlkqtQgf7bUXLPKWkpRSY2Pdm1f1GxSg0tIpxVv82j8G+qQdXm3tqgMhPv8Qs2n9uiVl7cjWhJmyvGzuhYiKo1HwsrIIaUKNvNaW9I0zujQLl/wL8uxjP4+vEEthlvrlBWs0H/tThJ2BDiA+83Q8KT2TmwDSoUufBvqqLuldHQ6zjbs12iV+WCVXgeLRexCO/egExMo07LA56Tg4PQvHBFTt4ag1pPSGhg6FvR5pWcERXbggK3AXB8qxgh7TaV7zVJa9mQeYjh7WUuHuQX/oD1VXcIuojuokLAgOdotm//rP5RihKeESqBGmaIdAh8d+idnWG1Jalh2QbKjRSoKH8Vjhin8Uv8/SPczT5c1ks1UQgo8Y2QoD7/nQQzyWcF+LDJfskFAZR8BCUlK9ATDlBUGDNkxDMPDQpUVlPC+IoSv5MN7l8oiCF98+UEe1Usvzb39WZdEHirQEZEgBf+A+u9ifzFgHP5EzDkPebgn+5rNCNtBZAVevDwHFeY8sUTJxEfuM9+FLJtTau/zqj3T7JM7x6LoSglohI7644pRoWZJqBMNWVoQf0iB7jwGYQ8OAp2CHpBRrRe18sdLAmtX3McJgrWvSJJC6cDDzd24sCsR8lpnGSnCSJLzRrVeF5tI7j7Oo6QN79rbvzTJJd4/qJ7Np7Y2d+CmOxToKHxtYo9Kvr+SoKyuQqOleskXTYASxjJGN6Ovr3cjhUpE9YMLxMI+cKrvvdJpfsLYWTUM2g/zhkWajo7r2+RP9ODMhW+p8NcbfifCIk5qTwVgqj//1zKhbhsJxE5tZAPgmndSkfnbHb3ZjzoIqgCzzjh5m7IVAMqgPCGccZsONUV8BqDQUxm8HGoZbG0SDbwOYJAZK3rK9UpVEV3JrMYw0v1jXZdz9L35SFNQRmJPDmdIe5tSgAG0te3DD67lGszM+UNfZJ6gIA575fN15ylXzMs/u8EqarLI5SJnSf60ljzm9eOaUNJfxTfRikZSZ7PfU0w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84e16d7e-1e85-4c7a-946b-08dcf4efa7cd X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:13.1907 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ud8kYuqimKnEI5yQ8INZvNmOiHWOqGxLx2/5nGRpsR6JuUdEqw7xk2UpSVfvZdhfm2KIo4rSYRZcoQwKKvc8ug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This commit adds support to link multiple streams together, creating the foundation for implementing broadcast links: for Broadcast Sinks, the user could select multiple streams to receive audio from. All selected streams need to be linked together and considered when creating BIG sync. --- profiles/audio/transport.c | 38 ++++++-------- src/shared/bap.c | 104 +++++++++++++++++++++++++++++-------- src/shared/bap.h | 2 +- 3 files changed, 97 insertions(+), 47 deletions(-) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 68192bae6..d71013077 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -330,12 +330,9 @@ static void transport_bap_remove_owner(struct media_transport *transport, { struct bap_transport *bap = transport->data; - if (bap && bap->linked) { - struct bt_bap_stream *link; - - link = bt_bap_stream_io_get_link(bap->stream); - linked_transport_remove_owner(link, owner); - } + if (bap && bap->linked) + queue_foreach(bt_bap_stream_io_get_links(bap->stream), + linked_transport_remove_owner, owner); } static void media_transport_remove_owner(struct media_transport *transport) @@ -581,12 +578,9 @@ static void transport_bap_set_owner(struct media_transport *transport, { struct bap_transport *bap = transport->data; - if (bap && bap->linked) { - struct bt_bap_stream *link; - - link = bt_bap_stream_io_get_link(bap->stream); - linked_transport_set_owner(link, owner); - } + if (bap && bap->linked) + queue_foreach(bt_bap_stream_io_get_links(bap->stream), + linked_transport_set_owner, owner); } static void media_transport_set_owner(struct media_transport *transport, @@ -1129,14 +1123,14 @@ static gboolean get_links(const GDBusPropertyTable *property, { struct media_transport *transport = data; struct bap_transport *bap = transport->data; - struct bt_bap_stream *link = bt_bap_stream_io_get_link(bap->stream); + struct queue *links = bt_bap_stream_io_get_links(bap->stream); DBusMessageIter array; dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH_AS_STRING, &array); - append_link(link, &array); + queue_foreach(links, append_link, &array); dbus_message_iter_close_container(iter, &array); @@ -1572,15 +1566,15 @@ static bool match_link_transport(const void *data, const void *user_data) static void bap_update_links(const struct media_transport *transport) { struct bap_transport *bap = transport->data; - struct bt_bap_stream *link = bt_bap_stream_io_get_link(bap->stream); + struct queue *links = bt_bap_stream_io_get_links(bap->stream); - if (bap->linked == (!!link)) + if (bap->linked == !queue_isempty(links)) return; - bap->linked = link ? true : false; + bap->linked = !queue_isempty(links); /* Check if the links transport has been create yet */ - if (bap->linked && !match_link_transport(link, NULL)) { + if (bap->linked && !queue_find(links, match_link_transport, NULL)) { bap->linked = false; return; } @@ -1757,15 +1751,13 @@ static void transport_bap_set_state(struct media_transport *transport, transport_state_t state) { struct bap_transport *bap = transport->data; - struct bt_bap_stream *link; if (!bap->linked) return; - link = bt_bap_stream_io_get_link(bap->stream); - - /* Update link */ - link_set_state(link, UINT_TO_PTR(state)); + /* Update links */ + queue_foreach(bt_bap_stream_io_get_links(bap->stream), link_set_state, + UINT_TO_PTR(state)); } static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, diff --git a/src/shared/bap.c b/src/shared/bap.c index 8d04290f8..0b234275c 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -262,7 +262,7 @@ struct bt_bap_stream { struct iovec *cc; struct iovec *meta; struct bt_bap_qos qos; - struct bt_bap_stream *link; + struct queue *links; struct bt_bap_stream_io *io; const struct bt_bap_stream_ops *ops; uint8_t old_state; @@ -1101,6 +1101,14 @@ static void stream_io_unref(struct bt_bap_stream_io *io) stream_io_free(io); } +static void bap_stream_unlink(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + struct bt_bap_stream *link = user_data; + + queue_remove(stream->links, link); +} + static void bap_stream_free(void *data) { struct bt_bap_stream *stream = data; @@ -1110,8 +1118,8 @@ static void bap_stream_free(void *data) if (stream->ep) stream->ep->stream = NULL; - if (stream->link) - stream->link->link = NULL; + queue_foreach(stream->links, bap_stream_unlink, stream); + queue_destroy(stream->links, NULL); stream_io_unref(stream->io); util_iov_free(stream->cc, 1); @@ -1246,6 +1254,17 @@ static void bap_stream_update_io_links(struct bt_bap_stream *stream) queue_find(bap->streams, bap_stream_io_link, stream); } +static bool match_stream_io(const void *data, const void *user_data) +{ + const struct bt_bap_stream *stream = data; + const struct bt_bap_stream_io *io = user_data; + + if (!stream->io) + return false; + + return stream->io == io; +} + static bool bap_stream_io_detach(struct bt_bap_stream *stream) { struct bt_bap_stream *link; @@ -1259,7 +1278,7 @@ static bool bap_stream_io_detach(struct bt_bap_stream *stream) io = stream->io; stream->io = NULL; - link = stream->link; + link = queue_find(stream->links, match_stream_io, io); if (link) { /* Detach link if in QoS state */ if (link->ep->state == BT_ASCS_ASE_STATE_QOS) @@ -1803,6 +1822,14 @@ static unsigned int bap_bcast_config(struct bt_bap_stream *stream, return 1; } +static void bap_stream_enable_link(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + struct iovec *metadata = user_data; + + bap_stream_metadata(stream, BT_ASCS_ENABLE, metadata, NULL, NULL); +} + static unsigned int bap_ucast_enable(struct bt_bap_stream *stream, bool enable_links, struct iovec *data, bt_bap_stream_func_t func, @@ -1821,9 +1848,7 @@ static unsigned int bap_ucast_enable(struct bt_bap_stream *stream, if (!ret || !enable_links) return ret; - if (stream->link) - bap_stream_metadata(stream->link, BT_ASCS_ENABLE, data, - NULL, NULL); + queue_foreach(stream->links, bap_stream_enable_link, data); return ret; } @@ -1893,6 +1918,13 @@ static uint8_t stream_disable(struct bt_bap_stream *stream, struct iovec *rsp) return 0; } +static void bap_stream_disable_link(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + + bt_bap_stream_disable(stream, false, NULL, NULL); +} + static unsigned int bap_ucast_disable(struct bt_bap_stream *stream, bool disable_links, bt_bap_stream_func_t func, @@ -1919,7 +1951,7 @@ static unsigned int bap_ucast_disable(struct bt_bap_stream *stream, } if (disable_links) - bt_bap_stream_disable(stream->link, false, NULL, NULL); + queue_foreach(stream->links, bap_stream_disable_link, NULL); return req->id; } @@ -2351,18 +2383,30 @@ static struct bt_bap_stream_io *stream_io_new(struct bt_bap *bap, int fd) return stream_io_ref(sio); } +static void stream_find_io(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + struct bt_bap_stream_io **io = user_data; + + if (*io) + return; + + *io = stream->io; +} + static struct bt_bap_stream_io *stream_get_io(struct bt_bap_stream *stream) { + struct bt_bap_stream_io *io = NULL; + if (!stream) return NULL; if (stream->io) return stream->io; - if (stream->link) - return stream->link->io; + queue_foreach(stream->links, stream_find_io, &io); - return NULL; + return io; } static bool stream_io_disconnected(struct io *io, void *user_data); @@ -5849,8 +5893,7 @@ bool bt_bap_stream_set_io(struct bt_bap_stream *stream, int fd) bap_stream_set_io(stream, INT_TO_PTR(fd)); - if (stream->link) - bap_stream_set_io(stream->link, INT_TO_PTR(fd)); + queue_foreach(stream->links, bap_stream_set_io, INT_TO_PTR(fd)); return true; } @@ -5905,7 +5948,8 @@ int bt_bap_stream_io_link(struct bt_bap_stream *stream, bap = stream->bap; - if (stream->link || link->link) + if (queue_find(stream->links, NULL, link) || + queue_find(link->links, NULL, stream)) return -EALREADY; if (stream->client != link->client || @@ -5914,8 +5958,14 @@ int bt_bap_stream_io_link(struct bt_bap_stream *stream, stream->ep->dir == link->ep->dir) return -EINVAL; - stream->link = link; - link->link = stream; + if (!stream->links) + stream->links = queue_new(); + + if (!link->links) + link->links = queue_new(); + + queue_push_tail(stream->links, link); + queue_push_tail(link->links, stream); /* Link IOs if already set on stream/link */ if (stream->io && !link->io) @@ -5928,12 +5978,12 @@ int bt_bap_stream_io_link(struct bt_bap_stream *stream, return 0; } -struct bt_bap_stream *bt_bap_stream_io_get_link(struct bt_bap_stream *stream) +struct queue *bt_bap_stream_io_get_links(struct bt_bap_stream *stream) { if (!stream) return NULL; - return stream->link; + return stream->links; } static void bap_stream_get_in_qos(void *data, void *user_data) @@ -5976,11 +6026,11 @@ bool bt_bap_stream_io_get_qos(struct bt_bap_stream *stream, switch (stream->ep->dir) { case BT_BAP_SOURCE: bap_stream_get_in_qos(stream, in); - bap_stream_get_out_qos(stream->link, out); + queue_foreach(stream->links, bap_stream_get_out_qos, out); break; case BT_BAP_SINK: bap_stream_get_out_qos(stream, out); - bap_stream_get_in_qos(stream->link, in); + queue_foreach(stream->links, bap_stream_get_in_qos, in); break; default: return false; @@ -5991,6 +6041,14 @@ bool bt_bap_stream_io_get_qos(struct bt_bap_stream *stream, return in && out; } +static void bap_stream_get_dir(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + uint8_t *dir = user_data; + + *dir |= stream->ep->dir; +} + uint8_t bt_bap_stream_io_dir(struct bt_bap_stream *stream) { uint8_t dir; @@ -6010,8 +6068,7 @@ uint8_t bt_bap_stream_io_dir(struct bt_bap_stream *stream) } - if (stream->link) - dir |= stream->link->ep->dir; + queue_foreach(stream->links, bap_stream_get_dir, &dir); return dir; } @@ -6046,7 +6103,8 @@ int bt_bap_stream_io_connecting(struct bt_bap_stream *stream, int fd) return -EINVAL; bap_stream_io_connecting(stream, INT_TO_PTR(fd)); - bap_stream_io_connecting(stream->link, INT_TO_PTR(fd)); + + queue_foreach(stream->links, bap_stream_io_connecting, INT_TO_PTR(fd)); return 0; } diff --git a/src/shared/bap.h b/src/shared/bap.h index bf928bc2d..cd5ea2eba 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -231,7 +231,7 @@ int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id); int bt_bap_stream_io_link(struct bt_bap_stream *stream, struct bt_bap_stream *link); -struct bt_bap_stream *bt_bap_stream_io_get_link(struct bt_bap_stream *stream); +struct queue *bt_bap_stream_io_get_links(struct bt_bap_stream *stream); bool bt_bap_stream_io_get_qos(struct bt_bap_stream *stream, struct bt_bap_qos **in, struct bt_bap_qos **out); From patchwork Fri Oct 25 12:21:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838489 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5C0C1F9431 for ; Fri, 25 Oct 2024 12:22:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858943; cv=fail; b=JyB+54YrbSsxbt8yIi8AJF96V48u3riQEjHFh/gMhmbydIrGIm/xjDWMA66gnLfGld3rAzfM+gkkPyjlW3XrfbaRRrKAEgyC/iwk8QWkm1E6oitcWsEQcf7V7MN36cqNZDQXNLlU6a0eRb6nXYvg3ytKhbMO0F0WFessm4qq+c8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858943; c=relaxed/simple; bh=/BaD/pzck8gvP6AUj7B8YKk0UwFhtsbFoSc9f1xKwYU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=d+t619r3tSU3F148nUJyZBf4H7t+0hDcmi8fETHSgr8LtbbD8W88ORCgoeFPNXpiJZQXJl6/1w9Mv2+gKIJ82N0CI72yBeOZhigv3NzoNNrWm1ChHo2fT3y1a953EWTdbAeZBqqNikFBtQIvGXdX2WZrS/7JPpq3wgY7itEX/Mc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=JfGKFCI9; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="JfGKFCI9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QuTqdGpH/dslXqQYDMNF+OKpWCunB7BcjXrchDUVHI5jZDXYgogFExNhLI/E46/A4V+zV8G2b9SybcewwPWOz1iCLvhF8kc0iv/cTBVw/tRheZXJsTf9OBtGZUzeN1gCf64LkqLg6BM8awOzz9xZ2zqypKbZqnuwmS1nwFoDc3OrTIjBo4CK5s3cd4hR4zseQrGQ10nYs9Gp3PxkyWREwsV23U8s5IMVo1vV3rlUsmBV6/H/385tkA50GiTuEDZcY4KrFzwb/Lh0aHDb7N0tTGuEqFOJRG2q/xom5v7cmoqpr0mL9SQn7IWBvaFSERnqzeBz6DZn41y2iKusH0I70g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z4k9xz6Rwc5YMyixdAo9GXLJS0IsnuU69i6YAToid7U=; b=BZ5/0s1E3vB3uTn4y2WqgTwSoweshte1u6Ozkf27bFfb2LcbHf6KUjWaLRo7JXOOcAndBeyvanpp1GjM8LA97DdVYGQSs/9Gqmaj3rV6DzihS7UbiCwf1AMb1rIUrzSOJE6qFmifrdnixBi/9XN13BlPN15o5nl5mBrN2osHJvWFlN3sf00S8wnHmMzNBLdYxm2bkhwbV/Z2sgZ2RE3+Trrjzy2hU7vpJ4iRYu/pG7LxP+3xekyJNSgwBZHPonkTkGZaj698C1AY0ah7uaZne41BsyLAtTgVbjohxsxcN+4IhkvqIl0B+fVT8lChhSjo2zVmVuvbB6Sgwu2w+hZbBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z4k9xz6Rwc5YMyixdAo9GXLJS0IsnuU69i6YAToid7U=; b=JfGKFCI9f4rfxPXXwUmp75KUC5uxQwSGh2i8lUfHB/G4MyxlFGFXOaNa0unzxncGFf80ZPV4nIOJpy/D5ZVMFbFpG/1Wr9i/Iqi0oV75W7Kqnj2GSnJuNZzZchBSP8IpCejREfepdkpvLzoio6y93wVQA3So8McDb+S2cG7eIQj7g7LOEvfj1AmIEvQ6FdC3muvAAkm0aWW3/kSYxirA23VpUovWUvOR7Wpz7VFWs8bCuM86zZ0liExGYYjbOEuqrxQP6s49yJH/NWUoNN/8iaVZ0sKISC7lYPMy8iLs7SEdkLyMMvZAOACPJZmp2pOAg6aTixybE/BLMIVBt/m8Dg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:16 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:15 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 02/14] shared/bap: Add support for handling broadcast links Date: Fri, 25 Oct 2024 15:21:34 +0300 Message-ID: <20241025122146.17925-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: 61c82312-1ecc-4f9b-4174-08dcf4efa978 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: 5EtKuPKfgM7vwbrzuNvQKhzH5FRdF5WWePTgFdwSzCPWrjifCBDQEEo9XJ9FEy8oJyd5NX72u/3B8EiWjesvIUEFd5M6FuINbmvu5gchwediDIiNr2ZauxTLEl+BPjWrcNb0F2rITs6cP8RRchkeKT0Zzr3fRasNrRGpq4MRu8nJgSHHVTbcHunB2vxjdZSb9XG2FhgglCcpJYK5lgOnT5SpFaO2k6S9gDNzrsLSXX13hDbkmCpfDtHD1n0V//E4I1yisFK8qIahggbs+eaEWCtdxkOIDy3QlQMq+m+4blFMsWfLXxRJVfz9cLAYK0kD03k6Pu2n6YoEleBVmovjv0f52lHGBpGsC135fuYrZbWb8b7h9jxFB0/Y3BEydkVrA3wDhiujly+p7JBBW6zpwRrpKHhfhJv9ztvheme08AC9c6o+Lf+qajGxxxrWh7DVQxDym3EWSM+rBRFnpEzo0FXNRAmZocwhCtGOB8j+BvhWWvT7oru6JAsEWfVZahKjmYapkszVugl8UERlxfhrIn6+54fz9WKToyiEJ+gxGfFyRZb9ZBkegkoyOgphrbEynJXkjNRfeVoil5xDGOfu9eCMncacXhvCh+skJQdqMDfKRAGPpXQGYGMvRrM1B8DJ2QdS+/2aKsHE/AVt77/G6r1C4BFBre6ipdJaNOTyvdF7AzrBBpLw7KCtyBM+FGZDO4J2cZkw6VDXiqL/bUgB30qWMWeKSf+mFnaGSPeXhQkT3qKgigN30Qyadw+e82Bqhus9Dy+CaWI0jNR0L0Y1D2LJ/J6AzvxeNY3TiMq/bdHGOtMHkV05G3o0gaKU3QyMSTpe/SjrIVfkinsNDaf/QLCKZPV+2/eEUmyhAqWAoqQe1Vv1t+tO6HCvCpvTR1udNCtmwuznqYAajemt6mUgLrXxvb45Gr8TBydeg71hBWv9ftr+FD7Pv4cwGu9rxNXcMej372/yT5nQ8W72Wld2v6wSX9PJkGo+ikv93GHxcWy9896jY0vvVYG0F4/iBXUdhEiEib/xwsI4GvYaLY3BMjnuYGcWZzyKPGuI2ox2Mq1Bj/G6+0VkfFrOaQ401brD/bnYt6thBLJmxf3pOfo5MAyTJVqlp5zUUHWe6uLFSTdRz17mxN72IOpyLcy7cgdXhptDoGrSG+gO9dLTO5Y/qmo0p2XUoFrR5bM5jJBNUtsXGLYv4xwzUdzo6BIhIsOHUmcOodBLImeyplUb65Sh139PsTWYsyeoQepNYtlmTTDxTTDsHcCz5rVoql9Z/puBigqgX84E4W6OPkNowNyLst5v+oc+v1iv6X7Jl3hzYpElVb4omqVsk3Ru2+SPB3taEQJWPtVM1ada1GNGRWJhax5RdLwz1z3bEL1/xySTxGk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ILibBdYmCiYH02MSblflATGfy0TyDslZfV4D6BWm/p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Uzkd+8m6KiIt/Rb/65/cAFW6ZmVFD8fw00uRnJoCY+SXaWIFNKuMiiWlCxk7p7dNDciZvridKejRSQvbOT9gcEmkV5tZasQ5TZlxdJHalJ/rW1Es+/ndNDNb+niKBeOaxmLHmGUvmoO+8PqejLUzPTbEAVu5sl4+w277pX88C+gA0HsPGc6Slhx8Skr/M+z3gRIHGpvaNbm51E8Y51UY467xCNCk9Cf2AJZUn5wysn3LQbNHV+7w0yac88XbWuDyO3Ij6qEn5ufSEHyKmKTQolqEA0UHG6QWjjiucaLYfd4bz3b+fT+kVa8rqVP7rp4NxKjXKLcSJwz+7BuOnisf+DwcblSz0/PdySdiQh/OI4RG7wYZV+Fct2mLejQux08LoeHLwCvjGjbCPJs/UCAZ/tCOK63QtIpr2FGCw4/nG/gjSG0/YFd+4dt/gwapkG72naF86CfYUQWr9JwpZjQ1zBw71xVSHyVSewYuA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61c82312-1ecc-4f9b-4174-08dcf4efa978 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:15.9093 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: X6zWFF4ycdBw/6jBQQDOswyQKs0H/wNaLTSgfvzwsrsSwWzEQstAMLaj5YRzxAojk8WtiBJMa2lSvdLd3Jduvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This commit implements io handling functions as stream ops, since broadcast links need to be handled differently than unicast: Unicast links share the same IO, while broadcast links stand for separate BISes with independent IOs. Unicast links have different directions, while broadcast links share the same one. This also adds a function for unlinking broadcast streams. --- src/shared/bap.c | 336 ++++++++++++++++++++++++++++++++++++++++------- src/shared/bap.h | 2 + 2 files changed, 291 insertions(+), 47 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 0b234275c..a696471bd 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -252,6 +252,13 @@ struct bt_bap_stream_ops { unsigned int (*release)(struct bt_bap_stream *stream, bt_bap_stream_func_t func, void *user_data); void (*detach)(struct bt_bap_stream *stream); + bool (*set_io)(struct bt_bap_stream *stream, int fd); + struct bt_bap_stream_io* (*get_io)(struct bt_bap_stream *stream); + uint8_t (*io_dir)(struct bt_bap_stream *stream); + int (*io_link)(struct bt_bap_stream *stream, + struct bt_bap_stream *link); + int (*io_unlink)(struct bt_bap_stream *stream, + struct bt_bap_stream *link); }; struct bt_bap_stream { @@ -324,6 +331,13 @@ static struct queue *bap_db; static struct queue *bap_cbs; static struct queue *sessions; +static void bap_stream_set_io(void *data, void *user_data); +static void stream_find_io(void *data, void *user_data); +static void bap_stream_get_dir(void *data, void *user_data); +static struct bt_bap_stream_io *stream_io_ref(struct bt_bap_stream_io *io); +static int bap_bcast_io_unlink(struct bt_bap_stream *stream, + struct bt_bap_stream *link); + static bool bap_db_match(const void *data, const void *match_data) { const struct bt_bap_db *bdb = data; @@ -2262,9 +2276,194 @@ static unsigned int bap_bcast_release(struct bt_bap_stream *stream, return 1; } +static bool bap_ucast_set_io(struct bt_bap_stream *stream, int fd) +{ + if (!stream || (fd >= 0 && stream->io && !stream->io->connecting)) + return false; + + bap_stream_set_io(stream, INT_TO_PTR(fd)); + + queue_foreach(stream->links, bap_stream_set_io, INT_TO_PTR(fd)); + + return true; +} + +static bool bap_bcast_set_io(struct bt_bap_stream *stream, int fd) +{ + if (!stream || (fd >= 0 && stream->io && !stream->io->connecting)) + return false; + + bap_stream_set_io(stream, INT_TO_PTR(fd)); + + return true; +} + +static struct bt_bap_stream_io *bap_ucast_get_io(struct bt_bap_stream *stream) +{ + struct bt_bap_stream_io *io = NULL; + + if (!stream) + return NULL; + + if (stream->io) + return stream->io; + + queue_foreach(stream->links, stream_find_io, &io); + + return io; +} + +static struct bt_bap_stream_io *bap_bcast_get_io(struct bt_bap_stream *stream) +{ + if (!stream) + return NULL; + + return stream->io; +} + +static uint8_t bap_ucast_io_dir(struct bt_bap_stream *stream) +{ + uint8_t dir; + + if (!stream) + return 0x00; + + dir = stream->ep->dir; + + queue_foreach(stream->links, bap_stream_get_dir, &dir); + + return dir; +} + +static uint8_t bap_bcast_io_dir(struct bt_bap_stream *stream) +{ + uint8_t dir; + uint8_t pac_type = bt_bap_pac_get_type(stream->lpac); + + if (!stream) + return 0x00; + + if (pac_type == BT_BAP_BCAST_SINK) + dir = BT_BAP_BCAST_SOURCE; + else + dir = BT_BAP_BCAST_SINK; + + return dir; +} + +static int bap_ucast_io_link(struct bt_bap_stream *stream, + struct bt_bap_stream *link) +{ + struct bt_bap *bap; + + if (!stream || !link || stream == link) + return -EINVAL; + + bap = stream->bap; + + if (queue_find(stream->links, NULL, link) || + queue_find(link->links, NULL, stream)) + return -EALREADY; + + if (stream->client != link->client || + stream->qos.ucast.cig_id != link->qos.ucast.cig_id || + stream->qos.ucast.cis_id != link->qos.ucast.cis_id || + stream->ep->dir == link->ep->dir) + return -EINVAL; + + if (!stream->links) + stream->links = queue_new(); + + if (!link->links) + link->links = queue_new(); + + queue_push_tail(stream->links, link); + queue_push_tail(link->links, stream); + + /* Link IOs if already set on stream/link */ + if (stream->io && !link->io) + link->io = stream_io_ref(stream->io); + else if (link->io && !stream->io) + stream->io = stream_io_ref(link->io); + + DBG(bap, "stream %p link %p", stream, link); + + return 0; +} + +static void stream_link(void *data, void *user_data) +{ + struct bt_bap_stream *stream = (void *)data; + struct bt_bap_stream *link = (void *)user_data; + + bt_bap_stream_io_link(stream, link); +} + +static int bap_bcast_io_link(struct bt_bap_stream *stream, + struct bt_bap_stream *link) +{ + struct bt_bap *bap; + + if (!stream || !link || stream == link) + return -EINVAL; + + bap = stream->bap; + + if (queue_find(stream->links, NULL, link) || + queue_find(link->links, NULL, stream)) + return -EALREADY; + + if (!stream->links) + stream->links = queue_new(); + + if (!link->links) + link->links = queue_new(); + + queue_push_tail(stream->links, link); + queue_push_tail(link->links, stream); + + DBG(bap, "stream %p link %p", stream, link); + + queue_foreach(stream->links, stream_link, link); + + return 0; +} + +static void stream_unlink(void *data, void *user_data) +{ + struct bt_bap_stream *stream = (void *)data; + struct bt_bap_stream *link = (void *)user_data; + + bap_bcast_io_unlink(stream, link); +} + +static int bap_bcast_io_unlink(struct bt_bap_stream *stream, + struct bt_bap_stream *link) +{ + struct bt_bap *bap; + + if (!stream || !link || stream == link) + return -EINVAL; + + bap = stream->bap; + + if (!queue_find(stream->links, NULL, link) || + !queue_find(link->links, NULL, stream)) + return -EALREADY; + + queue_remove(stream->links, link); + queue_remove(link->links, stream); + + DBG(bap, "stream %p unlink %p", stream, link); + + queue_foreach(stream->links, stream_unlink, link); + + return 0; +} + #define STREAM_OPS(_type, _set_state, _get_state, _config, _qos, _enable, \ _start, _disable, _stop, _metadata, _get_dir, _get_loc, _release, \ - _detach) \ + _detach, _set_io, _get_io, _io_dir, _io_link, _io_unlink) \ { \ .type = _type, \ .set_state = _set_state, \ @@ -2280,6 +2479,11 @@ static unsigned int bap_bcast_release(struct bt_bap_stream *stream, .get_loc = _get_loc, \ .release = _release, \ .detach = _detach, \ + .set_io = _set_io, \ + .get_io = _get_io, \ + .io_dir = _io_dir, \ + .io_link = _io_link, \ + .io_unlink = _io_unlink, \ } static const struct bt_bap_stream_ops stream_ops[] = { @@ -2289,28 +2493,40 @@ static const struct bt_bap_stream_ops stream_ops[] = { bap_ucast_start, bap_ucast_disable, bap_ucast_stop, bap_ucast_metadata, bap_ucast_get_dir, bap_ucast_get_location, - bap_ucast_release, bap_ucast_detach), + bap_ucast_release, bap_ucast_detach, + bap_ucast_set_io, bap_ucast_get_io, + bap_ucast_io_dir, bap_ucast_io_link, + NULL), STREAM_OPS(BT_BAP_SOURCE, bap_ucast_set_state, bap_ucast_get_state, bap_ucast_config, bap_ucast_qos, bap_ucast_enable, bap_ucast_start, bap_ucast_disable, bap_ucast_stop, bap_ucast_metadata, bap_ucast_get_dir, bap_ucast_get_location, - bap_ucast_release, bap_ucast_detach), + bap_ucast_release, bap_ucast_detach, + bap_ucast_set_io, bap_ucast_get_io, + bap_ucast_io_dir, bap_ucast_io_link, + NULL), STREAM_OPS(BT_BAP_BCAST_SINK, bap_bcast_set_state, bap_bcast_get_state, bap_bcast_config, bap_bcast_qos, bap_bcast_sink_enable, bap_bcast_start, bap_bcast_disable, NULL, bap_bcast_metadata, bap_bcast_sink_get_dir, bap_bcast_get_location, - bap_bcast_release, bap_bcast_sink_detach), + bap_bcast_release, bap_bcast_sink_detach, + bap_bcast_set_io, bap_bcast_get_io, + bap_bcast_io_dir, bap_bcast_io_link, + bap_bcast_io_unlink), STREAM_OPS(BT_BAP_BCAST_SOURCE, bap_bcast_set_state, bap_bcast_get_state, bap_bcast_config, bap_bcast_qos, bap_bcast_src_enable, bap_bcast_start, bap_bcast_disable, NULL, bap_bcast_metadata, bap_bcast_src_get_dir, bap_bcast_get_location, - bap_bcast_release, bap_bcast_src_detach), + bap_bcast_release, bap_bcast_src_detach, + bap_bcast_set_io, bap_bcast_get_io, + bap_bcast_io_dir, bap_bcast_io_link, + bap_bcast_io_unlink), }; static const struct bt_bap_stream_ops * @@ -2396,15 +2612,23 @@ static void stream_find_io(void *data, void *user_data) static struct bt_bap_stream_io *stream_get_io(struct bt_bap_stream *stream) { - struct bt_bap_stream_io *io = NULL; + struct bt_bap_stream_io *io; + struct bt_bap *bap; - if (!stream) + if (!bap_stream_valid(stream)) return NULL; - if (stream->io) - return stream->io; + if (!stream->ops || !stream->ops->get_io) + return NULL; - queue_foreach(stream->links, stream_find_io, &io); + if (!bt_bap_ref_safe(stream->bap)) + return NULL; + + bap = stream->bap; + + io = stream->ops->get_io(stream); + + bt_bap_unref(bap); return io; } @@ -5888,14 +6112,25 @@ static bool stream_io_disconnected(struct io *io, void *user_data) bool bt_bap_stream_set_io(struct bt_bap_stream *stream, int fd) { - if (!stream || (fd >= 0 && stream->io && !stream->io->connecting)) + bool ret; + struct bt_bap *bap; + + if (!bap_stream_valid(stream)) return false; - bap_stream_set_io(stream, INT_TO_PTR(fd)); + if (!stream->ops || !stream->ops->set_io) + return false; - queue_foreach(stream->links, bap_stream_set_io, INT_TO_PTR(fd)); + if (!bt_bap_ref_safe(stream->bap)) + return false; - return true; + bap = stream->bap; + + ret = stream->ops->set_io(stream, fd); + + bt_bap_unref(bap); + + return ret; } static bool match_req_id(const void *data, const void *match_data) @@ -5941,41 +6176,49 @@ int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id) int bt_bap_stream_io_link(struct bt_bap_stream *stream, struct bt_bap_stream *link) { + int ret; struct bt_bap *bap; - if (!stream || !link || stream == link) + if (!bap_stream_valid(stream)) + return -EINVAL; + + if (!stream->ops || !stream->ops->io_link) + return -EINVAL; + + if (!bt_bap_ref_safe(stream->bap)) return -EINVAL; bap = stream->bap; - if (queue_find(stream->links, NULL, link) || - queue_find(link->links, NULL, stream)) - return -EALREADY; + ret = stream->ops->io_link(stream, link); - if (stream->client != link->client || - stream->qos.ucast.cig_id != link->qos.ucast.cig_id || - stream->qos.ucast.cis_id != link->qos.ucast.cis_id || - stream->ep->dir == link->ep->dir) + bt_bap_unref(bap); + + return ret; +} + +int bt_bap_stream_io_unlink(struct bt_bap_stream *stream, + struct bt_bap_stream *link) +{ + int ret; + struct bt_bap *bap; + + if (!bap_stream_valid(stream)) return -EINVAL; - if (!stream->links) - stream->links = queue_new(); + if (!stream->ops || !stream->ops->io_unlink) + return -EINVAL; - if (!link->links) - link->links = queue_new(); + if (!bt_bap_ref_safe(stream->bap)) + return -EINVAL; - queue_push_tail(stream->links, link); - queue_push_tail(link->links, stream); + bap = stream->bap; - /* Link IOs if already set on stream/link */ - if (stream->io && !link->io) - link->io = stream_io_ref(stream->io); - else if (link->io && !stream->io) - stream->io = stream_io_ref(link->io); + ret = stream->ops->io_unlink(stream, link); - DBG(bap, "stream %p link %p", stream, link); + bt_bap_unref(bap); - return 0; + return ret; } struct queue *bt_bap_stream_io_get_links(struct bt_bap_stream *stream) @@ -6052,23 +6295,22 @@ static void bap_stream_get_dir(void *data, void *user_data) uint8_t bt_bap_stream_io_dir(struct bt_bap_stream *stream) { uint8_t dir; + struct bt_bap *bap; - if (!stream) - return 0x00; + if (!bap_stream_valid(stream)) + return 0; - if (stream->ep) - dir = stream->ep->dir; - else { - uint8_t pac_type = bt_bap_pac_get_type(stream->lpac); + if (!stream->ops || !stream->ops->set_io) + return 0; - if (pac_type == BT_BAP_BCAST_SINK) - dir = BT_BAP_BCAST_SOURCE; - else - dir = BT_BAP_BCAST_SINK; + if (!bt_bap_ref_safe(stream->bap)) + return 00; - } + bap = stream->bap; - queue_foreach(stream->links, bap_stream_get_dir, &dir); + dir = stream->ops->io_dir(stream); + + bt_bap_unref(bap); return dir; } diff --git a/src/shared/bap.h b/src/shared/bap.h index cd5ea2eba..126348e81 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -231,6 +231,8 @@ int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id); int bt_bap_stream_io_link(struct bt_bap_stream *stream, struct bt_bap_stream *link); +int bt_bap_stream_io_unlink(struct bt_bap_stream *stream, + struct bt_bap_stream *link); struct queue *bt_bap_stream_io_get_links(struct bt_bap_stream *stream); bool bt_bap_stream_io_get_qos(struct bt_bap_stream *stream, struct bt_bap_qos **in, From patchwork Fri Oct 25 12:21:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838806 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 324AE2003C1 for ; Fri, 25 Oct 2024 12:22:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858947; cv=fail; b=GWwKmi7koy3/tls0k5iJUQ4TeEe1LLK03jQpAJJzq2869u7Q2SYq1ItxQ41nryMm8FS1aXMVMjt8nvsgmpF5mMecUeHVRf+BNXzHQU9qhdVsGIXyNe7ZuPa+Efub1w7SAb3rPcbWm3R41pEV21gzVQ6DFwHGZJNGUncVh+TG6hY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858947; c=relaxed/simple; bh=KCTXfeS1Vp4ztM2OxZH8DnCVQvjzPo60dgO0s5W8r0w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=p6HEQEAOYtNVarvtlRS53pJfxc6fAvWVSERwy9raSGSBM4PUrvzlwmb0+Qo+rLEBd91BCSKlB7OHY9zH5zNBFRfnfmyzB0aPTTikxuy3jcPUybo0KBeY6bf38X5Va2Pe3cp3UaR09+bQDhq/UJVru4HBZ2gixn3foXB67oHIdPc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=oIltK8cZ; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="oIltK8cZ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SXD3yp1nhrQWMRvVdVr+bnt/sSDGpHTvK0QcBuKLyufiJtlLy3SY6/ubtsf3JoW1g8SABuXU52VG3h5DcY69d6kKZP44X6Nh7imwIgZU9hUG7AwJMRgRz0HhcNgIObgRAjDakEb8DNkrnMI6Z5X3diyjfTflBu1jefc2xA4bwquRlxLsj8Qf9YtbgWgW/mmhHSPHAHJbwFs2aYRo+Op0fmPefJe7N6lb0Q5hGk7d/O+/G3ThoGXdijdIgyzsR0m9T7QB5yKqqCZQn/EeuHucqnSD3LKrcXcVsaXym/0E2bTuPH9xLEHmNBHjYCtvF7o0FJZb+Zr0nXjoxSeuenR73Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zwcTYG4EvntBrtoSqFm8AVSmvcVJLnuAa99fFwX/KTE=; b=U0qtirDPIr0rvSgtRmUDYNjjRbsuicgmp69b15lFTwaeRjcSKK1JHNDa6j4jMcRo83FE6GVZE2bRjJHdEGVS1OJT421ebPqAr39qmfbWX8zYFIbV7MMUG3vN4WkuGF3uH4GGC5jz7o3ZLo1LV2Ccp6l4cxn9+zIBdT2dz+e3Q4TtuS5q4E27m1vAxVp6RuxZ2TquP7vRJgkjom30fpIAADLWjhgFaU3khQTkLhw34IYOGrz0Db1gkusHwmR+SbaU9Ej9ao5JnB7Q7pg84S+Vp7+ZVxd39dIgTpUBRKPAkJIwoacNwyeTBxnB8RXvZJ6BaTLjTfe5D7tTAQK1eoqbBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zwcTYG4EvntBrtoSqFm8AVSmvcVJLnuAa99fFwX/KTE=; b=oIltK8cZr4B7BYNq7aCO6UywREjizTxvH8dLa6UcVyzYeSNeLFc8wjoRAYDwgpN1v9cuWa4+LTaQOOrd8vJbg/pyFruwgoaDgAul2V+nF2R1hVK7ZVNFdAP9amP6D6qWGl3mTYKXVgySFCfqQOYBylmAJ4LpCOL9ZsnaESz49Fe/yqHfM7KU1gJnQefo13pUUVTb5XQhvZR4dhC5zfHynIy53LP4wl65Dqd/tjQsiJ4BmFZLBceTte8Th2Ga3RNirBK4GbQaPr+qPFni+UYBweRjRqvZllkQr8x47xCECsrIt+WhCgiIQW/jY5l9f3uNKH4TCCunl/LZvi4945+W5Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:18 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:18 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 03/14] shared/bap: Fix broadcast set state Date: Fri, 25 Oct 2024 15:21:35 +0300 Message-ID: <20241025122146.17925-4-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: 39ad4573-fecd-4cd7-196d-08dcf4efaafd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: lVwdcDJXIA5WpdNWMd2yFcwsbDwLgsYVRoknSxmqz5J5HcaZqcPN4Tu4iMcE51yRAl0Br1iuzzhz6hYiIOlRIxJT7Orq+HfRjJPg29sjwIZGKK8jdjJZMR9ZsKR0aI8sTFsrFDFgAajOlKequ+MTOOFhLwHDBgmWgamwUU+0Oq44dcpAWB6EO413KJpImIopkq/1ANEs0gMLDwdODZ4R/v6gFIi6+9P8b6pUX6ha2vN/L/DFATd7jGoaKJe99mU06SS2X/tGRrGdBOR3FFmq8l2HdR2X6lTa8BtNQaTpO0uXFPhtjUCL5MZ2/IIe+tJiN559i2kw3OeROktwt3GNxBoHm93gy6K7XYtZ5lK6CxnglCQGmVXwSFg5PoStkkuh5PJ9IZ/VdFuUJzSXmGFYW36HLUMad4vb1ZRcI1+tuMij1lj6kg4PDlNm4xM9r4y2q5lUDA3gIj7VDO3iab7OvSReNHB4RLqh2BGU8q+J41QzQU0wsFtSG4vCQiruLWx4q9sXdFUNDgMHwaI2Dro7DfMGVYAi/TSgFGNDFQV+uv9fxwbU93DzBl1WV+ULYS5ktfYknydNxzx+G/tLHZqJHLjTHD/k4exXfD9aXZ9Au4GVc9GOstiAlSta1ufmFDXb7FU2hVK7CFGl8zZ8iA44erZ6vxndtvI++9dgvXQclWhTHw61ytOHU5WeXAr2bmFAyff9uvDAATMzat1bKQCwUzc+RGL4+Jfej+LQ1P/j4XBUNx4JFlTXMyG2PyZVBawcL58Aurdm2HlF0XHTHdOL/ZjE4JcddOAiHttvrofzTUolQvMeCIImyrVt9JA5MOnn1ZlkZ5U3/XNBuY7hz09CPntdtQWDkntgl3PH6qcGpCWy0ILySzngje4kJZ5CzwgIev4AxNDOTtLfUmhFeMSGM8NbzDGYDlDMiR7RnNo3il1QCthREVyAYT1DYSCSYp6awNJLvMY0rYE8jqJrInl6a+k33R/bgAgxczr+8f5O+CIAPT2HNWt0N+Z4SEBN3KeuKa1JPkHrqAdxLCECQv3VMWueoFgzo8vTdcNvRPtGqx/Yiihviz5HeI/5GQSaDyS7IyM7ROKGU6VyU3D077cT+LGVhfN02C+itsuFL2TrwXM0nfWaCm9Q+7RUJBHmAa9GRKnRRFqKA0ke3d5FwwRAYn2OEOob/Bp4/5hDLv3K3rJHFEAIJW3XngK+I9D9B9aaYRqYWPt9hZImL0nYlgRbMhWzuan0/nC+/8Us3ET15Vm6KzhxRdiG0LAsKshPw+drPD0H7X47n5aXn/PMV6tG9lICS3BkOk2wHXnZQQNxSe1vWuF3Gb+UipPkkJzygrib98o3bzacscyp02fLCzT1NVeCfHD8+HjKa57fRa8PvVw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xiyGUPzcEgreg8ZVmtk+0wFtOAjlsc8XCHfw/5RJWjGuDNX/ETszCiUDmJOn6GS/UPt4rNTEpLq78WQ5LCs9Ff2G6nLnmAic3a9umJK1bw50AgH9xU/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51vyPLVxgX/0GM6iiJ3LGJierIRLKXD3gr9RVjM+ohyDxPdIzWsoSRi8vthI0va3gfp8T5nkzKdJNF/0iAKlDeo456E5bzqPecolvtzxLAkGYlDGBKZX7sp1vC3K7R9DJGicG2sOCBdyzqkymM3lHJ/ZcPYqxOMi6Z85jNkt+WzUqF+3+Nqjx3WBEQYuiJN/9xxgxd7HjXxdR2FURoVBtCjlpa9x2v0oZZPXewuWDEhQNpFa6+7mEb/Zf2/DNXBTuuZHokCHktEYa/GOGmuTJ7pUmUtjyKpPvIDKhkH8nUQvhOIqL3Q2YjrJsdMKYdZ/zmojH3ORP2DOhBWIreZ1CiJ7MtamaelZLcujxBHFiKokaWlfRyPEfQ440dEGyvqztdo6tSf4x/iIlSrN69Zd3ygCnulb26fd/EUUXlvWnb0cvbf1WTCGGIjCAwLNOEQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39ad4573-fecd-4cd7-196d-08dcf4efaafd X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:18.4329 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NrkoBBgouXqRHNo7OImmccGJM15hznE/GYz4A1qkHOpjIWN0oU0szPB/3foCGet1Hr5bQRc5Vb66I09EpCL3Tg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 When a stream changes state, the update is notified to other drivers that registered a state changed callback. These callbacks might further change the stream state, leading to the stream being freed. To avoid use after free errors post notifications, this commit adds support to ref/unref streams, to make sure that the stream is kept alive until all processing is completed. This also updates the switch condition post notifications, to handle the stream based on its current state. --- src/shared/bap.c | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index a696471bd..17fedb397 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -262,6 +262,7 @@ struct bt_bap_stream_ops { }; struct bt_bap_stream { + int ref_count; struct bt_bap *bap; struct bt_bap_endpoint *ep; struct bt_bap_pac *lpac; @@ -1204,6 +1205,17 @@ static void bap_abort_stream_req(struct bt_bap *bap, queue_remove_all(bap->reqs, match_req_stream, stream, bap_req_abort); } +static void bt_bap_stream_unref(struct bt_bap_stream *stream) +{ + if (!stream) + return; + + if (__sync_sub_and_fetch(&stream->ref_count, 1)) + return; + + bap_stream_free(stream); +} + static void bap_ucast_detach(struct bt_bap_stream *stream) { struct bt_bap_endpoint *ep = stream->ep; @@ -1220,7 +1232,7 @@ static void bap_ucast_detach(struct bt_bap_stream *stream) stream->ep = NULL; ep->stream = NULL; - bap_stream_free(stream); + bt_bap_stream_unref(stream); } static void bap_bcast_src_detach(struct bt_bap_stream *stream) @@ -1238,7 +1250,7 @@ static void bap_bcast_src_detach(struct bt_bap_stream *stream) stream->ep = NULL; ep->stream = NULL; - bap_stream_free(stream); + bt_bap_stream_unref(stream); } static void bap_bcast_sink_detach(struct bt_bap_stream *stream) @@ -1248,7 +1260,7 @@ static void bap_bcast_sink_detach(struct bt_bap_stream *stream) queue_remove(stream->bap->streams, stream); bap_stream_clear_cfm(stream); - bap_stream_free(stream); + bt_bap_stream_unref(stream); } static bool bap_stream_io_link(const void *data, const void *user_data) @@ -2139,6 +2151,16 @@ static unsigned int bap_ucast_release(struct bt_bap_stream *stream, return req->id; } +static struct bt_bap_stream *bt_bap_stream_ref(struct bt_bap_stream *stream) +{ + if (!stream) + return NULL; + + __sync_fetch_and_add(&stream->ref_count, 1); + + return stream; +} + static void bap_bcast_set_state(struct bt_bap_stream *stream, uint8_t state) { struct bt_bap *bap = stream->bap; @@ -2147,6 +2169,8 @@ static void bap_bcast_set_state(struct bt_bap_stream *stream, uint8_t state) stream->old_state = stream->state; stream->state = state; + bt_bap_stream_ref(stream); + DBG(bap, "stream %p dir 0x%02x: %s -> %s", stream, bt_bap_stream_get_dir(stream), bt_bap_stream_statestr(stream->old_state), @@ -2162,7 +2186,7 @@ static void bap_bcast_set_state(struct bt_bap_stream *stream, uint8_t state) } /* Post notification updates */ - switch (state) { + switch (stream->state) { case BT_ASCS_ASE_STATE_IDLE: if (stream->ops && stream->ops->detach) stream->ops->detach(stream); @@ -2172,6 +2196,8 @@ static void bap_bcast_set_state(struct bt_bap_stream *stream, uint8_t state) stream_set_state(stream, BT_BAP_STREAM_STATE_IDLE); break; } + + bt_bap_stream_unref(stream); } static unsigned int bap_bcast_get_state(struct bt_bap_stream *stream) @@ -2568,7 +2594,7 @@ static struct bt_bap_stream *bap_stream_new(struct bt_bap *bap, queue_push_tail(bap->streams, stream); - return stream; + return bt_bap_stream_ref(stream); } static struct bt_bap_stream_io *stream_io_ref(struct bt_bap_stream_io *io) @@ -4148,6 +4174,13 @@ static void bap_detached(void *data, void *user_data) cb->detached(bap, cb->user_data); } +static void bap_stream_unref(void *data) +{ + struct bt_bap_stream *stream = data; + + bt_bap_stream_unref(stream); +} + static void bap_free(void *data) { struct bt_bap *bap = data; @@ -4166,7 +4199,7 @@ static void bap_free(void *data) queue_destroy(bap->reqs, bap_req_free); queue_destroy(bap->notify, NULL); - queue_destroy(bap->streams, bap_stream_free); + queue_destroy(bap->streams, bap_stream_unref); free(bap); } From patchwork Fri Oct 25 12:21:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838488 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50A151F9431 for ; Fri, 25 Oct 2024 12:22:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858949; cv=fail; b=o/Mxy90XzpoY3Bw3xp+hL5pKX2lowYEeUxezuIRaKGj8jq6oumoIe+tyatrrHeon8AvuJBGIes9qezICNVi/oBlBJOeusI4u3AxEeY+xtkeH+Jt/BOjlA8YuPpyUqojytx2V3/qENjTtwLB8dqvT4Txkib3GlnO8qmpe57mfQDQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858949; c=relaxed/simple; bh=8xRDB9ovg70a4f1MdIK0e6b5DL3X/61zNLqvC9bhEvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=iOXSNKQJmEI248VXKdHl5wW7Y08cFnxZ+Gxoa8Xuj5o2/WGkxzQgpq9DT/UaRZT65rjj2GB3Xlsd5PBw2fnIBFT3h9nvcmcJ6G0p3tftt77dl9DdXCg1Wj+h0neNoKH/q7+k1THFwFBD/tuRJvLs6nkgjXBDD1D88wXrptXGCao= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Fsi23soj; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Fsi23soj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SwYWEvBgBAvdqqk9/djDwk1+FULMLZzBN2wK5tnEIun/dmSl3rrFhC6O/g30OXVg8ldmyBSqX1TitjJ0cFjq+L+uubFaQaLfxpoqsaFfogrT2MQLmieSxQcn4kuCKOQqVAacPiMQOaBr10NgCjtjySwjiBjzFGOqgCmNYsGCI45Lfzq6v/oYLfyanynj3E0XnRcZ8tIKbfyBx21pxb8xBQtv9SchgVJ2uqEgsQMa5RC1Y+UXtmKwVUB75sjIXNa42Kh5cMXFnlzve0Aay+wxM/77DUPq3n1dN/JpMIqO96TAXsM0fjm/jj+988grWfBG5UCXLX6P0GSHkmGR+snKDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9YQM9ltIZsX/V+zLsBt/H6LU2t6pK3ly5daKehwnspE=; b=uI5IfwOqNLyPFLJz6jpp5O0N4YioYMVbrpopvVmV7TTGYTVMQSSDkCw0Q6K18gnvARIIEHYf44KpghJDrx0pTgrxIBZ4r8DmokTBIMiPPPR20K2yZ0uPHIR/j7qyBzomxL2B4KBpW74PnaymADKFmpjECdJDQkE8/nXlZhGaAVt54fO950+FUmLvWH3QJfOTLiArUhijF+ld4ir0dEdSU+ZBLPe56PfRq1DfEX1W09dpE7TGgnNjCgFtB7aidfvlItcnkcuLLBV5a/DFvAgY18U0PCVnQMUrxCzDHhUbQP6v+RArP1dl3HPe5I2zVK4oAIp5itOV0ed4bkFv3T94GA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9YQM9ltIZsX/V+zLsBt/H6LU2t6pK3ly5daKehwnspE=; b=Fsi23sojn1TY+8dDivPvqhT5mFQtof7e5jdgOMxifKdUVU2eynoV2dWqdW2i4b7VO1wHeAVCNod34sdtO5Uge4+kPdz+87UTEWSq7hVuRyoXL0zIpJ/IlUrEfcfLaqM/uzJwaFWh0tX6VZhGTkppiL83i4Kh7JLUM2MPacIqM/VGLp0722EvZFovjIvFFD0TgOnA2sZcW1juMU4i951Sv/SvCJlrtIDY1jcKXU1kls83CtrrYGrL9hPAj8+/k0SbojbCp7wjB2W3SEb3u1XBtySGgIDpHa34p132axghWgiEpK0pJnf01D3ShEuxCt9w+4MhiGIJnenuGzxg3+OYLw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:21 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:21 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 04/14] shared/bap: Use enabling state for bcast sink streams Date: Fri, 25 Oct 2024 15:21:36 +0300 Message-ID: <20241025122146.17925-5-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: 7721b78e-28e3-4e05-6fd3-08dcf4efad16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: O34gCAFlgw2EpXIVzDrari/ZWnJCigJWGYrUGoAyyGW8Nhehe1vhbJ+3CWeo7B253NrOHOhSN1a/M6huvTLVa9yVQQcfiDU4/xk9GqKayzviCYWrt0xpz/I2eyZ9d+SCuOF6fBxNOEAlbF6OKfKPK2bLo3kiHVJWI8QMrpzdeZWh1KmqbXUL57Wugo6Ohaiy1efVEH141OjDQg/I5CEKcbk9lQDEXnzW2XnBPBa7c1dEw+8ADlxICEAjswj/qn5ax5BQ/6xB5mTKFWDEprFLtG8KLCnvdKAILWgoJYtt/J51Sp+jheYKYdnYMvW8kSTydgj3f7fC5jmHz1hxyNT0rmoqo3Jd7YjJz6m94GRxtKiOVCxKB4RV3MV5XpwwJEabvcRraR3X/weoQBzx0fQ0XNYY+A6Z/ePhgDlqyvbo9DgNDABY84Tmb6ovvJoQtYftDVA82amrMP8H+pM4lO9qz1mw7Xp9St+fUEDE8cAsoQIDt+JUcShl6GW2o6z/6SUj/HdivpjKu9hqQK5+PNENJiG/uTuNLvrSsL3xa/y3Tex8TP7UCRHVOGBthGc5ogrFhnIqdwwXboXH/EnuPefjZ7iyCs/QQP32UNMvdHqnUClNQE3XoMsiAprp4mVnwaW33f0zq6joDXN92/tFPZsVc1Df/Ld4oOLvc/77uOmUxuObHrybWXbkzNjT+N2JE9MF5zMnjv6+IOOYiztkcCiDzkurRoPANMtLGeWia6n0TU/CRU5aNlsQcr+coJ3kwb5LhgLqgc5/LdD3aUq7ASsGDzjGqb4GAEvHyxGd4PJeHFK49Z8I5bPyFiviTHXK8vRDScGRt74wrwe2o4VSL6Rsh6uSZuhWZwoBhHMKGaUdDLtonkE8/UCD97vRAHCgBQyLlN1RivjA2IwrRScM44/awWNhn92rx1v9cfaD6UYW0fJoJsTZHbycJc7sYQ/cwqnFUyAceJWttvmKDPJA6SjWHHoYJgxi1DeqJocnkcctzvmSnfFxmt9jqnXj3sRKmDhoIK9EXSZEUS23Uvf7X5q2jtGZcKlyxus+IwRO/mHtLJ51ZHSoHYZH4DOYsnbP9OOtgerm2COIz1DST8YJWkyC7VEA2uZHQYSc/sVXYi1B2XS+bye8yXQwjsWsWMmcTNa2TABLEYDXZGb5yIxa7LA2qR1PCEV3iKcYwctpNjpqsXFM0AvflpfRlr/SJUnF3/xBs7vRrhAX11fjl+hzkwU57ZpM3ZDNvCVVT/uW+xON8thMk/i9oHUseFfjOgwkzOM0CASeRPjH+IoGCp/0KO+/O+qkbJQSS/9Gvv9a9GsL8zZ7oibamT82j9Fvk9cu5mGBDFVf+S/iQnfI+rxtQ2OcKNTNMMcDPMwL4+LO+mTV+tw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QlbbUuE9QutrH+N7qn0dLgP6aAqYDCuK2tqYCumR9G4DGnvYp61oAwrrqZDqDRkjvOYgVB0wheGgd3HFT0Q3ci2+WFjmx1OyvvGpBDhWXdKNFYnpG9aRzV/HkW5WB7hHI1bmiBkvw8AmfSDe+H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BCre4E7w4Ui+dtC4CVN6WEzG/BQmBb8EMjECMEfxX2SrTZ98oJ8ZsMP6LA7BeQW0/GmBxJQef7dJIRWm5yVEusCFB9DjzP7mU3QY2vlrJhPQ8D3drO5Qugn8Afesb4xU0gLN9zsUqnoeSODCGp5kkuuw2eMrsHTzMwyAMkjjpM6J3TTkDkFtGgvwm8hAluNFbrXarqPg23F/TdUWQJuiCf6PiyFt87CtBuMU6zQxnDquspCiL2iw1St9kQYKd4mShE15SF66vazpEsfB0rqO2Z2SWMvN4Mix0KueAWWjHen2xfMlMF+hJz2+HjuWnQl3hpjlMAX8mEAMO9Mn4g5UxGr9p2NVI0DY8mitYNwVDyLsMR14sZRih2WE2SxMBsQuQi1JoQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7721b78e-28e3-4e05-6fd3-08dcf4efad16 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:21.9203 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UlDX7hE8NNX69Qh6uGr+SbjF1MQtkyr9x1X/gpGqts/tNvOQ9qDOY/Wx5QnwKGqRe6m/V8SRvlGOy4m5aZgkCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This updates the stream state transition from CONFIG to ENABLING, on enable for Broadcast Sink streams. This is done to differentiate between streams discovered in the BASE after short-lived PA sync and streams that have been selected and enabled by the user. --- profiles/audio/bap.c | 13 +++++++++---- src/shared/bap.c | 2 +- unit/test-bap.c | 7 ++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index c45717ef2..81e1fb03e 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1020,7 +1020,6 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) free(req); if (bt_bap_stream_set_io(setup->stream, fd)) { - bt_bap_stream_start(setup->stream, NULL, NULL); g_io_channel_set_close_on_unref(io, FALSE); return; } @@ -2676,13 +2675,19 @@ static void bap_state_bcast_sink(struct bt_bap_stream *stream, case BT_BAP_STREAM_STATE_CONFIG: if (!setup) break; - if (old_state == - BT_BAP_STREAM_STATE_CONFIG) - setup_create_io(data, setup, stream, defer); if (old_state == BT_BAP_STREAM_STATE_STREAMING) setup_io_close(setup, NULL); break; + case BT_BAP_STREAM_STATE_ENABLING: + /* For a Broadcast Sink, the ENABLING state suggests that + * the upper layer process requires the stream to start + * receiving audio. This state is used to differentiate + * between all configured streams and the ones that have + * been enabled by the upper layer. Create stream io. + */ + setup_create_io(data, setup, stream, defer); + break; } } diff --git a/src/shared/bap.c b/src/shared/bap.c index 17fedb397..b314b4b99 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -2210,7 +2210,7 @@ static unsigned int bap_bcast_sink_enable(struct bt_bap_stream *stream, bt_bap_stream_func_t func, void *user_data) { - stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG); + stream_set_state(stream, BT_BAP_STREAM_STATE_ENABLING); return 1; } diff --git a/unit/test-bap.c b/unit/test-bap.c index 9cfc8c403..0c190d7fe 100644 --- a/unit/test-bap.c +++ b/unit/test-bap.c @@ -6419,14 +6419,15 @@ static void bsnk_state_str(struct bt_bap_stream *stream, uint8_t old_state, /* Enable stream */ bt_bap_stream_enable(stream, true, NULL, NULL, NULL); - } else if (old_state == BT_BAP_STREAM_STATE_CONFIG) { - /* Start stream */ - bt_bap_stream_start(stream, NULL, NULL); } else { /* Other state transitions are invalid */ tester_test_failed(); } + break; + case BT_BAP_STREAM_STATE_ENABLING: + /* Start stream */ + bt_bap_stream_start(stream, NULL, NULL); break; case BT_BAP_STREAM_STATE_STREAMING: queue_foreach(data->streams, stream_count_streaming, &num); From patchwork Fri Oct 25 12:21:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838805 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F03511F80DB for ; Fri, 25 Oct 2024 12:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858952; cv=fail; b=MaSvD6WK5WDVld9I4aSKuRuVK//M6qtoXZHw6hKmH3FKPWWXdZn58XO/QpoVzx+4lqldn3To/k8K+4CQpFFI9yfAb4vpBbOwId51ExtoWlGn/CxsfpewghxveNeydlUtKP2e2oD1ddn/8JjQgMFFe6a1L1iLxQIClOr16A3WrQk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858952; c=relaxed/simple; bh=CimEUsgb+hSKdXv5lc4cttFowBU7JZ5evqCUoSIIuxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=bIWvAkJrHevp/NkQTb1MsrjdLNYoKeK8BspTxt0g4W/exsyATyAK6pQtobcnsL+lKuXw9X9RuaDFxT6SdtpI13w483Fe0UYBSeV7CbdtCj1NWV97UhMO9trcm4HzAeaxupiLzbreUCfhVDeBfYdWGk7Wt+vFvcqNP4AjBVU3v9I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=RJ48gdNj; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="RJ48gdNj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x0r+QL6FPXVX9mBbdPYSCJ87iBP9zXCXJ0DTLtvMxOR9k01SwL9LdQczfsoQfxnJMjnd/ZdfFXKLEEXb0NqBItq9GeQmaQnTQphP8YyvMQ5+S/Ej/HwDOOKafYqGArOQBFuu4P8g9XoFeiZwCaUfD0KNXAK0I5+SLm7Bk1NDiXgcIDwha4+mUNvDKCdp0bARKx5joba+aZPdJuNGwPgeMF08FI1U5w/eZMP4teF0OFQuyKcXZz43H1NPNrctWDWo23r+xQYXve2JjDhZs3M6yHj4bHTdZtGPJdqM1p+gC5LO4kSniyiVhezx8fPVNW3hrVj4JgSIxC6j4dO7BA2baw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TPRx1EL+Ory0wF/hWi8VLsusGaNBICYmIZFqW9JgFGA=; b=zIOaadzmwvrczzA65nIhK5X/AYblz1GJGOnsK+OtnNsfeKl3UlNLJpqjKcqV7VWNy452DyKcDtcMN+D/MJjWLvTsoVlVLFMLcjpxhbbdruSFuyFGieJAoRWqFEjcj0ioAEqM9cu7gOdIYXTSAJQTOJUBuww9I1R93hFmK6+KntawbJ4UQplwanOqtOZBSVD5lDhXbW+rnpqlhI0AvJH/xFAwWMqhkE8diXKpCrd5MoqLmRRpJ+wdGnwIzRozGMmvHDFqNYIT5bNDjd+p7KJYE3k/6z+D1Spfgot2u1ZLxuMC+2VStrI25f5GS9dXwhoFzLBN9VyZSu0bukuiZ8TkrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TPRx1EL+Ory0wF/hWi8VLsusGaNBICYmIZFqW9JgFGA=; b=RJ48gdNjEfgb+c/UDLP4DLGQtW+Vyu6GiQQ6Ny9s8j3GxYHie5pg8Zj6tvdJBKX3cGg0N1kqsz4G0UjB7d7N+LkHrFscq9gKdanCFdAGg/yn+yMmafp/3bm6MM6y6Coyac5scr1DB98UW8DzH4dObLxZ122GXHgPMrETYhpObZxZ1N8XY98aSJko151izKQKdjO9FQsF8V843zjA+p6smwuqkQTX9IOFrVoTVR5zli2+ceIMRR6PSGzIeeY+qtxmoTR0mQquxFzg2uSRGxXeeNG7guzzXLCIujdpFhFQ9mDvvT0fblFtZcm9NvyfOaim2dpebHIJqUWfRSxxKDMxpg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:23 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:23 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 05/14] bap: Add support for syncing to multiple BISes Date: Fri, 25 Oct 2024 15:21:37 +0300 Message-ID: <20241025122146.17925-6-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: ace94775-978f-4bd4-6bed-08dcf4efae33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: pYsbFKMqwveXl16wrZcs9ThHqAjVSgobdQLrE3KrSOgFDpOxSgM2wWsg/iWYuQGOqcotzaoxxbdwFBHzWrgM4nxpa6rGlT6HDZMs4P2vrMuNquGxCb7NXPW35O7jE++0baSQcQTsXnmKcXCgEuIwULuiHbIjHhz0ROLpjeMtR/oQeb3slrZcApp9jK4WC2ST6Ui6jxya7NsY1ea17j0eDx6Q15K87Ugn4xMqjohzGAsTVS4h6NEHdN0j6mJHD3cqbtgnj9f4SLE15pGB8bGv0MKIqyp8UJ1fsID5hGONSob3zDucf8+SKZvUk4LnfUErh6Lvnjgc61uG4VrIWVimoYkt81KkMFmtXZC44hazmR4pqSAR9p7cR/aPAwfB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S8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N/Z2pTsuzhNXudVA8jbLOnJ/QM/8qtywXZu6S9+oT7ATVJUlqdLpaDKys2IpLvVS9UUbFrJWZMPrlBtQlG56O0ZU43c+hGhSnMkkYZngpQGODrA+YqLAWitieHiZsQVrra3zEMIAGMKObuUhE9raVVNkfZCvrMQPAgBidJ3XSjUB3OGr6/9ex8ecy3EzgtiHlCIO4TkT5EQsddWnnPQSk6jL19LsAcgCRbf7DKu7NUjDjs3ZFey1pacfmR0ZhpZ8c2/IIvSEDPLhjkeUTwvgbMkA0uk/46hZiGWEAp+aJVVxsxKmNusc3yVh48TYG+wdnm3tdXi3JHwtVyXqGGsiTa7GQfiNpfURep1mu2fE0s+KRHkn322cj+cZSzi0WmYKkMEGDNHBDcIM8Nv6nm9BIFsCrD7sN7NyWQcGSfUWrpR6DZli4TrHroUMDABECZ9r3fJu2GFJhtPVDW2kii33tXqsx/ipdrYkxKx878XigVcYTxhPGjTdIpvQcV+M0akfuDMCPLOYQbawCMyTcNC0/533cA6ilK+M0Q1uaCULLodjNwrLpwz5u+RhovhKfKGBjIVQ3tfLWY/as4oT7bdD7rZ2R+vola0/Dcuf8aCQ+cUVihL6+l44NOGNZLVFOfybvi8ToAFT4vcVbleLHyon4UMBDON6L+2KFyRftDotcW1RhmphYnrw65mH4X0LxHaxV5kNsYpahBx1fDdu1WW01Cs4fQY6HgZddQDcf2EwickxKopj2IAsWUzKZOgKIXReVy9Qe/dpDETouOX7XGAzI3MFWQPab0tXsv7JnbTGWYhqzJa8h0+dQE+8FollRtk2JOpph0lh0yHcTuSKSW40pnORqtiXmdWIzrTzh35t1h/0yE2co832eRZphtabfDXSNK5NMIczYGranWQatL4/7zfX1g0v6f6GD9Ovs16bylR63/XkNcM1eg7xBw5BDNMgpGgd0ccC5ZXllrwQ5sYC+0s5wIY7YoO3FP3IaycjrTrZnTeYqK45elKKahGys0F4JtO3aE0G0AU/9QNCxtogVzsIWwsQZhB8I8q3VGPY6lT3Nqi+zRfNKWdQnGMHe+h8Z/eD0d9mGG6qvryIBIdzOS0IU8TuvZtfHVcPv4k8yhgyXRkwHd7DdaspkQra5SYem9JyHPWd3lbbcXr57T9VLP7tmFtYFUknX5txymimklKS5Jae8GMVFXlVnREnZW+QkT6dviO0FpeGlf4ZrXEZvY9aJQMC4IMzKfMSECT81xqH1tVSl3RWaqax9I9+/g98CdLw8GUuWcf2kX4ZcwzW4m+KNfSijiEvozQyNOuYjp5/1APTt1WHwprz6ODGzzYmHgdxzeuVcBu6waiXKftfglXCfGV1DuHclWsEc64ec5IEBxMwSLSh6cpJ3AyJMMcNlu0UmrKW0vmEo6Ak/VgK/y9JVMfIpgMtiRTrqFhmtlVEangHpaJfzLlGZKCir0y97OliNoNRiFzPGD2b6xgdyBpz3Yg1ZxvFzICi6qz7siGcZQ2ZpCEQuLalKgIKeWzWoNHuIfiFh+XL14OLk3Ytrt25cbEpXvsyi6u8R3FFLW6UVtDsurt3hk47iiQwlW6+CEOXkgSumNaPjVqAurfBgw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ace94775-978f-4bd4-6bed-08dcf4efae33 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:23.8436 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hPS37u9KP62fqHCzawxlltoksUjJHjVTHUerdW2+AGaoRcn+tSXWlyXVIcudZp1gKdMmYeNxOaNEJpX48Zsi9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This adds support for a Broadcast Sink to synchronize to multiple BISes from a Source. BISes selected by the user need to be linked together and then enabled one by one. The first enabled stream will enqueue all its links in a request for PA and BIG sync. After BIG sync is established, the confirm callback will be called for each BIS io created in the kernel. Each fd will be set inside the corresponding link, even the links that have not yet been enabled. The enabled links will be started as soon as the fds are ready. --- profiles/audio/bap.c | 171 +++++++++++++++++++++++++++---------------- 1 file changed, 109 insertions(+), 62 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 81e1fb03e..df685c6d3 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -134,11 +134,13 @@ enum { struct bap_bcast_pa_req { uint8_t type; bool in_progress; + struct bap_data *bap_data; union { struct btd_service *service; - struct bap_setup *setup; + struct queue *setups; } data; unsigned int io_id; /* io_id for BIG Info watch */ + GIOChannel *io; }; static struct queue *sessions; @@ -997,27 +999,34 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) { struct bap_bcast_pa_req *req = user_data; - struct bap_setup *setup = req->data.setup; + struct bap_setup *setup; int fd; - struct bt_bap *bt_bap = bt_bap_stream_get_session(setup->stream); - struct btd_service *btd_service = bt_bap_get_user_data(bt_bap); - struct bap_data *bap_data = btd_service_get_user_data(btd_service); + struct bap_data *bap_data = req->bap_data; DBG("BIG Sync completed"); - if (setup->io) { - g_io_channel_unref(setup->io); - g_io_channel_shutdown(setup->io, TRUE, NULL); - setup->io = NULL; - } + /* The order of the BIS fds notified from kernel corresponds + * to the order of the BISes that were enqueued before + * calling bt_io_bcast_accept. + */ + setup = queue_pop_head(req->data.setups); - /* This device is no longer needed */ - btd_service_connecting_complete(bap_data->service, 0); + if (queue_isempty(req->data.setups)) { + /* All fds have been notified. Mark service as connected. */ + btd_service_connecting_complete(bap_data->service, 0); - fd = g_io_channel_unix_get_fd(io); + if (req->io) { + g_io_channel_unref(req->io); + g_io_channel_shutdown(req->io, TRUE, NULL); + req->io = NULL; + } - queue_remove(bap_data->adapter->bcast_pa_requests, req); - free(req); + queue_remove(bap_data->adapter->bcast_pa_requests, req); + queue_destroy(req->data.setups, NULL); + free(req); + } + + fd = g_io_channel_unix_get_fd(io); if (bt_bap_stream_set_io(setup->stream, fd)) { g_io_channel_set_close_on_unref(io, FALSE); @@ -2265,6 +2274,8 @@ static void setup_accept_io_broadcast(struct bap_data *data, { struct bap_bcast_pa_req *req = new0(struct bap_bcast_pa_req, 1); struct bap_adapter *adapter = data->adapter; + struct queue *links = bt_bap_stream_io_get_links(setup->stream); + const struct queue_entry *entry; /* Timer could be stopped if all other requests were treated. * Check the state of the timer and turn it on so that this request @@ -2281,7 +2292,21 @@ static void setup_accept_io_broadcast(struct bap_data *data, */ req->type = BAP_PA_BIG_SYNC_REQ; req->in_progress = FALSE; - req->data.setup = setup; + req->bap_data = data; + + req->data.setups = queue_new(); + + /* Enqueue all linked setups to the request */ + queue_push_tail(req->data.setups, setup); + + for (entry = queue_get_entries(links); entry; + entry = entry->next) { + struct bt_bap_stream *stream = entry->data; + + queue_push_tail(req->data.setups, + bap_find_setup_by_stream(data, stream)); + } + queue_push_tail(adapter->bcast_pa_requests, req); } @@ -2647,6 +2672,15 @@ static void bap_state_bcast_src(struct bt_bap_stream *stream, uint8_t old_state, } } +static bool link_enabled(const void *data, const void *match_data) +{ + struct bt_bap_stream *stream = (struct bt_bap_stream *)data; + uint8_t state = bt_bap_stream_get_state(stream); + + return ((state == BT_BAP_STREAM_STATE_ENABLING) || + bt_bap_stream_get_io(stream)); +} + static void bap_state_bcast_sink(struct bt_bap_stream *stream, uint8_t old_state, uint8_t new_state, void *user_data) @@ -2684,9 +2718,19 @@ static void bap_state_bcast_sink(struct bt_bap_stream *stream, * the upper layer process requires the stream to start * receiving audio. This state is used to differentiate * between all configured streams and the ones that have - * been enabled by the upper layer. Create stream io. + * been enabled by the upper layer. + * + * Create stream io if not already created and if no + * link has been enabled or started. + * + * The first enabled link will create and set fds for + * all links. */ - setup_create_io(data, setup, stream, defer); + if (!bt_bap_stream_get_io(stream) && + !queue_find(bt_bap_stream_io_get_links(stream), + link_enabled, NULL)) + setup_create_io(data, setup, stream, defer); + break; } } @@ -3050,63 +3094,69 @@ static int pa_sync(struct bap_bcast_pa_req *req) return 0; } -static void iso_do_big_sync(GIOChannel *io, void *user_data) +static void append_setup(void *data, void *user_data) { - GError *err = NULL; - struct bap_bcast_pa_req *req = user_data; - struct bap_setup *setup = req->data.setup; - struct bt_bap *bt_bap = bt_bap_stream_get_session(setup->stream); - struct btd_service *btd_service = bt_bap_get_user_data(bt_bap); - struct bap_data *data = btd_service_get_user_data(btd_service); - struct sockaddr_iso_bc iso_bc_addr; - struct bt_iso_qos qos; - char *path; - int bis_index = 1; + struct bap_setup *setup = data; + struct sockaddr_iso_bc *addr = user_data; + char *path = bt_bap_stream_get_user_data(setup->stream); + int bis = 1; int s_err; const char *strbis = NULL; - DBG("PA Sync done"); - - if (setup->io) { - g_io_channel_unref(setup->io); - g_io_channel_shutdown(setup->io, TRUE, NULL); - setup->io = io; - g_io_channel_ref(setup->io); - } - - /* TODO - * We can only synchronize with a single BIS to a BIG. - * In order to have multiple BISes targeting this BIG we need to have - * all the BISes before doing bt_io_bcast_accept. - * This request comes from a transport "Acquire" call. - * For multiple BISes in the same BIG we need to either wait for all - * transports in the same BIG to be acquired or tell when to do the - * bt_io_bcast_accept by other means - */ - path = bt_bap_stream_get_user_data(setup->stream); - strbis = strstr(path, "/bis"); - if (strbis == NULL) { + if (!strbis) { DBG("bis index cannot be found"); return; } - s_err = sscanf(strbis, "/bis%d", &bis_index); + s_err = sscanf(strbis, "/bis%d", &bis); if (s_err == -1) { DBG("sscanf error"); return; } - DBG("Do BIG Sync with BIS %d", bis_index); + DBG("Do BIG Sync with BIS %d", bis); + + addr->bc_bis[addr->bc_num_bis] = bis; + addr->bc_num_bis++; +} + +static void setup_refresh_qos(void *data, void *user_data) +{ + struct bap_setup *setup = data; + + setup->qos = *bt_bap_stream_get_qos(setup->stream); +} + +static void iso_do_big_sync(GIOChannel *io, void *user_data) +{ + GError *err = NULL; + struct bap_bcast_pa_req *req = user_data; + struct queue *setups = req->data.setups; + struct bap_setup *setup = queue_peek_head(setups); + struct bap_data *data = req->bap_data; + struct sockaddr_iso_bc iso_bc_addr = {0}; + struct bt_iso_qos qos; + + DBG("PA Sync done"); + + if (req->io) { + g_io_channel_unref(req->io); + g_io_channel_shutdown(req->io, TRUE, NULL); + req->io = io; + g_io_channel_ref(req->io); + } iso_bc_addr.bc_bdaddr_type = btd_device_get_bdaddr_type(data->device); memcpy(&iso_bc_addr.bc_bdaddr, device_get_address(data->device), sizeof(bdaddr_t)); - iso_bc_addr.bc_bis[0] = bis_index; - iso_bc_addr.bc_num_bis = 1; - /* Refresh qos stored in setup */ - setup->qos = *bt_bap_stream_get_qos(setup->stream); + /* Append each linked BIS to the BIG sync request */ + queue_foreach(setups, append_setup, &iso_bc_addr); + + /* Refresh qos stored in setups */ + queue_foreach(setups, setup_refresh_qos, NULL); + /* Set the user requested QOS */ memset(&qos, 0, sizeof(qos)); qos.bcast.big = setup->qos.bcast.big; @@ -3148,10 +3198,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) static void pa_and_big_sync(struct bap_bcast_pa_req *req) { GError *err = NULL; - struct bap_setup *setup = req->data.setup; - struct bt_bap *bt_bap = bt_bap_stream_get_session(setup->stream); - struct btd_service *btd_service = bt_bap_get_user_data(bt_bap); - struct bap_data *bap_data = btd_service_get_user_data(btd_service); + struct bap_data *bap_data = req->bap_data; req->in_progress = TRUE; @@ -3166,7 +3213,7 @@ static void pa_and_big_sync(struct bap_bcast_pa_req *req) } DBG("Create PA sync with this source"); - setup->io = bt_io_listen(NULL, iso_do_big_sync, req, + req->io = bt_io_listen(NULL, iso_do_big_sync, req, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, btd_adapter_get_address(bap_data->adapter->adapter), @@ -3177,7 +3224,7 @@ static void pa_and_big_sync(struct bap_bcast_pa_req *req) BT_IO_OPT_MODE, BT_IO_MODE_ISO, BT_IO_OPT_QOS, &bap_sink_pa_qos, BT_IO_OPT_INVALID); - if (!setup->io) { + if (!req->io) { error("%s", err->message); g_error_free(err); } From patchwork Fri Oct 25 12:21:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838487 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D1DC1F9431 for ; Fri, 25 Oct 2024 12:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858955; cv=fail; b=a07Xj3IIEsTJ6UZS9gOktNp2KzMwS4wMgG8w/jG4PO+7/QdDK6Jt9jBxgb6V9of7WXRijStUhQEfgrea3qEsBmhT36Dk9iOI2L0VLnT5J/Bk24zkGDLcIJAoXKYoq/uM8mPlEcgEW16HaFFOu1wxxeeqBOFR8rG6XNorTf1acFc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858955; c=relaxed/simple; bh=k0Grb85DTW9s6DmTJ4E2hrhFh7HxL63dPPfQupsqcbg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=j4zHf6sasA7ft9ac9EPIbSgPlFhpBE9ldlHdviPPXwDtFGgwlm8Hp3ZP2yM2LDzd9+kaj3NmfpZ9/14bDrzQN9wgMmGjnAb5MHonaHcWKXd1itllj8Z/VfbQOiXGs7X/GIQUOQHodudyQothyWEy6PJYVgwWcHWyc0Cuul0HNp4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=LeEg+OHW; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="LeEg+OHW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wvMKlt2zxkbVUkCToayaO1PK+o3lrAOPMh3v+bQZQvDkqY7zFtBdBJfPvXkaQ3JTzNkLvlJd8Y4WmfTWD0kNudz4j93vdewdUea9WsySi74ApqIZ7DBv4oxYTkhO8Gx60ikxkz6GEUUxTpmv3wvSZXy2W/u8zQoVs4mGIi6AeTd2Lw1Z3+85at6DuX4B5EFEOSOXenUVAcxgZ30ho74gLOZuj9YlIt/CeU9ECmauiLhEHpWbDreaZvxArnVUmSkwDDgcp6GmKKTAWlO8kHn9Wohf4ioh2SsLgp61bMSY4i5POF9tQHE6nmZmmCFTmMyG+vFbMvR9fxLAGfTk2HIbeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QeE1jA4drqJpvzCxsPahhw1a3hwWv+XOKINVATxOngk=; b=nFJeo+71BEGce2m6Rou82MzJ+BIlB60Q1XyfghYAsYltsMwf88DFQG3KjiKbsfFy7Uw3QuHYNBNsy7ITs3YVt7tZ8j3iQNcz1XAXlJXlIYBlw4J+sMvJ7Wrv2rFx0tC9aNGSk+StCZSGFZHUtiP6QXPhL7ND8LzyQ1CZb/Hijt2w2qZczf9DqFSOlr2bBoOD8zS9plDbyIdZg9CMdKfbBiJvOUms6wBeYCQ7Z2bLtWYDXPDAF4np5/KsIAKnQSAMyqEngDjjFD61cFy076iz0367pFz+n4StK2ThJEcxf9XeuUJuH3L7E1/PNg9IytLwkdnjZ6P5UdBr/ny9pk0QAA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QeE1jA4drqJpvzCxsPahhw1a3hwWv+XOKINVATxOngk=; b=LeEg+OHWlCj47SmcB1c2lueOkQyLrq1H5H9ZfM7eRbm0Jp4cMvrESxeVkinYeN3ypnyN+pUbKGBym9kwEX3moOU9EHKmRqZi1g5Sv275klqVOAxsNZTrlYakF5rQrLkKwu7axfEPR5R9H2e1S0pc4CAQnpFj7gbFvK/pb9CwQdHxyQ05HhcP+/8/Hk349JTytDZHKO+E+kAGY5ZupTQw4pLf2oW5jqpnRsYzQS1RWBNuPpYV2fLBvpoS1MCibnU7dsYHLdJQpmlLAJviL/DJydzk6PuwWiA/Ija0RXwTXtS+cg5kAemfP2NY819vI4HilvBDnmhRWqwrwU4k0BjzkQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:25 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:25 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 06/14] shared/bap: Handle multiple bcast sink streams Date: Fri, 25 Oct 2024 15:21:38 +0300 Message-ID: <20241025122146.17925-7-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: c534aeb7-eb15-4624-dd30-08dcf4efaf1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: fLrPemtrJGZsluj8ODR2Y2Qsig8QHoJ0PVf+gOdmxOobyK1mP+1r/FXXeIF+o/K3sUBuitOY7wsAAGHoGVgeFeufSovA6vlQ2BsMqI9KZIBvinD++5a9DujGAS6f4NEUZmThF3DS8doFAduZDTOoYhMsv6JfaIl/RT4VRts0Qj0E8919Iq5D96I04FKWfLGoITX/1O/fX9H3vaQcZ89zHOxlubt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Fw8qDeNrAF4M6jRWNT0AolocFXoIZenM5DZAYr/jTb/6dCvw1WbdQQexhPdteBQOjkgZ1cI2g= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gcZMP26XjBBYH8I+DzUazkHkPhMV29B7f9CuT8QV/PvHcMVNJNwsUgS/L1x5j21E8UEnjHXuWweCpJ5jIT5xMxvTIcfgZzw5Z/ldYXLJEa/ynolYxcJDsLmDDH4PsYDN9eIRj7NLndXJZ4AUDnumy0e3ORxDtJtBUR/mYK+XGvzQh3ykBQzNubj7AXkpnjhIDAgWf2odbHTAD3nEznu2rOb92HOEBYZZgpQA/JAogguDBWwhJLsNBaxyvsU/7Uz6JnLpUHwZam4DRSjFbU8RYtVg6SSEhMAD1ky4VAyc32AkGj7GM++Tn8wS0YUan/be/T3DU5P9mZUYnt+ox9itn9D5ed+bYQkN1u4vo3emACpD7BSBdqm9pBefSIhmU/ngww56+OnGiNrykmM1pluoS6SvqMEhS0ELQZFJqkoc1qpG3h4bDPh4tPRU6/mPLeR8S6W+ZvZQmTvALXIyhlJqrDTG1oMfuDjQBcrCBQ59bPqS+U2nH+w3CPuYdJnQqS1UrvDzxTu0lobb9KTWbfiwXjAy+zf5USf2CSjxUEQsB2JDFVcaUIaIRTEnONkI+oaqJ4ae2cknr4JoVYf3yjSi3O8IX/fgaAJjDrN1vJeKqkfBSVc8xvkDpVOmEqPOi8blUbZe1zQ0Szq3MNU8ST8JIisKCaD9cSY0DQzAjGdm4ItpN0th+sH3l6qNKZKnPNVuYx3SYe/03ykEX/4X4zY4NYluH7arii6p7Bz76HLn5RY7qcwVSQTWYxaIlIBJx6M8ROQLBrBU2n27+n5NoHNy9boVz0RoTXCgqk7WACXlFJrkWE1BDWnlnMso2Xr1mN1Sgoma/Gv+FrTYYSLAUs192nkYkx5MkTc+eOi0Lw/wU3QFwBtPItPjS8UmcjrcNH/jqInf0GUS3fGILPMIXRKri96CEarnwZ1gy1LmWQ/CMsrDpBwUAgEVnmkxE9epKIUmKDFEOBLxU2Re7WfdFh8b4ewjPdHGUOJSUiBEMMS0eJxGgq7HzdhESYFX5IsykkXRYlZgvsnrfLSjbtaEREtkjMYZYmW2NvyScHyBjZAAD9fuO89jSsUmEYMtmt0szUgdRQFaVu1a3WYkWlFdErzPEUtg8ogwCwYtonm9ScTfTGJkBEJJGWA58+O9xnMr/mOQGKXMHRZrcZJNjO4XXy3PlvJUO7VL9BsyvTqdhh9Me4K0n1c5ZYWR4yB90OAwH0pKtHLp0Y2BiNej5JKWCZ593N7/lzNZiauRye9IMmzMA9Nupu6Z1Yk824HwOKkCrUV5lYNHx5oJJcvsV+EmMjqbH3jAiYh1cmK5yBMqI4x3dsIj6sNiHhnGzDCUI7O6Sm5LortiWKeJVp1hERHNusHEcRZgcslCukvxCbNyAnG9QWz3Mj8rdhZvuuo6EojnoO5nFJ+d2HEGhmjR9Ipqg/SqdnTbI/LFf6h/oGToQGA6Lfj3A0zgT9JEYcdusYlvjs1KMQO/gDq6XxwwlAuWw5mRL/GLFeULTAaYXrsZlEY9t8G2Ewu2qZArwYtlJ66V9521o1aXRgZsIhfi1l0dX7wbEBDJIZwxX9ua5xydtRSnmOvcoCPMLiMZ702XBh/QU6CdyW2G4ixxKtdTakxvSqROyg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c534aeb7-eb15-4624-dd30-08dcf4efaf1c X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:25.3977 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qqQjaRKGqb+x7E3SSZ+rKaOFPZMj5jrasBun8pxVCO28oo5W0Yjp/v3wj7R2k7kh6o7dn+T+VbKie2NbKB5jbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This adds shared/bap support for enabling and starting multiple Broadcast Sink streams. Stream enabling should fail if any other Broadcast Sink streams are in the process of enabling or have been enabled for the same source. Also, a stream that has been enabled and already has the fd set should be started on the spot. --- src/shared/bap.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/shared/bap.c b/src/shared/bap.c index b314b4b99..dad510aec 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -2195,6 +2195,12 @@ static void bap_bcast_set_state(struct bt_bap_stream *stream, uint8_t state) bap_stream_io_detach(stream); stream_set_state(stream, BT_BAP_STREAM_STATE_IDLE); break; + case BT_ASCS_ASE_STATE_ENABLING: + if (bt_bap_stream_get_io(stream)) + /* Start stream if fd has already been set */ + bt_bap_stream_start(stream, NULL, NULL); + + break; } bt_bap_stream_unref(stream); @@ -2205,11 +2211,40 @@ static unsigned int bap_bcast_get_state(struct bt_bap_stream *stream) return stream->state; } +static bool bcast_sink_stream_enabled(const void *data, const void *match_data) +{ + struct bt_bap_stream *stream = (struct bt_bap_stream *)data; + struct bt_bap_stream *match = (struct bt_bap_stream *)match_data; + uint8_t state = bt_bap_stream_get_state(stream); + + if (stream == match) + return false; + + if (queue_find(stream->links, NULL, match)) + return false; + + /* Ignore streams that are not Broadcast Sink */ + if (bt_bap_pac_get_type(stream->lpac) != BT_BAP_BCAST_SINK) + return false; + + return ((state == BT_BAP_STREAM_STATE_ENABLING) || + bt_bap_stream_get_io(stream)); +} + static unsigned int bap_bcast_sink_enable(struct bt_bap_stream *stream, bool enable_links, struct iovec *data, bt_bap_stream_func_t func, void *user_data) { + struct bt_bap *bap = stream->bap; + + /* The stream cannot be enabled if there is any other + * unlinked stream for the same source that is in the + * process of enabling or that has already been started. + */ + if (queue_find(bap->streams, bcast_sink_stream_enabled, stream)) + return 0; + stream_set_state(stream, BT_BAP_STREAM_STATE_ENABLING); return 1; From patchwork Fri Oct 25 12:21:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838486 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2083.outbound.protection.outlook.com [40.107.247.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87CD61F9431 for ; Fri, 25 Oct 2024 12:22:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858958; cv=fail; b=d8ho0EXDkjLmTJngseFpt57rFvxwy6pojrN7ruzdpTa/l9YvbdQfyN0Ewvbv8MCJMrFCA3GNCsCFI+TYDIHtK6R/RaR4537pDtNfUOoICO08sVJRIAh05f23bXF3h1tllXFzLwJSzt8fBK3pMyMvSkgSTzfBx1PGU4ym/5ZnAhw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858958; c=relaxed/simple; bh=RBkN4v8HbOrapJSD7ZWet5Tdlo6IkOvkm2+1rTmxx1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Uz7OrHolCPtN/Iv7nvsZH1EcLhDXUR7BGWC6q7CpPjPfV98sJk+U+I9apefKJ+C1GN4kmM4ifOWeGqh221g7za88k0G5Xvzvwty41CVbdDR3px1Bmy4OYsW/lfx9R0ziHQuZC8ApWH8jiYaCVcuU9wIeI8ymvbXvmF694CxtTo0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=U9IXOfsU; arc=fail smtp.client-ip=40.107.247.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="U9IXOfsU" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l3wBftEUpuQgqEwp6gEXHTUlbxvncxT9Ns/2a9BDhNhZVR2AbdmKVsHeqTR7i2E6rLNGlbcm/234h0CDe1bs9o5C41TGBNCDpwnxKacNN9fMGGjr1Iv6+GIwGVPYiSk0zg6AEJTzeI5ukCANyZVwOBxPjtkUsyz+7+5FNPx7oU25AkDSA2fAAziW4iKYKFkurTwvgosgNGaTwXHll8SH1QRL3QhESn75IZAJS2V2Cq/hpZdgqxXFsJ/zjzqHBNGr68JrF/9SnqykQQ6PQWNUqCcSo2VAkF+8fgYgLCJteAybCdK6C7ub+had9qzst1dfxT0IcGpzFGcTRKWfwI5s1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HW2MlkTctZWRz39nmD/nTbjenO9cNqJ5OKsAgyabizQ=; b=IpQ+a7FTxwXEmDk8ydX4w5SATTllnNa8ND3u0jOE4m6eGYD3dfSUL29E0udLaVdyykezgFUSd9Al3sjZzKYHic54hIlr3sqIYXXba9UrbjQK1RVqDeywNjneKOlM+3YikUF2uW5QN8ghlVWfnECk4jdAaLifdNy+1DnYNW3mE8f4YMwPeE9rOoej6Fk4bv+PmA2AvDktV6Fs/Z01eysmk1CS04H/RMVsI7mknHuELW9XpugyUErux14BSryJ6ec258dWxkayVTlcVWPLIpXvWP7rrglloW6EMEHC8BV1dFseOpQcm0V/f0IExBJlpTvNXZsHrQFYa6kqdp1yU+GbJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HW2MlkTctZWRz39nmD/nTbjenO9cNqJ5OKsAgyabizQ=; b=U9IXOfsU94yKzK2S8p0NNsmwE1po5/PXFMhWth9T+bZoATBHDOD/v43lBD820JRivbZ39+GqJeXMNWkylLSNaArUjwholuuA1tLDQRst9virTSvfCVV7HyXh/OvJkUI2YSWh9jvz5JcRv5L/xhsirTlmezQXNLYc4HT7MF7VCmGJuqpQcgXm+m6vj9uPY4JDofcTKYca3/rUshMOYm1bpjUjS0wevxhVbA0y+yNhVW4OqQt8fWaKmpBA9q0aiKqr2Z8YrZnVJJ6G05aTDniQMW0SuV0tL+AUOQ3JZu+IxY825dt2MBbkPmgeVvkiDfAm5+xGzF6cctOxOtlETsz2Tw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:27 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:27 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 07/14] transport: Unset transport owner before owner free Date: Fri, 25 Oct 2024 15:21:39 +0300 Message-ID: <20241025122146.17925-8-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: 31c344a5-6411-48af-38e6-08dcf4efb05a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: n0hoItHEVn6qfQutj9ZA9WjPmKRcwkgKCwswLd+4karkRBB96muwz8ndhCE29d+B/s8fysl6W9D0cyYvfWtVlKTJVxt209sCTX9S2Dz+jsV/ijKtL3TD8xkcjJR1HcI4YxyVUQMfpdy1CLFjdAb1+iKOo05SLyjMZJPW3/EwMgB8pwNYoAGY4LBF68qOY450buE0lagpMDOVyOyih2lvXwVdhg0ckTKT9vrv3RnRVRrldw96A9aaEc2FL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Q96UaSnGeDue0HPjGEIL5t6b35ksTuxZ1whi23eLvnZL399OGS6Dx8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: puc0i1bTS1kkzTKgMr7hTcuo50sbG2N6P+T70KTfSVifjzMT8jU2pOLFWKq/Io9neV81q84nFqw66lVhJbVnqZpFFjkR1agOkcZwJxG5N4LHyvvVUth1LjjGKb/y/995grXza0Rpq7m4q2cSs0eKo6XtjWeKJ1tIiIXfLHeAmTcwwUghUGztH0xDKIVUmTiap63DB7Df7UZrbiZ4WpMV4VRq0EBgW6teF0lvLmllL+Xbh6yPmdVFU8lEDK7Aa0CF8cDTDkQ7NoJ4By94nBrrvuo9UirYfhPFtlZB5h6/P4I6eiI09XQtt9mAedTS9DqPwhLIAXIGf2FBl4jEldAEroWVXH07C1pk+oChnUcHbSXAqJtwGn11MYuxWfX/ineOkmSv3vHHF2wxuPsCsh4RStkvHK93qvnTGd32vy2wQZpeAktKv1/qaSKLrhDL1fCozc7cxSa9mPIgQeobstdO9JYu0sY1n5PSaLgyfQ36yEymkuVkz1jYe7RwUxBnV8QlNiW+n5/P5Q69xONBAAD8qN2eC7zCcrqoAfdvz1NwPlIqZyx9BrGjNP6DfvNbwKheUex3QGp254tOlXCqZ5Z4+DcPeY2YHKjeCya2bs6fr0SXiEn+sVCOMw6PlwODKhFC4dWgVHwnesB/lo3N8lDJvPJLpDVd0yN6MXo7IbHst4MRqbYxa9E6+f1GkHo3B1k23EK1ygOXlImlHn/bHpxw00exBGwKnjp5cR7xihiI1UuUL0nnsZnaeqG/VDoKpFQxZQaiUhyX71X2iWU4ykOtlDPgB3jnNCh94eQFFPcsw4l5MByhnPWP3Dk/E8AbzxMU7ryzelxEFVrVzcAo0X5vmhoY0ITHyroMlvGHyqRZEgmJ4cXAl1D0IZN+i+kDX/mzP6fzpqfE+KC6XKH5MIYBDzxN2Ki3uS5oEaRk644dKeMPBLqWfJHXk4jwcuarzAp6LfNYIYK2sshL+8uvCC7IWZ/uVVELm9kL8BQlNIHCYH/PCYMlMhrnI2d2hYtX6r8Pu9jmFMoQgZpRQ66UqT6tBLsucMJHYfrspuP4VscunsCPpZwfwK5ZiipbZmTGmxQkz8XFayG8nIUs8rPqbX4fYNvl4DLl6y+5EKWp+7lnL9Fj/v9x9nwFT04Y9i1OXiHEpeAwGTqQFmbD6ycIDin9OIxXdK2kd8cqsF5HJHXSFe/3d55cOOadu4omxOdYiXSE/FJbKAAM3D13xaDtZm4obql5JaBj1cyFt7zkZu4Xh1wFcBLIhvEKQf0aaGoEHqOu54eGESbobUGhVdjmwjVFUBZ0FwkDAZt3o95tRa7JszNT1Rrtea1wION9V8oBFvnLhYadk1OXOtwUTQO1MY8dQbVqwfWch3HiHfQPZM7mVeNwCe97vJY+JMZzzOox8ksJQzS64Nu+iaR9di+qOcNp7gC7vcU62Wu6LdIp2SleoYgDHm5y4KTEIJ2TX0jGuDTGnlkxFbXFjGTtA3cUF86OHUAbUsKP8dpxAFVdu819Z2/AwpT9/T11LWIwvwskzNeEnqmKUl2RgrQtSdOXT7auoIMc6zO6fkEqck2sbxD0obCGm0E8lsUP6uGO0rP4Rh95wCdfFLP0kMRXIfvaFBsJWA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31c344a5-6411-48af-38e6-08dcf4efb05a X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:27.3919 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: chJIzLXWSMI0Lrq4Zoaf3w0qe/hux8KvflNogKbmw8j+4MulzaRDgVVeo768gjB3BR2DpG1cNbbg713AAGTIcg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This sets the transport owner back to NULL, before the owner object is freed. --- profiles/audio/transport.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index d71013077..dafd1c471 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -287,10 +287,15 @@ static void media_owner_remove(struct media_owner *owner) static void media_owner_free(struct media_owner *owner) { + struct media_transport *transport = owner->transport; + DBG("Owner %s", owner->name); media_owner_remove(owner); + if (transport) + transport->owner = NULL; + g_free(owner->name); g_free(owner); } From patchwork Fri Oct 25 12:21:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838804 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA7DC1F80DB for ; Fri, 25 Oct 2024 12:22:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858958; cv=fail; b=J0j3ain2Mg26ZCpwEJHyGcX/YKRSfvL41gBxl1VAs3YowNWpfR41jehqg4vj39Z+T9r1S9+Ifj8qpi22/Zo1RzUaQkwvEL3qxEpF2E7t69Vxv8RXzCLx8l+hqtUnHq0BNdsQGDByS/zfO6mKTPEFqJK2tKW3C3FkBniQFqsI3RM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858958; c=relaxed/simple; bh=ZFFXxRCSf9Jx4GbQa2m//6EfaqXcj+5DDEi+eCi7Slo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=lKjEGetfOBuxhangKC8G9Vo8GdOQNDrvEJROuAceWt3yDcD8lM1lN+uZwwzDJGtqsFAmTlcYT7TeoLASesVJqbg0GMVDei/ZNMsW8fAKpkIH2a/LMISDGBWq6u044etMj0rNsm/oMxg1m2R6TokfqPzaGECTw6M7SzD/A9uNCJw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=H0USWKtJ; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="H0USWKtJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j5Gb6sjCgztQZ/Fh77uM9jbz3TN4zZKBN7W4ogCKfv7zDNeR4Mj9IniqA9W3PsJiMhIUI6DdHdlO+VEq7zzqkxktA5IXeG2CADycQBgEL0tZb5ZsKu8Q79OeYgCk060yKdTf2nSsG6ljMZvGdahZmKsjNZ60suOLSL5h7Ge/8t9R4Q5mnT+nDvI6/NbGJ46FWMXlaH3yyHdqZSXvPuUPpRl7bqgRqB/6H3nhAAOR+vDMln/6BH2O50bofqBSUmySTyg/ifpYW1mQUuJ0k4NYBy7IvTvHN5An5Fcv+vnQT16pJYfJUdqoSTFj98ATWJYiBWe2s4vG/Y3GkPhEOnYx1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E/70KQ7Y2mqGgTXupXPGpsWqexp8myFutK+mNYzAWdU=; b=fkOoDmfp/YPD/5r/YLZ6vjasYVs24esz0ycEluEns0hG8WxBPaZZcovrFaGBZQMjHO1SNJatOt9NM8h133Q0n3z5NjrM2ljCNWrClR2VrNgoGKPtJy0kNCOWqXouyepOtFg/azU5PpyWCgZPLBAnCxxiNLG+9DGte3SJj5va++euP6qChS1GkQg4eP8o9xrbZ1dhpeJU3n1HwZaHVFipLUtMnxa39qhk+IICarA0Ya2HJNoJ9se4OVWmfz1UoVPIZvFMiGHQZ3NdoGzrpX30MN8vZnveHFUpI/umJI0stGLvXH5l/2g+C/c8OOwVxvMBa4B13Y51xSG20llrvdxBgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E/70KQ7Y2mqGgTXupXPGpsWqexp8myFutK+mNYzAWdU=; b=H0USWKtJjdySc7W5c4V1i7LucXK7V24+tojCEktnicgIN+zFBXGfy4nqMDheF3vMeddQAgFYfxaBWVFrqq9Fi7XUZIg91WNTAtyDT1EeHrcaZbAE7GQR5C5SPRLlIrWfTRVQDHqaiAjdqcL6YuoyyqSUkr0nqAucDfNYsyyCDy1z5gXVDuQGmHrrXGf6xreR61mJUoEpO1SyntDS7fJSMvl64+OC8vghOZMUg9iCjqKmtSdTa/PgjvtjTjISQAG7Oi7tJpJQfgz5osRwSXY2XjQ+rPRBQaOTiLTXdeoxkVANyD1n/6QRknPPynCh9QcZD3g+hCJvSGi670ZHgpDecw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:28 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:28 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 08/14] transport: Add Links property for broadcast transports Date: Fri, 25 Oct 2024 15:21:40 +0300 Message-ID: <20241025122146.17925-9-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: 61b96eff-ea75-4bdf-ada4-08dcf4efb123 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: qjTGMfVBVkLDjiLgbFOPmBDtkabalivQT4toZcd4HmYESwhRokIEsDDCsaTxq8cSWEKdspWOOYDB83YGEkMF7tAC/TXFLmQETT8eeW2cfRfKnzII4IdCo0S7HVH6NmNCGi3r3d4sAI4rfpAcFWLSMDuTVZdIKH2/L+1K3ICXzRLOJwEhIOIQ8q5Pxl7fqGO23bioDa826ogquHmJN6XY4qT8m03BcYw2ZRmDa6yBNf1K1HW9CJzF8ebYOpJNHhdW/v73I6atucZk3S9yxAXJx91NuCYilsOARM29iM3TyiaNrqOmlpYqJHHFuUyTVO8YLgdS/HhLB3UQsj97C6rWUi4756gYzxB5Bx7TgmwfJ7nf6XmzYxpRr9gKdcGSrP2PLKcqyGRgNNHfF0ICfZfXrsFPOsuWHGI3I9cR11f3v6rcwBmxQdFivFdCpdrnD4Be+ZFJkV72Y+0J8i5BIKzb1zFdLnKW/B+TiGkkgCMwJrT8x2pWyevd2RCPlMV2ICNEeg231H14v9KWnZ6mZ/optia0pCIiZ6q+QTiQSaUi05yXRXSJxAC0+naFL0DhJxV9vLIsvzGFPCd54r2TAB2RwDL5a6QExGBsHJ5YcmffiUr0b01SH0HnE6ejKV2J5S0suYLagftWnBoLLTmlfsfqKM2VQAXWCsebtLuicPKxZb1oc0l+rq9AaGe2Cp2hCCQ9ZJaf9Dg45V9XN1dEw90h3CwOz1jr0JpOWsWtszw9Hi/OxZN2E22bCKi8gztg0z0hbNIoHP20EedVRkMtrADvCPKLpsiwgM+E1dtYFb2BKu5pEBZw4SfnETwLizsnUVvOPOCoL/aGx6//CHSRZCBHGrWWxmkTAjvbxPl0IivNbBEPH3MHKKSidrvdpToVo2LIGxcy1XMJV0ktJKhNYMvmoIu5aAfr+heySvWCR+HNjE4oZiSUbK4arolHzY+OZ9M2Q69RPdnKBFQFYTa4nKaPEnL/myJrDeov4IvNdXM4xs6R1Gy2f9WlH8XT/EcRD8O/+3akXidbZxwrYSGbIgX/eMfUhDM8m91/EwIY24k5xZg7y6OI2w6G9Ih3bnTxtpHEXHL5ylmT2G6xOHYyWAUtemjjkcZCVEy1DM1qLWfwUh7E3R4TcJFqaz1Isrrj0QMxMoxt1AjrwX4DmJaxrC9ObrB/V2/ioZ/N7lZfbVfSaribB4sX7rckWXTUGVAsDY4twIe9MxcOVeXnU/EIPSdL3eIxkm5q3nnMBw2dXaTOH4w+fx2BVoudd5HP9ckkloSgAoIrzmBiLrRPFNG3KYgGJXn7WadSvy0huMiSELvZtDCAaMeZrJSo02SMVquuxZ9zkPbVs2ZJ0cjlAl9MC5FrJ9A+Q6GixMYlqc986M8nlGQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NSO71gRPQP6+uLQvb8GNegQw7vV04OhcTqFXnkqxeWQ69y20KRvg2TTA01yPifZv1relQAQWvrrva5oWnSur2MGOGIt15dz9JJcCox7CCb/IEUNcNh7y6+OOv6ZF/bDLRk7J5wSGHfOvo8+PB96LrRoXOeu+5SqOekZS0k89b31turzs9pK3yQmO+qRy1CpVZvo7Re8U7Dih4Ezc/FnC6YJ+PJGJFFDir4f9gw+5QqX4IbJ/AJLHVXBJEWrq2ZAw3YYMexAHbvnll3nL/J9KrFAOhP7pM5AlUWeTibgGIZ2/fXNcigyTdqEii3IQzDBo/BGTqT3Dc77FDt2PdqMVHV5a91jEmlicVCMfG2e0oabxfYe2A/AmF6Ou23jp9bCuxH/u/8JAuxYbwflpu+Js5MWKKRP44+SHTqcamE2oTxwZwkHGQ3SuNNI0Z1k4xgs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vQgakTFBTlKRTma8i3prtQUPOqxwi7J+ANnXLpoQOo39cAXmPbBj7AeXB27poThr8LOVFw/7WQoLu4XPePe5rTXVY4JKQL7tQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61b96eff-ea75-4bdf-ada4-08dcf4efb123 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:28.7341 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VjXZG8vLxi5Iyur3aZP15qNAii0QK/vLngn0JGI3GSPJ1PQmtbbOFphVVSDjDrfaYZAXqZRUqJXGIfGjdJgmUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This adds the "Links" property for broadcast transports, which allows upper layer applications to write and link transports together. --- profiles/audio/transport.c | 62 +++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index dafd1c471..b3bcbaa19 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -183,7 +183,8 @@ find_transport_by_bap_stream(const struct bt_bap_stream *stream) struct bap_transport *bap; if (strcasecmp(uuid, PAC_SINK_UUID) && - strcasecmp(uuid, PAC_SOURCE_UUID)) + strcasecmp(uuid, PAC_SOURCE_UUID) && + strcasecmp(uuid, BAA_SERVICE_UUID)) continue; bap = transport->data; @@ -1142,6 +1143,64 @@ static gboolean get_links(const GDBusPropertyTable *property, return TRUE; } +static struct media_transport *find_transport_by_path(const char *path) +{ + GSList *l; + + for (l = transports; l; l = g_slist_next(l)) { + struct media_transport *transport = l->data; + + if (g_str_equal(path, transport->path)) + return transport; + } + + return NULL; +} + +static void set_links(const GDBusPropertyTable *property, + DBusMessageIter *iter, + GDBusPendingPropertySet id, void *user_data) +{ + struct media_transport *transport = user_data; + struct bap_transport *bap = transport->data; + DBusMessageIter array; + + if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) { + g_dbus_pending_property_error(id, + ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); + return; + } + + dbus_message_iter_recurse(iter, &array); + + while (dbus_message_iter_get_arg_type(&array) == + DBUS_TYPE_OBJECT_PATH) { + struct media_transport *link; + struct bap_transport *bap_link; + const char *path; + + dbus_message_iter_get_basic(&array, &path); + + link = find_transport_by_path(path); + if (!link) { + g_dbus_pending_property_error(id, + ERROR_INTERFACE ".InvalidArguments", + "Invalid arguments in method call"); + return; + } + + bap_link = link->data; + + /* Link stream */ + bt_bap_stream_io_link(bap->stream, bap_link->stream); + + dbus_message_iter_next(&array); + } + + g_dbus_pending_property_success(id); +} + static gboolean qos_ucast_exists(const GDBusPropertyTable *property, void *data) { struct media_transport *transport = data; @@ -1295,6 +1354,7 @@ static const GDBusPropertyTable transport_bap_bc_properties[] = { { "Endpoint", "o", get_endpoint, NULL, endpoint_exists }, { "Location", "u", get_location }, { "Metadata", "ay", get_metadata }, + { "Links", "ao", get_links, set_links, NULL }, { } }; From patchwork Fri Oct 25 12:21:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838803 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58F802010EA for ; Fri, 25 Oct 2024 12:22:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858960; cv=fail; b=auPD7cED93RVgOcZGuGJF6Q+s96tksm2m8roMiy2Y0Su8U4TZkABInzf8RZtSZAs0wbsOaT5az13az0Bk00Eqdfc7edLmpsRx/GQK2KdnOlVqTPMVmhmzeevKlbwYIKO/dKDtdWbXs4TsILJ3Ny1m793mL9EVNcy8baBS6rlHBo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858960; c=relaxed/simple; bh=JGUqzxPfsYUr9BVao+ZnnBylRBbvw/737OpD0MrOp9o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=e5Zz1ViDwPICDrcBqVR44Ttcei26JMtjKOxwEiHM1byFhJiSQY5XN9cgsrWZumVNEP6Z6KfZIKqD4OG11HLLIwPm46ekw+KWhBPFFnzT0oXsyjJHE93eHYLrEV57xtDZiHMz0LXcCR8YQ7SlL3EWYlNaPZ85gN0YejIRB9QTuAc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=JvlozHbg; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="JvlozHbg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q0U+9a492ODGwoZ8swe1oAd5FfhbWY9q51/iUpeQMvyTWCqiLO71DG44+EogIQL3ihj+IFeCr2wmhqTylP/s6NXFhuqxT7xHt4IfQV8Kqv8t29skkm5LV8goEJ7DSvsWe3Iere2+FGbl2e43b0jDah7lKPWpF7k3DA6ImE0kVEY56rC6Fe9sfIDBNOJzvD4WsJOmuDmeNwg8AwOo/a+cqRU0dSpwgLijcdn0lDCKQAttW6spGhuo69An5mtA4cmhPWui6dkfK5slZM/IF8BXzO03+0l2EMjk1aOkaYWv0i28R8nNggmT5+nyMTLLL+8dj9Txq2aigWK/d/2O9SZmPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EG0JfFcPMjt3WfSlLtm8E/r4ZqzeMtHRX3RPWtzPRnY=; b=oVoiIvP44pHgTWmbtWbXDhO4PvtSizQalSiRZ78zEUd7d1KLg+NZOl81Fh8B5L0Xr5qrh4fh5mBHupwQwojOpHhZtgK5tL9Gv8bT4hQCSyQN/ktyeJNGfR2RIP/d1o1u/fxATal44IzWlAsdTuLWMNe+47JIW3ctpP/ijN4BJcetsoa1vV7f86YolxKXwbIkj5ZMlrrQSyJuRzhDjVAPGnOnJ1MjE9CSuHAv6ehSbu2CtWvIJp2p+0jYT9uuiwr8srSK/qAVscDnFa1cKwgGx4NCT43pUym76/K/9YNuhiEyAn874ioU5vFjnAdn0hrmAW8XIUE+xI3ual8OhooFzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EG0JfFcPMjt3WfSlLtm8E/r4ZqzeMtHRX3RPWtzPRnY=; b=JvlozHbgaJp39zo9Wp/kR14Gm+8Q4zxoaXMONt6MS9BLy/s3lVWv2+umCseDayJVzRL7/vJUHUIfkdfdkW9IRm5ejRRuIjc7sGRSqRhCxZPEAfvmntuEjF/cjmBfviuQovgz0ZEohbbqQV+A1jcf5DpJzhvOpPzViLRJ+xi+cUHQrWQl4LBeKEG4tapWZgEWDxWAJIRKFAlcmENrp0yKFpFO5Na+GGzq8kAMekLRjUwobHYeGSUiZd1FIL1A9gIiBSCMimFCXAuum0VLzUnG2WpMf1P172O68WFOA3tyQLS4Idh+j79ohEgVCXg2VpiadmQyGoEzUoXDe6VMWJymPw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:30 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:30 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 09/14] doc/media: Document Links property for broadcast Date: Fri, 25 Oct 2024 15:21:41 +0300 Message-ID: <20241025122146.17925-10-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: ed22403d-cbc4-4ac2-14b0-08dcf4efb239 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: L5aygQdI2IoOffQfDb6SKZgofhUWg37ZTEpNnZfKuksifuw+Iu5Gz7RzOdVlj/5sXrsvYAPkC9xOc3UWhACGYOp7ugn0FquaCBgavn3/fLg0YtAaUz77L2usobpV8fQXmYdCv2wYyCmI0zluTij2LMqVGZn6T3f7PjSPZ2jRQ/ayBNJAPmoKR3iVo6gggDh4dDDMpPLNtLpGSmUcwGh7EXenQ9xLjbH8iVL4yalAR3N9SyJ8NnE3xgzhcSU+k1OEKO7k225pkJRPqa4TZtsXrA9Q7ZdDD7/Bd+iIlHJ4XYUcTfgG7QIH3rJ1Rc9PZm4+3ry/QURlrYxsp1oeHuaJfNFMjei64XZtKDJ76QniJj7+1k3XbhQnUkUJQZnGnuzrNt2b0JT3ZWFznqrNdChuJA6gecp77P9MPKimxA3pk1FtfjfzlyRI2gtzfIQ+i1Mz5sD4hdzc2iXtCW6x/akUWiELaPkS4HP6kBNYI5dFAfsK3v6OYqQn22z0fNLDd7PhcJ2YYRWI4DKejrP/Rn45g6Z1A7Ypv9+5qgPlhRmwVq9M5XTGBoEooontk8lcCH3b9ly0bsIyUrxUwhhjplfkcyG+tvqEtLU8PfbE1+QDPjUoGLyrEfgaYuvdcDdzUkCT+pc8YUgC9lvtdLlz//oj8TO3xGt+1zwhKHp6MHmELy8zktKpX4Pch/00khyO6eAgV+pzanDP+IVPLv73jLUey1hH01YgPj7lInjtB+MsePmAR4Iqfr1FJ7Td93iF3JSt+0zeZOLMZLumOJHBlm+HVZnvehcc51bDKia3RzhRvIZUinUeAaON/yof+Ytwdo6y/R9+BL5JAR4yXVUeTmislEUh00BZC59j4VMfNbDBKyHc9yk0lOycDFs5YslnmItZqi+gwCV7UzGyd6qfP5lTJzIBc/67xa4oPhn9qyyS+w2uNcJuJoPlb386tWzgowXktheJhony0NrsjY50o7yp/pBKMlwOlkQKYhdAfxl1tZFOLzy2obWRakRQyOFK2W5TjhHWRYy5CbTaHf9eL9Awu0Mhd/z8rdwlCLnnt3yGew1DRLhK6WPvFrXfOVynGX/HPbU3C/qL/0GS32V5cQmgoPEOVE5saYQUMUDthJXNoFrkXrY7phDx86//GPw9cJSGKgzDm6O9Tek+QHOwDb+9W8D6tVjS/xEFm+5Jn7+CetB3Rd2HvHQubtUES7H5ZestHARbjooLUtcwOsTA7wF3BmkLf4eGwfqY4vt1QGa+3kE1B5oOjI79KsD89HgCCtQOSocjDXPQz6k2t3Dgiwsro+hw3JxwRSx4+2cqgRJ+i1dnv5+I81d4mglebnBGvdmBtkD2hdOnsHbP1tlqqw53kdMtEKac6JU1hAXBuMzp8vo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jux2qclDwYaIk4BXCBpBwdTvxD6bOPELI2wBECuvWL82msTP0hBDdrcnzzP+LFmPOkmRYPURBFGtgEjlGkqrQsPXbhMnObbzPiJOhbji6p+bl6m0aQRDlOF5GCb9gDE3sxjDd/xN/fS5DwgOTBm8Ty1a6Gn+rKlzvLXYBhHtGgEtkOY1RUbpaMdz+U0rXE6GIsP2OWrFni96fx4/nd48KpKh5OKLKoBakB+asLoARRVYo2Gh7D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J/ilscnaNti2boHDwXCBpwK6S29UrM1Z+50Ayz0I6NLnQvXpc1vqP3Eh8Gsvyiu0iMOKYRzbzsVkXwgRkC1SfbfC/fkkyaH9neISeCnjNrQYQ/3jbm+uFxgZxa6Zfr0kwtmMM6y3aQHCgdI6wRdOVHASOVcVam68MTOTePZwhI879MIBiFmovWNqF88/wEIEvEFIXX6N0cfgrd5KwhLgmD8b4ZdbRJFpjDVok22HHvfesdPTG/Mtt6U//t2aEFaOlY2f1uOCoZQg0fKlYx/uCtMvaBERwnU/EhNuFRPqgawqNQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed22403d-cbc4-4ac2-14b0-08dcf4efb239 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:30.5026 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: O2BPisKo5HwNGlPYfj5Oema6OWBB1D3U04GPp7Dp7m6UWo4HXpvn8dIrTBOIBgGWdjaixkhMcFrUKceQppS7RQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This adds the "Links" property for broadcast. --- doc/org.bluez.MediaTransport.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/org.bluez.MediaTransport.rst b/doc/org.bluez.MediaTransport.rst index 4d998b2a8..4838d69d0 100644 --- a/doc/org.bluez.MediaTransport.rst +++ b/doc/org.bluez.MediaTransport.rst @@ -144,11 +144,26 @@ array{byte} Metadata [readwrite, ISO Only, experimental] Indicates transport Metadata. -array{object} Links [readonly, optional, ISO only, experimental] +array{object} Links [readonly, optional, CIS only, experimental] ```````````````````````````````````````````````````````````````` Linked transport objects which the transport is associated with. +array{object} Links [readwrite, BIS only, experimental] +``````````````````````````````````````````````````````` + + For a Broadcast Sink, the BIG sync procedure requires all + desired streams to be enumerated from the start and it cannot + be later reconfigured by adding or removing BISes. To avoid + terminating and recreating the BIG sync everytime a new + transport is selected for acquire, all transports selected via + Transport.Select need to be linked together. When the first + transport is acquired via Transport.Acquire, all links are + included in the BIG sync command. An acquired transport will + create and set fds for all its links. Then, each link needs + to be acquired separately, to get the fd and start receiving + audio. + dict QoS [readwrite, optional, ISO only, experimental] `````````````````````````````````````````````````````` From patchwork Fri Oct 25 12:21:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838485 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2083.outbound.protection.outlook.com [40.107.247.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 001EA20263B for ; Fri, 25 Oct 2024 12:22:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858961; cv=fail; b=T5ugUuePgwgoPGIXEicHKdCJ90YVO7zq4Dg7OoZ2jtUYmTbeJMtkkeL/UYIqdSNMF0+kDVz6baGzjoiPUJMnTKWyHXWJ4X0XhfU5IJ+1mDauhdP63oMvV/qbqlD+FBs1Cv9ShAOyKScj08C7Neu92ZQS25U5e/ygoTo64o+XCCQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858961; c=relaxed/simple; bh=DBjw1HuhG9Hc1TTXpFthYCiqbR6nNuTPlts6WlPno80=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=BOf2xCV1aaz5VqlYxR5w2tOUEAklDrOxfNKakuvY/+fa+Y9N564ZF0yN40Z2RldrwGle/cEmBfOjGzlTLY1JGb69mhbnWf3yjiUrYkEIa60wZtQNusw2znV2NNWY4XXPAQfKUPyy3lPSJ0U48qYHVKsi9xT/dT+PuV2hOAj7Pdc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=QGPA03EC; arc=fail smtp.client-ip=40.107.247.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="QGPA03EC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sQ9WuSFxuAjG3zO/mqWrZxdyxldnHzdR1S8x+6aAqz+KlJZOccuHN5JPfMoqxWVsh/B5Rh+yyVejCXacOn6cIp2LJ4GybpqeR+HGaw6Qi2BhZuOAUtZtaxdZ29/+F8p0Q0vi0Z5YGaMaGTOXme4k77hI9L03GNQQcy8yf7kCJ1WYKUYSHgAzMRkC7LocY7xLaUCfasUxdXI2Hm9WibS5Fm70u/ZSDzh9mpCz9Hg19tFR16upfcCe6q5ZT9Wl2TL+VfH2hiuXODhRHmOT3jTqOTfstfVH/kbJefj34ZH2k3x13E2Aig+vAqIqifXwV/v8HKkOd9wpxaPCBv59983chw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kwWf7rVpAhkvNGcoWH8mWav+kcSOW7QebguyLx4xXQE=; b=hcepwA8cwNjYOGI/W6cbx06BpwrN0/ziIeeH5d3kyHYRIjGRYbV3vTjOWdQCB2p+OiWmtKHLl3tWA9iyEx6zjIsHJWD1jlmaGne/M+UvuOByPs8mTuoCQDryOj3xUKpntu1mtLUZ6HSkWFnypy6wf9buZgLz3crgc4/0mosfKviOfRDVC9E5bRqV/Dur08oybvMFhx0+WNCEYYkvq5PwrUawmxjYt26T1Zl2nodfaTIz+eAoWEZWZNhYmYnlu7XTpXTrFMCZiDeDfZL5PxyE3b+j7b4w7Gi/2OxdHsSDzuY3TmlFpFsWIykwqbN854131J24vXvecS+7LGvbris6Fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kwWf7rVpAhkvNGcoWH8mWav+kcSOW7QebguyLx4xXQE=; b=QGPA03ECiUKFkEXnGotwmGnH4J32Q0kouoQUHlHzOTQhCMmLSKo4j3QXZkrrG1h0Tiyhf65SEHFkzFr2SX7UG8LoEcz5jSICUeXrOSqxKJ6ti4cYqt/a6+uNarLXhvaJUCnGFJTv0I8bMcZSUkJaNN10nfM98ohmWVZfW3X2hM+v8BjHKo8NQPRToPHRCTxSmksNKEfG+eCHN90qsZRWVzfzPfxtGTUqUc/9rfc0G+1JAcwLGGTvPQ1KsF0xeBghvCZgGQxWitz/NE2t5qqFiiRclvINNyA8TMPook3xnAMWobE5dkeHdJPNz93jSSTMl2tR+eiKnPkVZxeEq+A7UA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:32 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:31 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 10/14] transport: Set bap_update_links as transport op Date: Fri, 25 Oct 2024 15:21:42 +0300 Message-ID: <20241025122146.17925-11-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: 57217cc0-ca19-44c4-d0a4-08dcf4efb30e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: qZUiFMmDCRWnxQaR3gG/j6Jj/HyUN7BjIeMA0wsNtpDe1fHPG0SKftoRMWPJPor4e9e+H8qTIYF03OUUFdoIW0P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frD4otvG33rtZMoksY4SBnKsJtC7I3/iZSxiAsMUoOr1aG8UnyGbxPmdE3qYfRjtdIo7JYFQifmUT/2UHie6skN+Xw+IyvFQS9QcO9fyWRmZ6v/3vb0KrDWjkfxXxzUa6ZroiJRVGqt5RZtP8YV6IjqOW866Y8+KvH4x3GqS1gfL+v7Bzj0OuiWQQq21+9pJNSPdqyYfG1IQL01q15rXzJic= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x8RiH6+LXChgontwqEOYpEp4Q/+gpR3r9wUqHG9ZMWNP1D9TTwvcaAR2wtVh7SaKYr4S2+gRs89rJG/z9EuatvUnORXH1TQGEHfxfcR6ZUNIsELaPIR2OULX5ViLo8My/JX1yrrhDil3kYUFbIavE50vWH7q9ceTMFDkfeRbiFEFoSpemYNED4qNs3FYXeV/bZRV4FG2oZLAQiyep4JpzP1JtM39o2/FfMLUnIjlPbq83/2xCtNUnuGFpcbIn7O1eB/8MHVqG/RsPxc2B4fT6yTUqa16lSc/y08UlZHLKAPjTxY+OdjHw+bWQ6IWjPQEvjnJ1+JtjTqc6YFZxyw24gPvWqz7sPBrOsvUtQrQ6yfB38RTyTXXrdjCRje77Qa3rcAmgV5SSuj4SRv33EiNCTpmir27p99oKSE2M5f2ZJ0jXIQesSEEWeeFiJnXORj1qWJyz21k6U7d3gPyAaLA7ecOlapvjfydjTjKn7SnDNQssC34qeDEEaNrsP++YztbRYyabVRG4goiDTBSBquGm4/KmBqFripFKhgLsrrsTRb6OnyzwyLoSW8ZS7IF6JSwpfiDUWoA87MzOUyw22zqzLXV/JSy03VbkolZFgII59XTyaqaVEzJAutJJBUKPLZUyDgQM/r4ffSj1XnDYiNpEkkhCSd2TLt9P2OxuGLt3tLiPGBlUyU3kQVCKaZwvAY9LOloZ/w09tFGSRlwN5GXImGi2xjfUJh8NUwkowkp1ZGwYVrgRvafTRoK6t/P/H3o54CyH5D2FT53RmfEdOaSBZg3yJdnCxANfnagHow8AVPpbzRwpgk0uDQxLlN2aRjEGAO1RL4oXK3dsk4Ht7Eo/C0PxdHrGS/JOjK0hPN+tlbAgNTsGVCupPCrCxxvrOHprVSGXyhtq74GO4ZVZct4lT4QfnvyT2dKcQyzVrNuCYCGbijy2sicw6Kx5aK+vpA+biOIgIUot6MBEGZUFLeHnePuTxKzI7SLOJB4PHl4ejGXjblkvo+Vc5DU/sNUrhCLjBA341tlPLUDrqhKsNw9boOoLBFLD6hTNWjyB/tV9clBU/IBhMbOS6Xdlc9xxDGTdW7DuxPklXktc3MD6iQnjF95N8ZFo+rwrD9mPtOdmgzRX2o4tS1F85YK/Tu6Gy3wXjkx8jPryB1bbRrgtGpkHuLhAGG3A+0EFXgFG1jZOzL6HfiRzZvSjx3lGVBDTEPfui+7TpDF912pB6FUwjHZ+644vz3090nyKRE3Ton6DbqzDpkrITftSICOiq/tonuKnDND5eNueVTLgypQBLZuwjGVZW2TiopceDXYHCiJPfbaz9riE4l/mslldgesVE3JIVGmu/1kUDnnYLf+hUDvDTQlwWO+Lwe9EP89WjikAdwAeDS1qIA4lnShF2cCmvvP8/sSqtTYxnH9i1cqCj4QtpcS9p9OOdFvLfn4HidtLYY2jsFJKu7pmnPwGz1IG6T9vQyru/nKUAUywdWpcBAMpCl/1ER4inZpGqn6vID8AX4t9FXgufOgELPQdwr/O5xXOco9hNPgoTnZUwjRzuDSRirzBXu4KrY9d0vPjILoaKErqipvynJFJokEEsPhpByjyHNSsfr66E5MvngqHytnlg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57217cc0-ca19-44c4-d0a4-08dcf4efb30e X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:31.9196 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Y/pDI1POgs9F6qpcoBomQtVmarVhK9c+Wu3MknMeUbXYKjCNslRDtgs2C8Py9mTBJT3QO2bmAf0O0bjYekzaqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This implements bap_update_links as transport op, since broadcast links need to be handled differently for unicast, which only allows one link. For broadcast, the property changed signal should be emitted everytime a new link is added or removed. --- profiles/audio/transport.c | 45 +++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index b3bcbaa19..2f5ff6de0 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -116,6 +116,7 @@ struct media_transport_ops { void *(*get_stream)(struct media_transport *transport); int8_t (*get_volume)(struct media_transport *transport); int (*set_volume)(struct media_transport *transport, int8_t level); + void (*update_links)(const struct media_transport *transport); GDestroyNotify destroy; }; @@ -1628,7 +1629,8 @@ static bool match_link_transport(const void *data, const void *user_data) return true; } -static void bap_update_links(const struct media_transport *transport) +static void transport_bap_update_links_uc( + const struct media_transport *transport) { struct bap_transport *bap = transport->data; struct queue *links = bt_bap_stream_io_get_links(bap->stream); @@ -1651,6 +1653,30 @@ static void bap_update_links(const struct media_transport *transport) DBG("stream %p linked %s", bap->stream, bap->linked ? "true" : "false"); } +static void transport_bap_update_links_bc( + const struct media_transport *transport) +{ + struct bap_transport *bap = transport->data; + struct queue *links = bt_bap_stream_io_get_links(bap->stream); + + if (!queue_isempty(links)) + bap->linked = true; + else + bap->linked = false; + + g_dbus_emit_property_changed(btd_get_dbus_connection(), transport->path, + MEDIA_TRANSPORT_INTERFACE, + "Links"); + + DBG("stream %p linked %s", bap->stream, bap->linked ? "true" : "false"); +} + +static void bap_update_links(const struct media_transport *transport) +{ + if (transport->ops && transport->ops->update_links) + transport->ops->update_links(transport); +} + static void bap_update_qos(const struct media_transport *transport) { struct bap_transport *bap = transport->data; @@ -2105,7 +2131,7 @@ static void *transport_asha_init(struct media_transport *transport, void *data) #define TRANSPORT_OPS(_uuid, _props, _set_owner, _remove_owner, _init, \ _resume, _suspend, _cancel, _set_state, _get_stream, \ - _get_volume, _set_volume, _destroy) \ + _get_volume, _set_volume, _update_links, _destroy) \ { \ .uuid = _uuid, \ .properties = _props, \ @@ -2119,6 +2145,7 @@ static void *transport_asha_init(struct media_transport *transport, void *data) .get_stream = _get_stream, \ .get_volume = _get_volume, \ .set_volume = _set_volume, \ + .update_links = _update_links, \ .destroy = _destroy \ } @@ -2127,22 +2154,24 @@ static void *transport_asha_init(struct media_transport *transport, void *data) transport_a2dp_resume, transport_a2dp_suspend, \ transport_a2dp_cancel, NULL, \ transport_a2dp_get_stream, transport_a2dp_get_volume, \ - _set_volume, _destroy) + _set_volume, NULL, _destroy) -#define BAP_OPS(_uuid, _props, _set_owner, _remove_owner) \ +#define BAP_OPS(_uuid, _props, _set_owner, _remove_owner, _update_links) \ TRANSPORT_OPS(_uuid, _props, _set_owner, _remove_owner,\ transport_bap_init, \ transport_bap_resume, transport_bap_suspend, \ transport_bap_cancel, transport_bap_set_state, \ - transport_bap_get_stream, NULL, NULL, \ + transport_bap_get_stream, NULL, NULL, _update_links, \ transport_bap_destroy) #define BAP_UC_OPS(_uuid) \ BAP_OPS(_uuid, transport_bap_uc_properties, \ - transport_bap_set_owner, transport_bap_remove_owner) + transport_bap_set_owner, transport_bap_remove_owner, \ + transport_bap_update_links_uc) #define BAP_BC_OPS(_uuid) \ - BAP_OPS(_uuid, transport_bap_bc_properties, NULL, NULL) + BAP_OPS(_uuid, transport_bap_bc_properties, NULL, NULL, \ + transport_bap_update_links_bc) #define ASHA_OPS(_uuid) \ TRANSPORT_OPS(_uuid, transport_asha_properties, NULL, NULL, \ @@ -2150,7 +2179,7 @@ static void *transport_asha_init(struct media_transport *transport, void *data) transport_asha_resume, transport_asha_suspend, \ transport_asha_cancel, NULL, NULL, \ transport_asha_get_volume, transport_asha_set_volume, \ - NULL) + NULL, NULL) static const struct media_transport_ops transport_ops[] = { A2DP_OPS(A2DP_SOURCE_UUID, transport_a2dp_src_init, From patchwork Fri Oct 25 12:21:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838802 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE37B1F9431 for ; Fri, 25 Oct 2024 12:22:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858963; cv=fail; b=BE/RoXHLUjVQ4cQ46icn/TIYG6yc/OVgMw8OxShDLz7ep4pON8uWB98ENx3K6ZL6fkRmRC/8BJ2UuhluKLGgJGJCO4sgyIs/qofwXoEqyGeKfSXUeXzUJrJGCUo27RCADqq1G8A2BzmWyXmOvFdYHBUjIQbtr+6UENE9EPfFt1w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858963; c=relaxed/simple; bh=DgyPv53iHdnTPOrLt2LwIbzrvEY19ZYNPyeIZR3Sbas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Prhm+KQRdARslre6spyRVSZPyxAJ7o9g0/4sea6PTBII3gnPqqq8P8+X7QKHrBfvK8tjPUaMpY58rzrRsNPWR0TW2rcF2h2OFolj2NmVVScj7RBuzQkgr47BK+zl6gjdwO0/A3hdUO0BBsELJX3B+NFLDjyFYMFKRYnOepgcPQ8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=bZ28z84n; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="bZ28z84n" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=as+k3WK/Q0t/sESu2PkRSBXgzFctihyFD1CYC0Jv2tajASez+PP6K3iraSjS/FgXUPVbehvoNk+srG2lXs5LoFjsNfUUcyYlrG+SJnXC8WI1TawKsEvSKWlsURNe9rXchnesHj471QVmrHA1Qb1hrRitSjBnUAkciHHUQRiau0AHDwouqDxMnaI8XSojz6oaaf2OmIE5iWbanyNv2qydwYZeGQZWq8vXUNPZi7knTPZEkYLqbJJHgCAAq+aNj7rEkxnNNvEVZDGnXoX9m6+/PGA1jU8KR1tfmZQ3IJHjKMacvOvbHaeWtdhQXMSN9jAlGpHuZvoZ619LMSm5/5US+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=StK26AHiMKpFaYLOHxcQCIgxucrxIA3twyNPzY8kVIM=; b=gBWUssjzjJ7Y16PvlO5WOqgoLG9oOdVYT7XZ/9eCPkeNwhBzykkF8XUtxP9JPmhRVytEzwKr+Ysgqv8bIAip23CvmHoJoy+3nWQs6v82vTv0n3LM3WFAqyG1k34Fw2KMa5iSexhAQMKoWu4KUv22m2pJdG4G65kcdYDwuy8Tic/W1UcsaDgUcFRbQ/f0bXvWcLyuoifjUGosPvTpWJI6FapW3ow+THy4fH/J0SmYGZeevxwIDXDn5TBoverGer8DiQxOI0NHwmi7cx0JlWR+TuEG7d53DnqnHPpG4Ey0VVqw4MvaQO19cfYYsuWZ/uY8TsBOjoz7Whxz48MDOWA7Og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=StK26AHiMKpFaYLOHxcQCIgxucrxIA3twyNPzY8kVIM=; b=bZ28z84nHXu3jGWhacWGtKHByr9NygbBuvaBuePxPylnvHdGL31w09WjEvT0vEj7dcSU3gXHkA5gWzYpbJKjbu5mGngYZSPIiKCt1AfZAZRKTBbKaZl4BIOiPNFGWj5/fy3wcyOgObPmuT/XEN5Flro0/jpw8PSZB27AjPEGsVNLMkXm807GbiTzbrzftgWqjDv/aXaPXHPPrY8i1+zRCQY6smwbWuGz4jCNS0i3V168bkIjffAwo7mKwe7MPvbUCekEZZqDXssd0bLWnnh21T9aklTfNWHrWLJTr0Z/is7BRYfOMXYlls7ENvkyah7PTXDRbqWvZoNrcdaiaQN+7A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:33 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:33 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 11/14] transport: Make transport_bap_set_state part of BAP_OPS Date: Fri, 25 Oct 2024 15:21:43 +0300 Message-ID: <20241025122146.17925-12-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: 3522a52e-04d4-4eaf-919b-08dcf4efb3e7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: R3HSlg3yYDdN2W/4VXr7HV7s2Mk0E16xHxgNHvNEoFazN6+OaY5gD35Lma1b/5g3GmyNxRal+ws8UhgBg3zHcxuvMfoS+Hkg1V3V9Ek50nhkS5ghf0QT3iWKUFC07T0nUWo+EUNXXcnjnGBo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tUcxUFJsouk0F3jkaSeYbt00Bkm/he8B4DtAKIaEzXiHww3RzoQnKHSb+YB46sLJHznJ/K8YD4+IItEePlg09GzKWCtyWDp/sfVDcF+OcI1gSjwLmJC8fpwDxc0hLbpZsQghgl8x08B+e27DrmrnW6/OGzPrNxPRNo5uzw4fwYn4MIFOUjQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5D5GcmFJCoBVmMTIT6vzavlFylrx+tX/wbBmoaK0RW2DnFvVwx7+4Ae4zvzKU+iQ7/h4NOmDeZkyfhZvchxRFT7VVOL1hGPBls/BoEoGCXn5gJeDVjgikWfhRL02pCU0ulUeA7skUJ9XhaBcrZ4Ynq2FjgaNJqanFkGNBDcLcCW1AEyvdOeY00M/y2kNF6KAvVrSPMHibzWxqpkgP+xUmXVXmaRZmQkW7TEmBFE8yuDuri4/DO/+g5r4QfGNID2Jn1lDXGVL/nujiGb0BfJGBs7usW8loZYfS0Yld1BjVfNPH0SRn/pyNkT49jEfZ0wNJOyWLZ22xS//hJtl0EAzPoxpeHBhsM7VGFUQWX0guGTzrZeCzOQzt+wHjmIyg2zPYJ1P8Ybo3eT4fOoe6Win9SjBY0aw6PP6RfYijJFCYTgzoSh5JscQ95bGIZkbmD5iZMfqHCgFSjQjiSNnVwgqO2YKSywIefnf2jxc5siUFAtFCOx7eOZPOxmOx+1WYkAIoEjejaicSj4tMOwG3yWj0veJdRYMS4MAOxbd3Vi0HbFGO28eyOywXkNny2stAksLyOoyRWMz0/7W9byD/Wg40ROTU5P3WEGmNUDWowdZw1eKo4LfVCrkXA0D2UMm1FIJXpHXisjGSg3zVq+8bSu5ift9j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04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:33.3224 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Sj9goLR6DISRaNpKtdy8XweLDRJ/GokHgrugzj3gDvUsn6C/3FCqa5roQKmkdlACYJqYLD7gwoA0cZ8z5FuSYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This splits the transport set_state operation for unicast and broadcast, by implementing it as a transport op. Unlike unicast, broadcast transports need to be acquired/released separately, so changes in a transport state should not affect its links. --- profiles/audio/transport.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 2f5ff6de0..bb2ce8a4a 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -2156,22 +2156,23 @@ static void *transport_asha_init(struct media_transport *transport, void *data) transport_a2dp_get_stream, transport_a2dp_get_volume, \ _set_volume, NULL, _destroy) -#define BAP_OPS(_uuid, _props, _set_owner, _remove_owner, _update_links) \ +#define BAP_OPS(_uuid, _props, _set_owner, _remove_owner, _update_links, \ + _set_state) \ TRANSPORT_OPS(_uuid, _props, _set_owner, _remove_owner,\ transport_bap_init, \ transport_bap_resume, transport_bap_suspend, \ - transport_bap_cancel, transport_bap_set_state, \ + transport_bap_cancel, _set_state, \ transport_bap_get_stream, NULL, NULL, _update_links, \ transport_bap_destroy) #define BAP_UC_OPS(_uuid) \ BAP_OPS(_uuid, transport_bap_uc_properties, \ transport_bap_set_owner, transport_bap_remove_owner, \ - transport_bap_update_links_uc) + transport_bap_update_links_uc, transport_bap_set_state) #define BAP_BC_OPS(_uuid) \ BAP_OPS(_uuid, transport_bap_bc_properties, NULL, NULL, \ - transport_bap_update_links_bc) + transport_bap_update_links_bc, NULL) #define ASHA_OPS(_uuid) \ TRANSPORT_OPS(_uuid, transport_asha_properties, NULL, NULL, \ From patchwork Fri Oct 25 12:21:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838801 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2083.outbound.protection.outlook.com [40.107.247.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C862E202F80 for ; Fri, 25 Oct 2024 12:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858964; cv=fail; b=FTjU/iusbcf4JA6FVFfCAb5ONFrPtQgHhyOWZD/9jaR0i1FbcdxgNcv3M1m0Okhvs9muptntT3N7DwvVQZ5ifEKZ0McLFZfLL7N0r8ZThcenUixXCMZFRG3QLnKOuFeteIPCCtoepnqryc9ILFwQagyeGzwu8q4t+eaft7HBVUo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858964; c=relaxed/simple; bh=172d8i8/zHicvfv8mroJyrMbtl7MeOWvVjr2WBMQSH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=VctmXs5v/30MX+shDR80T/7N8H0B3XK/sfo5AXazD01MuFRabQUAhXHgVeuumHbp1yWHlNSjr0tKLMgqapQE1VHHOOlBjsndZRTcr6S3usS6ubZEoYQyDUrN23/7pvntPjuqZDVkgOwz9iyNDUYCWkDUznCVzEBEqs5L/8727YQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=GAlo6/0Z; arc=fail smtp.client-ip=40.107.247.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="GAlo6/0Z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Zvyv0M9hT+kWJSHdLaRahNTp41K1TUJmtClsBoNauSmzyp0VBftT/rBe0KlPZdSsFXCSfWvWvTNguS7402JaTtdZeivK/6sZfL9gXaJMACHZK54RZbNYSmQI4k4vZBQ6uFafHfIyawM2FhfF8iHahFVcgfGJBrHThVLbwrv1GWzhU+9xJ7B94sakwzxyporYppCWMpytIeVJnuhMi+ml7boBeNipCHplIP7CnE/RbzotlRBCXAG9CDrs5zMk55y375WChaDhZ+TUoaL9EFYa8stOM7laytjqWclkNdzxeuGWK4LC/EhpAQcrphI4Rp8Urk5bdktHU8kj2Rxz+y8cGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kqvVCmP5C3DRSJ0975nWdThfMmLvqcPyJT8hORJkPrY=; b=AuhvdcqjyBlDTi2yy/7hR3AgD/qG4Cbio9NYd4DHIWVrCFRuoKMdrtEAdP5MQvnGFFHVGExYvlWeOK/GwTpTkO4zaI7TZnwI0sZU71isex1xJDRCWQthzzZO6UAFqrdIskTSmR+GvjuglasLgCorf43HhP/PVtDHrV/iB1l7rDzrBxa/cTJOuV4PQlnnqEXsccInEf4xOSpUe2HC8M5yPuk6pTvXYhosMKXlZfjCDHnr9aD1ot22jZgfqg0Be6r0RcbH0IFzwvfrpE1fJ7XpRTCqIX66ypeyXRu1/tNv/jt4g1Jjk95J8G5dZ4nBsweCnJH3LxdCjdne+znSuRTwZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kqvVCmP5C3DRSJ0975nWdThfMmLvqcPyJT8hORJkPrY=; b=GAlo6/0Z9hs4zqM4L4NTHYdcY0j5y47PLmubR4RRMo7NtPwq43FKf8lWNF8tL7xJ9jPLJ4BXyfLj/Li3eYGxLpbatgpO03B7VJyK6s97KeS598Q2jei9U/8gYm1JJj86VUVZVmid9GZccIVLoeA/V1b2IkRTBwzBy+8e8UcIwO66Ba4PN7B+vas9U7p4AMhtoTctlv1Q34U4U5iho3MDsmQWpRfv0C0T4Av94hJlkExVG9aHjzYTErDa4cERrAJ2BTS5ec0XRDWASuWIUXl4m4W0M1od7HwzX38rOp5CWZlHFZIwGyvyTYPvy+UPXX/oHgvkE1aVyjwyMVGgXFd1ww== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:34 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:34 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 12/14] client/player: Handle acquiring broadcast links Date: Fri, 25 Oct 2024 15:21:44 +0300 Message-ID: <20241025122146.17925-13-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: f248a1f8-6fc4-46aa-e02b-08dcf4efb4ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: VuynRQYMKFMeJkbLgyHP1AOTn41cuxvyGb34VGU/GBe52jLXorQ5cCeQMMQu1FXgMAApr8dNTJFkJ5umqEZrCLxuzrTSatw2ntvNclhr0IyEM0vNNlUtJ84P/7nQl0S4NY/qwA1mgkbC53ip78SBrQRCF5n4W7CuUo/Dv8Fu+HNo3d8VTcBa2LPiIhV/ngSnmZlhhFjBXMOIgfQAGOk9eHHFredI4bj5FJOpJCa8NazIRRNbCeOGKVHDdT6kSk9GqqPZZWfQn9fPevbVBIA6IQCfpqYHcUxJpIKOHEz6RIPSi2pj3c95YEZLBQzX1aO3lgQdzf1v8NIwa2UoYVQRUGl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; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jEEFVqcsM85UJAYuzsLp5oWc7YvM6vgFOghT7NUqVnF6r9y4COgxj56m2ipU3AlD/4pCcOqUCvcSHM7ot95FUAEGPYJAz+pxFLjFAxzs9MTBB5AWqYePu34aBR9gng5DZ+VfCGa5aQ0HIlQ31t7CDDubgwhQBNfoFNNWbaGeGz9NhqIKodcO5vSPWojLvp3T6gdFuPA8sd0iTcb0KJVULNoW4PJKEkj0nVc6tJxLu9LKx/Kaomdn9Zgk7Cwv9vRJ9gfatM8upK9Igoiy8K0Ib8bXm74Dz24RHBenaW3nNO5tZPBGDdLOrwOCKYJgfIdy17+E9tIIJqLzfENov4OyvAResDFXHOBIMiSHh3ZPWUjWLzHC4D0BMRrbAjgX6pAvN4w9tYLdRo/PtqmED+4ur2gaLRn5TVC04zgeewRAN2+OvvkVLuKqO6vW821otYEL7AgYYSIdZSSJHg43RJFR50H4O27MNK6hZwY++kOYi6oMOhgHA/DsYa5vN8ZRPxqoQfdm4CJzSDlCgppQKm9gN+ptlpSKU7vhOCEcpz7PreMvu4dM2SaRSVFHNQhoNFpSmev5HWfLSi0HpFDTj6/pl6GNxY2ljsXLFusbIGRYzRjKTGbHaSJLr/ZklRplHRI5zc5cl+4PhNbwLaUxYDqipacrkEW0C/yvkMqKnUub3MZuIfI2vCCYoQdJATFDm2ftnRmAf9S0O1oLk94yJO0jg/A5W0OBTmjkAYx6tg+Dg+pl76zGsSkO2ALL+orPHpdlnE2b0F7ucWB6EJcEx9cSyg0lgu2S+w4Xd4MybOpLknR+EaqbELoP4niMlxNcUS4LLAXCgQ59zoe8rIoZA5jLkIdQVC1e5IgR87LaBHUULEKYilN7MnlYWhNr80bgDlEZHFzXhMVoVnM0cDtu1rSwIQLs6f6E4O3D0os4pXYVEgygytMTvL1MYE2ZGIopCoPESxpLBs7l+b6P6x7LRA5NgYsRF0ZFn4CMPYHBbfxZwEHGvCI/qCwawE4v+OJItnNCMI5yT2ADPEYqsPKkvxyeQHU88WQLzvgxg9hgydua98GanpOBljmc8MEM5qEfsAtRPw3foPdAlvO8tXUDbAwywIzyWBHcLiucUGCkVOUwVHyB2oQnAp1KvzLfq85vqX2i85wDdX1+EkQPkvgtoYeuY4xnilfBylqSTOdNk4hKomArckG+85nxY/xao0znkZYQdUge6BJRVoTJMUpB4h4ruqUd+JhPWmawi/A0vAQdshrMCb+Osscoutsgns5orDGDxd8KRQMVhGltrcxJu3kJ55uOICb7G/tAlF0htYxEJfDH+yj2vgzVipRP+mYA2a0i5jipN6i8lDLEUDFN243j5DlZr+Go/ZVVHDVVJc117URgwOgYIpqvIR3iFAQb7melKUTrI9To1LEBDBLVmarUp0S0ELgey1DRdQlhcPdvvrc14ZJqZOdUi9tvq1+URoRIOD3ZSTOx+bBeU2xhz3p2xZj2k2kfTtXS03hQJZSTi7zV5IEHsCt5yv3n8cV5g3kMpg4A1f5T8p4AtKSWtxIcGcUiD/52l0jY+Uq6CbrjsJOauQ3McLLh9StRoIZQRtxNdRSpzDf2ZTjBUMHr18yY6g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f248a1f8-6fc4-46aa-e02b-08dcf4efb4ce X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:34.8290 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: elCtcTpYzDLlU/4D3Um3KZzw435p/TpHceneILxL4QOE48FmgAVMEjACafV+qbprzMbeYx0zTzwhZrh7SdTc3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This adds support for acquiring linked broadacast transports: Each link should be acquired separately, unlike unicast. --- client/player.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/client/player.c b/client/player.c index 188378175..81d967a28 100644 --- a/client/player.c +++ b/client/player.c @@ -4812,13 +4812,15 @@ static void transport_set_acquiring(GDBusProxy *proxy, bool value) ep_set_acquiring(ep, proxy, value); - link = find_link_by_proxy(proxy); - if (link) { - ep = find_ep_by_transport(g_dbus_proxy_get_path(link)); - if (!ep) - return; + if (!ep->broadcast) { + link = find_link_by_proxy(proxy); + if (link) { + ep = find_ep_by_transport(g_dbus_proxy_get_path(link)); + if (!ep) + return; - ep_set_acquiring(ep, link, value); + ep_set_acquiring(ep, link, value); + } } } @@ -4919,12 +4921,14 @@ static void transport_acquire(GDBusProxy *proxy, bool prompt) if (!ep || queue_find(ep->acquiring, NULL, proxy)) return; - link = find_link_by_proxy(proxy); - if (link) { - ep = find_ep_by_transport(g_dbus_proxy_get_path(link)); - /* if link already acquiring wait it to be complete */ - if (!ep || queue_find(ep->acquiring, NULL, link)) - return; + if (!ep->broadcast) { + link = find_link_by_proxy(proxy); + if (link) { + ep = find_ep_by_transport(g_dbus_proxy_get_path(link)); + /* if link already acquiring wait it to be complete */ + if (!ep || queue_find(ep->acquiring, NULL, link)) + return; + } } if (ep->auto_accept || !prompt) { From patchwork Fri Oct 25 12:21:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838483 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2066.outbound.protection.outlook.com [40.107.249.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A4BA202F9D for ; Fri, 25 Oct 2024 12:22:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858966; cv=fail; b=iPnmJICVsmswmmt22Xr5+QZgZiOfH/x36Rsc0rGNr02kL9rwx833gm00pJwbaVv6g+TIEYER/apHP+rkF3rRISZugNGoPFQh0TNZkZJ/DM1dne2UEGh6ueLo8tWQK/Frc/KABSEyer1ETISmZhj7W6t2RjXvpghrjWjx0nhCtgg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858966; c=relaxed/simple; bh=A0KlTM+60pSi/BKDq4BjaLDPFP2MgJPBvuFCET9441Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=myzaYtDmspVjuMEC7nE5t1Qrnsjr9rktGRDg2tsf3MUvrq/kzMTwEmpXf+RXdPNroxpZeNcmQECw+CJZCHI4RPF7tDRrkdoaeOIlnaLEH7cy1Kd+Jlowrnj/4S4kRwLL2hHi6+bLBp1SkzhrAIpGJYke0355P4vZKhB8kWamDng= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=lW0Mibz2; arc=fail smtp.client-ip=40.107.249.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="lW0Mibz2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vVetc+7tQFnxWuGBRGUkP0xJzO3HEI1vKlo5fi/jkUloPF4KbeFvEabRoRHKR5ugdqac7ueFIXkDmFt4lvBxhZqN/ZVlUBltgxL+9LSwmLcoRp+RFvdNKDO07+Da3uAAf+ABRFnnP3mLD+hO84Pj7dYTq4mKmZ7h9s43XvTuk6Wuqe/OFFYWhfAKiaD7nk4r4G1wilKPToAuFpdj9i+0RRXjaPKWLleMg/BHNy2t34EUmgd9R0BwyQSWVLecHQIGfrdCUWa4utooKohHNyKK+beilsNrICXomuxJO30gvd+siZNurlkh705Yl31tMa0aMzUdBh+pqI0vdNakOjvdtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XjqyURUXzN1ULLwz0SXvnnDaimcQuKYmFBvTLDq0ePM=; b=tubO9Q1kPc+ri3QokMaB1yyJXXNg0naWtyxgyu/c5e1mNhjkCZ9CxMNWLsvOXzyS/rpPUm8zqM/mO9Sc2vi0ZIJV7aqRN+YNm0T7AGTayKA7NLUDCGxeiceNQaGoOfiSruRJ+UdOaicbC4bfEzDiBcWBBSnF/GIYC19S7ydBnVgdznBtyvjIqrJLVrRbb+IiH2FrZiUYo/pzDuBibD79+JZ4Oa95dRNvNBtpguvKCbj5kz0TAKNAV9sAsL0u1L/x0IVBbRdQnwEVQrCpmXtvhdpY3XtfRk4KtVfZZy9T6DP4u8eN69z6iRBeyb7ezwNOhtSj+32ZckU6GqT35BmxMQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XjqyURUXzN1ULLwz0SXvnnDaimcQuKYmFBvTLDq0ePM=; b=lW0Mibz29sZHAsQ6YGBI73PQr0krRHslGLGc+7LVW2YXHaUrbvV5LxiSkUPeDtiyBbD62mZSRVoWK+8tFS04YYBnE5KsEINifWurt4zeabE+U4Odjsv2M6Eew1hTWHpXpgWqRDcMxTbJG7XpKPaSsqHerWcFgO7SzZfo9ZuOYFO35+z3pNvSghmY6e2i5DlxNTy94/yHtUtTnG6NZqc8AZxkN8o+l1KEfCB5/wj3ewWV9LJr90cJru8iwOCHOaI6GAkMq/++5arz0yN6d0lNA1TI6rLz/owvDBxyNZVVZCHRHrV7HeE5nKyFq9FfH9h/8sE0/W/pVweT9mbIAlGaVw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by VI2PR04MB11052.eurprd04.prod.outlook.com (2603:10a6:800:272::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:36 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:36 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 13/14] client/player: Add support to select multiple transports Date: Fri, 25 Oct 2024 15:21:45 +0300 Message-ID: <20241025122146.17925-14-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|VI2PR04MB11052:EE_ X-MS-Office365-Filtering-Correlation-Id: dd15d039-96f3-4d68-e962-08dcf4efb5a9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: HYlqbBNlBIRo6I/rh4NpyuzTBmfPzM3BaajS9hJMDNQQlYZ8KFhIIpfyySlstaQNlLxiQ3PHR/1qgHyjpA8e0r7mHqH/lUxRlwp4ASbHKB9ZtYvr14deS6Of1+iL359Tn99M9/DR0xS4PzJNaE6YlZsBs5VbwJXTV6rKt40uoajErJExXkfDZAV7Cf9YX5rjOe7r+HfXUIdeiRbsN76xiqKh5lnP3QtGgxM/yOxiEOqUvVvoTiNOct8FydBSttZqq3VY9fEhnQXWRf2+F/gShlN+X5UpHKUJsA88rHomIuQ0vN6SQFh0/20TDfu0S9f+XcXNHlhS6+5Grq1yY0T0GTubU9d857EZo5FfPvWWkwDfmopMsJ45OaPOSypljPGtM6/bujvVPT+2nVt8vnJIb06FydZVA7NfvAUChuH/SuK+Wrfcm1C/7PmCfC69ni/dAwlAex3plMUHL1hzhXpzQ6BQQqFTpOhmVOvH3+fbLqBwKi32eCv/z0TFas3jSCgZr+TAgVK/wr9vDC7B8g94xJLkdOfB8DxcJDkdqsmYW4wGs9+dw2TBA0WwGueW403OIz+Gx0Zw/kHk4g469sW4njU6AwktbRoltgBzA7wIbA6/bnJXl6QvUUpJBQIaW6NMhAK3gSJDOfB8ESaBjymIeCDJFUOWAd4VmQL/NyI1tGxhtMZJg1avkMKGd6jEJdhztUwdRBdbaoCjBRk9SPAz5aAu5xG4ZuK0obBKvnllhsgsG1TV0e0Upu5iwITr5uIbhTAXGnzFrReCvjpXAxuvs2DybO7uAu3KctvGgq9AyCLKCOccDOSUP2NMIahjn7Mde8rGi4ilyLsTaKyfI2DWrHJsi2NU9M2SR4pnBNa0HB/UcQrh0Slm+RfsT4VuLzttFSp6oMHULNqO4Mp39t9DvHeyuef59jbCc6XINuC4Age//pYFxAAWOzzcqtBSQOKRX9HV3QXGNqS9aPRTW5/WpGZe1bQwGEQAzgv9sOH3g1wLAXIoJT8WCqDWn3F6SJcwrEcCz/u2BLqIEeAXATdeKufSrNJWOSaB+Wmw1h/t55YwCIL6IgRrQMtMZH7BuRAkdSSTq/EbKNzO5rykg2T6JL3tZvKlpD9pLfp4gnlg4gySXBPTKF/eAT7ODehf4qApQKB+zCjO9jYL+lAADq2/NxjLOtLaTStE5xXcch3N3ToFHF2WKIueqJr5mSGMN86P7e0RY+Rz36+BX2A8jKzB1tMjhI87hZtCoT0Z8JBdW0eu+QHLEZX5Sk0IVZe6qwFsv17KD20aXfS4G6RMPS3e/8jg+dcrJJ07C7ftuKiOXiFgQQo87pgE+7PMIqzB8eJJ4t573T3aAsH3v6tQb4W3jXFaOCqbQDse8o3wrsiDL8A= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NXGZ1w2BQX7uEcyfTN0JYVKUqBW+KL8tovwlalJhwU3mguc3e996RyXMwqIKL6Djl2LINvE4zHyvHlL4ZlQwF/yp0yvkj6eyNd+pAY41sNfCBj2V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F8tTYcdAMRwiOfCg579IsUplSqq0t+ZMTxSxHjaRqPOXgaP9etrNLUT0g+J0wW7278kh6p1re2unWZZHXmQrjekFa6/TQc9ZiIPxk6y6Mz1qa+yLF/aC5a7Mn1ZX5XvjK6lqFcWALT02i04vwS0T/fDpomNBNgYnP5nw15t00iZ9AA3KPt7L2dMjVMqwcznzJeJK+eVPuaokyXoXMulLZsxza7ppDtCb0BtEuTayGahSfMmoucWxu+xXyIUzXPYb1I4NzbkY6Qb5E9ICYpLRidhftPS/lZKZje5uYfwvK0FzK+rUBo3qk2U0hEOwAEAGP+aUl6WWgCpEXQimNtgZNuE6gLm+L3atseBu/g3GwKqKCp/dnfKO/BYupkzBp1j5gL7/+MJXoU/8EvvZ0r9qA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd15d039-96f3-4d68-e962-08dcf4efb5a9 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:36.4421 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Rd6ftjgtReq4GIpuq2A6ZM0pT9BG2HdHcqy/IQAbSGbi+3i5tvlfFy2Q2cEwYShmtJjCyaCiCQ2wlK0qSVcTQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB11052 This updates transport select to link transports together before calling the "Select" method for each of them. The bluetoothctl log below shows a Broadcast Sink detecting 2 streams from a source and selecting both of them. After the first transport is acquired, the link is created and the first transport goes active. client/bluetoothctl [bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): y [/local/endpoint/ep0] Max Transports (auto/value): a [/local/endpoint/ep0] Locations: 1 [/local/endpoint/ep0] Supported Context (value): 1 Capabilities: 03 01 ff 00 02 02 03 05 04 1a 00 f0 00 02 03 01 Metadata: [bluetooth]# Endpoint /local/endpoint/ep0 registered [bluetooth]# scan on [bluetooth]# [NEW] Device 17:7A:80:64:A7:93 17-7A-80-64-A7-93 [17-7A-80-64-A7-93]# [NEW] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 [17-7A-80-64-A7-93]# [NEW] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 [17-7A-80-64-A7-93]# transport.select /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 [17-7A-80-64-A7-93]# [CHG] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 State: broadcasting [17-7A-80-64-A7-93]# [CHG] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 State: broadcasting [17-7A-80-64-A7-93]# transport.acquire /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 [17-7A-80-64-A7-93]# [CHG] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 Links: /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 [17-7A-80-64-A7-93]# Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 acquiring complete [17-7A-80-64-A7-93]# Acquire successful: fd 8 MTU 40:0 [17-7A-80-64-A7-93]# [CHG] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 State: active The btmon log shows that sync has been established with both BISes: < HCI Command: LE Broadcast Isochronous Group Create Sync (0x08|0x006b) BIG Handle: 0x00 BIG Sync Handle: 0x0000 Encryption: Unencrypted (0x00) Broadcast Code[16]: 00000000000000000000000000000000 Maximum Number Subevents: 0x00 Timeout: 20000 ms (0x07d0) Number of BIS: 2 BIS ID: 0x01 BIS ID: 0x02 > HCI Event: Command Status (0x0f) plen 4 LE Broadcast Isochronous Group Create Sync (0x08|0x006b) ncmd 1 Status: Success (0x00) > HCI Event: LE Meta Event (0x3e) plen 19 LE Broadcast Isochronous Group Sync Estabilished (0x1d) Status: Success (0x00) BIG Handle: 0x00 Transport Latency: 0 us (0x000000) NSE: 3 BN: 1 PTO: 1 IRC: 3 Maximum PDU: 40 ISO Interval: 10.00 msec (0x0008) Connection Handle #0: 6 Connection Handle #1: 7 < HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13 Handle: 6 Data Path Direction: Output (Controller to Host) (0x01) Data Path: HCI (0x00) Coding Format: Transparent (0x03) Company Codec ID: Ericsson Technology Licensing (0) Vendor Codec ID: 0 Controller Delay: 0 us (0x000000) Codec Configuration Length: 0 Codec Configuration[0]: > HCI Event: Command Complete (0x0e) plen 6 LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1 Status: Success (0x00) Handle: 6 < HCI Command: LE Setup Isochronous Data Path (0x08|0x006e) plen 13 Handle: 7 Data Path Direction: Output (Controller to Host) (0x01) Data Path: HCI (0x00) Coding Format: Transparent (0x03) Company Codec ID: Ericsson Technology Licensing (0) Vendor Codec ID: 0 Controller Delay: 0 us (0x000000) Codec Configuration Length: 0 Codec Configuration[0]: > HCI Event: Command Complete (0x0e) plen 6 LE Setup Isochronous Data Path (0x08|0x006e) ncmd 1 Status: Success (0x00) Handle: 7 The second transport can then be acquired and it will go straight to active, since the fd has already been set: [17-7A-80-64-A7-93]# transport.acquire /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 [17-7A-80-64-A7-93]# [CHG] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 Links: /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 [17-7A-80-64-A7-93]# Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 acquiring complete [17-7A-80-64-A7-93]# Acquire successful: fd 9 MTU 40:0 [17-7A-80-64-A7-93]# [CHG] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 State: active The transports can them be released one by one: [17-7A-80-64-A7-93]# transport.release /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 [17-7A-80-64-A7-93]# Transport fd disconnected [17-7A-80-64-A7-93]# [CHG] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis1/fd0 State: idle [17-7A-80-64-A7-93]# Release successful [17-7A-80-64-A7-93]# transport.release /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 [17-7A-80-64-A7-93]# Transport fd disconnected [17-7A-80-64-A7-93]# [CHG] Transport /org/bluez/hci0/dev_17_7A_80_64_A7_93/bis2/fd1 State: idle [17-7A-80-64-A7-93]# Release successful --- client/player.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/client/player.c b/client/player.c index 81d967a28..66a26ef40 100644 --- a/client/player.c +++ b/client/player.c @@ -5173,8 +5173,9 @@ static void set_bcode(const char *input, void *user_data) g_free(bcode); } -static void transport_select(GDBusProxy *proxy, bool prompt) +static void transport_select(void *data, void *user_data) { + GDBusProxy *proxy = data; DBusMessageIter iter, array, entry, value; unsigned char encryption; const char *key; @@ -5220,28 +5221,62 @@ static void transport_unselect(GDBusProxy *proxy, bool prompt) } } +static void set_links_cb(const DBusError *error, void *user_data) +{ + GDBusProxy *link = user_data; + + if (dbus_error_is_set(error)) { + bt_shell_printf("Failed to set link %s: %s\n", + g_dbus_proxy_get_path(link), + error->name); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + bt_shell_printf("Successfully linked transport %s\n", + g_dbus_proxy_get_path(link)); +} static void cmd_select_transport(int argc, char *argv[]) { - GDBusProxy *proxy; + GDBusProxy *proxy = NULL, *link; + struct queue *links = queue_new(); + const char *path; int i; for (i = 1; i < argc; i++) { - proxy = g_dbus_proxy_lookup(transports, NULL, argv[i], + link = g_dbus_proxy_lookup(transports, NULL, argv[i], BLUEZ_MEDIA_TRANSPORT_INTERFACE); - if (!proxy) { + if (!link) { bt_shell_printf("Transport %s not found\n", argv[i]); return bt_shell_noninteractive_quit(EXIT_FAILURE); } - if (find_transport(proxy)) { + if (find_transport(link)) { bt_shell_printf("Transport %s already acquired\n", argv[i]); return bt_shell_noninteractive_quit(EXIT_FAILURE); } - transport_select(proxy, false); + queue_push_tail(links, link); + + if (!proxy) { + proxy = link; + continue; + } + + path = g_dbus_proxy_get_path(link); + + if (g_dbus_proxy_set_property_array(proxy, "Links", + DBUS_TYPE_OBJECT_PATH, + &path, 1, set_links_cb, + link, NULL) == FALSE) { + bt_shell_printf("Linking transport %s failed\n", + argv[i]); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } } + + queue_foreach(links, transport_select, NULL); } static void cmd_unselect_transport(int argc, char *argv[]) From patchwork Fri Oct 25 12:21:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 838484 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F21AC2003BC for ; Fri, 25 Oct 2024 12:22:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858963; cv=fail; b=jCE71BZFEgKEXRLqAwBQt0XUXWGMfcxJHkbfean5+PcDezJh27PWy6l4GkyFJMrjhNJ9UIx1/v8jhs34Cy1I0jB4bVrP/hcnqq2f8mHxLyQj/2VBX6NQq6BM6w/4R9oPZudEpBMGG/RKC5WWnqFkm5PJAm02wXJZ7VWe2MBgwLA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729858963; c=relaxed/simple; bh=aptpSCqH6pxjKOB/xIFyw1qsWYabgNFS7EDrumA7kxg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=gLCWVxOJw0phsc76ZPwLEuhN1ZmRUj17mWTOnYUJnlL4DVj7Z/3ao9JxXRzIM7CzoSO9xmY2cI6fPqq2d+vpbIbDckS9N7fY2NB7bE+stZMZ6jlGrITjvOxL6ZzyQuWiga8QxEgDlvPn+T0Jd3aPxLDNObqFdVUkZf4hHvGvhpw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=bKEor026; arc=fail smtp.client-ip=40.107.20.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="bKEor026" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IsTjzfVha+6n7BPay/2F6O8NdhAcJit25BqSWrF9k8vZWa6kvXh0tWT9b9J0rvaIZrhBee4/WpdTqPa/JR0TXfHoaU75gJaZ7rl9nbpWflHCAYC70b10yQvGnaFzJ3QDZK95tnMXmq42v9CoEX0e0f+WB/aXctUoq40BT9tWXmDEv3UXoExHckov5RXOunBnAsqT/mexHBiuOEqwsk/E2PeXU3utz/5AOBDt8/A8qW7rgY2Eh49rsbkKvwG6vl837nu5M8a00+1Zz+R79KvZJiKU9fK3VCvo+9VajPWkHGKgOSra5qOPCiFX0RgyNw90HNBWvoyu36IKCxlpxJXtTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L2aUKoPzRSyH7ntYn26/cxnlFeEcu2EtfFfDD2XBHlQ=; b=wW+ONM6gOQ++irCr0ljg6olrSBe790oSiOxBTD4KO/h4wVD+EeRYQlIG3Ubg9u5WXka6piAIlGNCYv20Mcy7Qmcr5PoXkz5gYeXj6+ouX2P1/8X6zy8q05kE/lmRrp0cIY35MUKqkehwXfzN0D3Tl+QL1TiR7ow8EwFhBdBCW8ZxUfdlixdyrYa46e4f/ClYaJ3hP8MLNvmhCtCLg4mTtKtDGFoOcp79j/1pfoNSzl9OWczN1ORV4cBm76I5NsxaWpGOgX90A37/YB4DacBGeRy7M2CysIwTTLBLCiMH6aUB/VAKtLFtfrW7KR0NTmnGE59ykCnJIDH82enkm3Rs0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L2aUKoPzRSyH7ntYn26/cxnlFeEcu2EtfFfDD2XBHlQ=; b=bKEor026tK0TFkwZ5L5Pn8rmea7iTyC9I2EBHzZc+OXZMS/Js9m61op9N99H9JXZY1Q++taC+XdoS5FsDRHS9hdMQQHhi05mXrHADgi0Y1XUjfg2699oKe5Lwd+NSLjI0MuWtMJcZUxitYXl+N7H28wKdVjlXTruCsfUjdepEZAHJjRpXRSpDBM+YM02sI8or6POrrNly4BBrVb6m1nqq3q/npDya5HUoyOLhLxqiGjYV1sz/EESKtCtkI8EstdSYCtdEHsPx1B7t9t3gY3DntYajcLlJgewzmvP3xw5GUKtI429JdbL/AowOwLRiz5pSs1bDRuOeDnZsVc5UEzQlw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) by PA1PR04MB10843.eurprd04.prod.outlook.com (2603:10a6:102:480::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Fri, 25 Oct 2024 12:22:38 +0000 Received: from AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654]) by AS8PR04MB8898.eurprd04.prod.outlook.com ([fe80::5e22:869c:33c:9654%4]) with mapi id 15.20.8093.014; Fri, 25 Oct 2024 12:22:38 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH BlueZ v2 14/14] transport: Unlink broadcast transport at release Date: Fri, 25 Oct 2024 15:21:46 +0300 Message-ID: <20241025122146.17925-15-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025122146.17925-1-iulia.tanasescu@nxp.com> References: <20241025122146.17925-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AM8P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:21b::11) To AS8PR04MB8898.eurprd04.prod.outlook.com (2603:10a6:20b:42d::15) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8898:EE_|PA1PR04MB10843:EE_ X-MS-Office365-Filtering-Correlation-Id: b9aa9ac9-c265-46c3-0787-08dcf4efb6c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|52116014|376014|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AjJl1iqkmVV532C0b0xRmxF9CXwCGV9Lud7t+HWC1QkvFLLTKbrAaz3mTkvE94/heV1/V2KrkQADYHCFa0UGR0GVPTAgCPWx/2homEwDVfkSrBorFjR+IsJIuSKY8SAtMMcJB6Lns00RM/MF6r+S1Osby7PPv+vz0TN51k0NZcbh5XtG/Oct2q1mwbWoS+Q2sppPY+oMwGm+6/qe1QGPdgFcxxI5MTYv6C0mwArFhJkgZbY9AIe1uY37gqRdYOg31VCapbMhL0OILx9MtPsTSrVR41gBos6nKM9XDSGGhXJwqA8qt11Tfzqenvyu5pzl0Xka3N1U+05PLVIs= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8898.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(52116014)(376014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CzrFZ0jr46IPeERYCT5B9FQchkCm/rc6Oaaru1esZjCUxPhGiWIG7QGIXkelFn6FJIpDtzXrIaJKv+gpStRgBbIIfcFmAYgRkSRH8twgpYDZBZ4uw4saq1k1WvH0mn5TsoU7/Gm3WZkfHtakckYX5SQ/PobftOt5BAfaYCnR8NsWJzh/BjEGbdjN9OWyrHggF3jnM349Oh19bVV2nfGW87KmTs2h2HIj5chfps9zieDsGKURFDFX4+FWfeao5ryuU3qqP8NPxm2AzliidL+3aCoLBq6EHHZTt/001BrvqBMir5w86r0iKLGfFumzMf5je0T9gG3rqXX1VcVnc9jRQRWIknbKBCKP7bBce/T3Ve5qs6DqlliLgQmq1axGrIphKfz07Z6iFvXkpSOfLxhvghpj2AHycB5HtLzjRScMo+SjXJ6kgz8iUKZy8bEijeLIHs20WFuZ+ADcEgSxSk9I3+BLmos2399+KDySS1YQy+de4hn8J/nfE5vkBToN573maHmRCscO+mMywXKhLnlLSLoqz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Boqu4T6S1zL7vJDCRYomdg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9aa9ac9-c265-46c3-0787-08dcf4efb6c4 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 12:22:38.1886 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: y+GnzZO2Cakqs1Wj13WXv80PLB4VIGWT802772a+sTtZ/yBFyhDna8jdQIuUlw9qonmgvUfTThkaB54+TKZWhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10843 This updates broadcast transport release to unlink stream from all its links. --- profiles/audio/transport.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index bb2ce8a4a..5646b2004 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -1779,10 +1779,45 @@ static guint transport_bap_resume(struct media_transport *transport, return id; } +static void update_links(void *data, void *user_data) +{ + struct bt_bap_stream *link = data; + struct media_transport *transport; + + transport = find_transport_by_bap_stream(link); + if (!transport) { + error("Unable to find transport"); + return; + } + + bap_update_links(transport); +} + +static void transport_unlink(void *data, void *user_data) +{ + struct bt_bap_stream *link = data; + struct bt_bap_stream *stream = user_data; + struct media_transport *transport; + + transport = find_transport_by_bap_stream(link); + if (!transport) { + error("Unable to find transport"); + return; + } + + bt_bap_stream_io_unlink(link, stream); + + bap_update_links(transport); + + /* Emit property changed for all remaining links */ + queue_foreach(bt_bap_stream_io_get_links(link), update_links, NULL); +} + static guint transport_bap_suspend(struct media_transport *transport, struct media_owner *owner) { struct bap_transport *bap = transport->data; + struct queue *links = bt_bap_stream_io_get_links(bap->stream); bt_bap_stream_func_t func = NULL; guint id; @@ -1794,6 +1829,10 @@ static guint transport_bap_suspend(struct media_transport *transport, else transport_set_state(transport, TRANSPORT_STATE_IDLE); + if (bt_bap_stream_get_type(bap->stream) == BT_BAP_STREAM_TYPE_BCAST) + /* Unlink stream from all its links */ + queue_foreach(links, transport_unlink, bap->stream); + bap_update_links(transport); id = bt_bap_stream_disable(bap->stream, bap->linked, func, owner);