From patchwork Fri Oct 13 10:05:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13420604 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E8BCCDB47E for ; Fri, 13 Oct 2023 10:06:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231163AbjJMKGb (ORCPT ); Fri, 13 Oct 2023 06:06:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbjJMKG3 (ORCPT ); Fri, 13 Oct 2023 06:06:29 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2056.outbound.protection.outlook.com [40.107.104.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFEE1AD for ; Fri, 13 Oct 2023 03:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YLqTSPtR9e2dcuFSx7zCkMsuhwDNNzWLoHMbfr6rGaJY9k6NF2PRci6KTbSQek5WAg6z0HH2zR3MVH/Bq9XdD8gx7YrvYTluAOmtlb8skdRZgE8j4Wg4RNOI5lxuPc9mh78WBow7K7P9JYM+Fc9IMSK6Da6LGiy2/odohILC2Fzp7ldMXyDN0qgmDFMcrO9dlth2U+228c2ovOtfBOGi1EPjjbnw9d+zOxkgDSB2PTR9VBiu3sDmkoo3dlCu90Uxv/tfW94IxJPyc5hjVD3ALrErizf7J0GuYhzdYl9L8WxrNgLlWgu2G+B6RvwL2zUFswbwZ6jS4MSiHG108rTGcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=SM6/gBbhm3WbCjeKJUdXbPisze954/Vc3mDe26p9Cuw=; b=G7bLSCRjtPFpWu/QekXkniuFfe7p4nn3VynITVcZwAzBQCR6fjCruo2rXs6c3rrWiN27/rCbxVvWVAx4q7CAjUrrZRxe+HOP+aZDbI9z5PUn7cON361GAorW4DyqVqBJvo7A4fdu6zPS5msCbAr2rLKIrt+Sc3tutjJKCqoLSMvEpecBNd7ETdn9PN+5r+mvtADQqUYQvI1Entp7OFoONVZGwp+Xj7Opcm5vw4OGA7x4cWz9IDUn8Kg3cJ69oD27HLcMNpNE2NVYtHJOt9goUTigc63WRmmHb8d8hwHdTbDKAm2k65LW+y2WEy1bTzeJiJInl8ov9l9HbChFZio8Nw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SM6/gBbhm3WbCjeKJUdXbPisze954/Vc3mDe26p9Cuw=; b=O2d+AM8nIUwawC73mlqdRKtby8fu/Yi1gMWz88gMaMIQU767gBlMdOP3N6ps6H/7g2mBbIFTpy13FCZizfkoFyQQ0hhb9D+uSOJznEtSvct0juC9H1rMRCSPyo8Er6QKWWcBy3i5r9egqZX/8Uof6WmGdk0egA91ouJZNzdFUBU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.46; Fri, 13 Oct 2023 10:06:25 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::a53f:4bda:e012:a73d]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::a53f:4bda:e012:a73d%7]) with mapi id 15.20.6863.046; Fri, 13 Oct 2023 10:06:25 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ 1/2] bap: Fix source+sink endpoint registration Date: Fri, 13 Oct 2023 13:05:36 +0300 Message-Id: <20231013100537.3867-2-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013100537.3867-1-claudia.rosu@nxp.com> References: <20231013100537.3867-1-claudia.rosu@nxp.com> X-ClientProxiedBy: VI1P191CA0003.EURP191.PROD.OUTLOOK.COM (2603:10a6:800:1ba::7) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|AS8PR04MB9080:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e5406dd-e716-4019-a1fd-08dbcbd40f43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hRGoMCO+AJenQA3VDPUceGLd1LCE8cGYrdP6fZQqte86XfUtafQGqgc+9tUP7Jdt+XPIaCahf4m6+fKmhH7UyHBNRxxjj/SUlrEzOZ5buP5GHIw9XocxXSaDaPkxDsnebjxirPl3OYWRg49jt4Hyz7algAxs9e6kExRmCFAHyqIURaOknkFSrFsTL52X3xuNRGHfEcxn39muWESx+jK3TjzPrnP3H/YGbpmz9T6hJPC+A36kW/H0pnegydGnqPbGOiKjvSBWyhe78ALOB51rKKe7HgxnirfHPHe4mTTVYmB4PaOleE384NyUdy4UAzeAoGrZTFf5+dziTnzHdi5eUhYSyUXk3HmbrtkZTHyuUlko1ZMQISPQ/l1oXRcCCrDOKtMikiBaEYg79qoGLKx84IccUXc3kMOE8pRFGEq/ebUM1ukNYrLF+R3mT7pSBIHXOFXC+lpdcr3RnXtP5riP/+zf+H1cJ1piuXlahaWfVd9KDSp7xoVNvsRfpQdqp2JXBxlVlV29X7JEvdkUIRW/ZKfJKm916FSvGsN/6uB7EWIrXUr5ey6T7RCqkZkvC1um X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(396003)(366004)(136003)(346002)(39860400002)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(6512007)(6666004)(6506007)(38100700002)(86362001)(1076003)(2616005)(83380400001)(26005)(8936002)(8676002)(4326008)(2906002)(41300700001)(316002)(6916009)(5660300002)(6486002)(66556008)(66476007)(66946007)(36756003)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZcIJnyK8IJQ3sKvX4yt+lJ8E+NrBcwaK7xcuGc5GZ/HRwSG+x36xtq8EM4TybvSF2Tz2JcqSL+riETzsKytPu0oLLqXbRMZ6vskMO9oRs5uwIS8wPT/RNsWjlO+UAd8UrUzrWWf+pAPwq4Or67n9jHiWBdLMofozn+4du4BRPEZCrYUNF+Q8/0vvRakMXPUWSaXYlNsy35JCqht2CKFxJswWGC6v/41GT+z9Nz5MO3ywEGcJGnh4IDlS1JjOfgXVFn4X2bGhPkD52FtCqWc2X54zZ90C01mlAl+OYmkH2U/U6PfG9PHz+L8/TDz0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k+duH/kkEfgxpiGEGu2KUPH/lPzQmnvpBMJTCbNfOL5injpUZm4wVKFS615C5Qh5cGa4cDtvH1BcNqxdied/WJrvC5ItGyahud1zYoovb0sB/MnWk7ko6MPI1XA2WU6maIWy9Bj2IcNPMVP6nLNgY+wj22XojTK67KQyiAJc8n9ZPD1GSrGM8NA4dgnyBbcsXhQxmcRmm7eig0mTd3Iv4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e5406dd-e716-4019-a1fd-08dbcbd40f43 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 10:06:25.4596 (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: jGWPMGDwJG/H/7+ciMXOh9lbP4ibdv3jFZwLzK8Joe/S1OGRMRXTH3kB89yl6gVVuOSRzP4OOk+zSB83J/cCKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9080 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Create new endpoint name for the simulated broadcast sink that is created when registering a broadcast source endpoint. This removes the ambiguity when having registered a local broadcast sink and fixes the situation when multiple remote endpoints are created when discovering a broadcast source. --- src/shared/bap.c | 54 +++++++++++++++++++++++++++--------------------- src/shared/bap.h | 1 + 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 925501c48..266116235 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -644,7 +644,7 @@ static struct bt_bap_endpoint *bap_endpoint_new_broadcast(struct bt_bap_db *bdb, if (type == BT_BAP_BCAST_SINK) ep->dir = BT_BAP_BCAST_SOURCE; else - ep->dir = BT_BAP_BCAST_SINK; + ep->dir = BT_BAP_SIMULATED_BCAST_SINK; return ep; } @@ -1500,12 +1500,12 @@ static void ep_config_cb(struct bt_bap_stream *stream, int err) return; if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_BCAST) { - if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK) + if (bt_bap_stream_io_dir(stream) == BT_BAP_SIMULATED_BCAST_SINK) stream_set_state_broadcast(stream, - BT_BAP_STREAM_STATE_QOS); + BT_BAP_STREAM_STATE_QOS); else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) stream_set_state_broadcast(stream, - BT_BAP_STREAM_STATE_CONFIG); + BT_BAP_STREAM_STATE_CONFIG); return; } @@ -2710,15 +2710,15 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, break; case BT_BAP_BCAST_SOURCE: bap_add_broadcast_source(pac); - if (queue_isempty(bdb->broadcast_sinks)) { - /* When adding a local broadcast source, add also a - * local broadcast sink - */ - pac_broadcast_sink = bap_pac_new(bdb, name, - BT_BAP_BCAST_SINK, &codec, qos, - data, metadata); - bap_add_broadcast_sink(pac_broadcast_sink); - } + /* When adding a local broadcast source, add also a + * local broadcast sink + */ + pac_broadcast_sink = bap_pac_new(bdb, name, + BT_BAP_SIMULATED_BCAST_SINK, &codec, qos, + data, metadata); + bap_add_broadcast_sink(pac_broadcast_sink); + queue_foreach(sessions, notify_session_pac_added, pac_broadcast_sink); + return pac; break; case BT_BAP_BCAST_SINK: bap_add_broadcast_sink(pac); @@ -4457,13 +4457,23 @@ static void bap_foreach_pac(struct queue *l, struct queue *r, for (er = queue_get_entries(r); er; er = er->next) { struct bt_bap_pac *rpac = er->data; + if ((lpac->type == BT_BAP_BCAST_SOURCE) + && (rpac->type != BT_BAP_SIMULATED_BCAST_SINK)) + continue; + if ((rpac->type == BT_BAP_SIMULATED_BCAST_SINK) + && (lpac->type == BT_BAP_BCAST_SOURCE)) { + func(lpac, rpac, user_data); + return; + } + /* Skip checking codec for bcast source, * it will be checked when BASE info are received */ if ((rpac->type != BT_BAP_BCAST_SOURCE) && (!bap_codec_equal(&lpac->codec, &rpac->codec))) continue; - + if (rpac->type == BT_BAP_SIMULATED_BCAST_SINK) + continue; if (!func(lpac, rpac, user_data)) return; } @@ -4484,12 +4494,6 @@ void bt_bap_foreach_pac(struct bt_bap *bap, uint8_t type, return bap_foreach_pac(bap->ldb->sinks, bap->rdb->sources, func, user_data); case BT_BAP_BCAST_SOURCE: - if (queue_isempty(bap->rdb->broadcast_sources) - && queue_isempty(bap->rdb->broadcast_sinks)) - return bap_foreach_pac(bap->ldb->broadcast_sources, - bap->ldb->broadcast_sinks, - func, user_data); - return bap_foreach_pac(bap->ldb->broadcast_sinks, bap->rdb->broadcast_sources, func, user_data); @@ -4497,6 +4501,10 @@ void bt_bap_foreach_pac(struct bt_bap *bap, uint8_t type, return bap_foreach_pac(bap->ldb->broadcast_sinks, bap->rdb->broadcast_sources, func, user_data); + case BT_BAP_SIMULATED_BCAST_SINK: + return bap_foreach_pac(bap->ldb->broadcast_sources, + bap->ldb->broadcast_sinks, + func, user_data); } } @@ -4927,12 +4935,12 @@ unsigned int bt_bap_stream_enable(struct bt_bap_stream *stream, queue_foreach(stream->links, bap_stream_enable_link, metadata); break; case BT_BAP_STREAM_TYPE_BCAST: - if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SINK) + if (bt_bap_stream_io_dir(stream) == BT_BAP_SIMULATED_BCAST_SINK) stream_set_state_broadcast(stream, - BT_BAP_STREAM_STATE_CONFIG); + BT_BAP_STREAM_STATE_CONFIG); else if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) stream_set_state_broadcast(stream, - BT_BAP_STREAM_STATE_STREAMING); + BT_BAP_STREAM_STATE_STREAMING); return 1; } diff --git a/src/shared/bap.h b/src/shared/bap.h index ebe4dbf7d..af3b6be71 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -19,6 +19,7 @@ #define BT_BAP_SOURCE 0x02 #define BT_BAP_BCAST_SOURCE 0x03 #define BT_BAP_BCAST_SINK 0x04 +#define BT_BAP_SIMULATED_BCAST_SINK 0x05 #define BT_BAP_STREAM_TYPE_UCAST 0x01 #define BT_BAP_STREAM_TYPE_BCAST 0x02 From patchwork Fri Oct 13 10:05:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13420605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DB41CDB483 for ; Fri, 13 Oct 2023 10:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231182AbjJMKGj (ORCPT ); Fri, 13 Oct 2023 06:06:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbjJMKGh (ORCPT ); Fri, 13 Oct 2023 06:06:37 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2082.outbound.protection.outlook.com [40.107.104.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D5FFD6 for ; Fri, 13 Oct 2023 03:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QKwxHT2xt8WIJ9QV//OFH0QEZ6a5ioH8WtewszLNoRQYViKbO4poyJQPms0c7QkeSiUSXEOFb7vt8Y03dQwNkxB60aV6zWKnrL150JKYy0d6U1V7xBeb/ExcQlRxwjUrr5v/YwPWiTdNeolkeyd84TR2h0r9ouaU5wT3eypI9BH+Sg/GvPhYVQj3AtEDCrUS6ZFEOKC6XW546s0H3f/AKDXEL82pLMvBVHFtd2eXxeSjfSBO7DWwWMhMWNBDYVZyGEIB6VxzdUdOtldeU+JZOgpgV7nSCj+Jrqa+6bueLml2ywGL4cd/e6GuONNPg8174dXFQS+N0VKsHHK4uSRrYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=2iwQzgGXnLwyQA/YmSlwyG7Ih/dUeVyOkY/pNqsZeo4=; b=Qf9JiPkZSbXgNRzEK2dlCa8oXzEtIF1sUg0BcfjCm9V4Z0ZUqrQHScOIxAnYFyRLCINVdylmzFt97zOhpjPh1Fex05KsbjBaEc65P9vVNNQ2ZNltFlOMmvVkFId7zO/zudAeztIazKTcTm4BY590spH1byZHgrqFpMbyPXyBi0RPdGnWlUk46tk6s7h052g6y+cKFbRZsVmDNjRp/FSaQAEQEKezG6klUtdW45mF6YNB8kx3ZtpEzs+CboiDl0N7NCKbFG7qdt1V5Pc2d3ASvsKqQOnUp33OWq3c4deAMDfTfAF9dNuu+8Y0zkQjvka6yWgO06YXA4i8XsJmumBGSw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2iwQzgGXnLwyQA/YmSlwyG7Ih/dUeVyOkY/pNqsZeo4=; b=GCR7dsnoRfGPJd2GRAEb8PWIaJ4oag2o1YtJcXTr8qnKf9rnEi6dk+JQqPUkbZgzb0LoAgrmQVJfrOqhr7cSHfKKeRI7n+J6pznnoZcQuWdLZa9bG+7DqqWJD4SwDuH62FRV0WqDdZXlKTRz82DxVhLTS9IkjthDKCeeChJf6gA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by AS8PR04MB9080.eurprd04.prod.outlook.com (2603:10a6:20b:447::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.46; Fri, 13 Oct 2023 10:06:31 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::a53f:4bda:e012:a73d]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::a53f:4bda:e012:a73d%7]) with mapi id 15.20.6863.046; Fri, 13 Oct 2023 10:06:31 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ 2/2] bap: Fix source+sink endpoint registration Date: Fri, 13 Oct 2023 13:05:37 +0300 Message-Id: <20231013100537.3867-3-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231013100537.3867-1-claudia.rosu@nxp.com> References: <20231013100537.3867-1-claudia.rosu@nxp.com> X-ClientProxiedBy: VI1P191CA0010.EURP191.PROD.OUTLOOK.COM (2603:10a6:800:1ba::18) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|AS8PR04MB9080:EE_ X-MS-Office365-Filtering-Correlation-Id: 6eab1099-a14d-4643-da13-08dbcbd412b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iGzt8ruFz8ijsMBucnerxgdGXmAH6Iw/pmnEmU89jxr56c0d+pESICaPDizZ+y0ulc3WfQbkN79O8wrh2Bo75TiMNO5RJSw6TFJuaPSFTr5p9vsQSRFE0Vm2zkdP8g4quuFx7MRPszhvgri5hRAhmv+hVAUV3JrTy+hL6RlUULxr1YoCsUfccWYrw03zgi6wULv35DM92CvgmO6M6c76+WYouwzSXks0YuEwtetTp14+fhqI396ozbn2VdeO9vR7ghHejP/0GkwMq3bHDl3cNE27HrijBcjhKIOXDcCYsafGtndHZU97St9mTA2ObVdLGGm+oQUWWxDw70W1RCz1Kj3r8ohQgfBqFbSdS0nc3VNj+ReGRF6YeFD4bMz1AdipfOmiNNGr84PjSrxvC6EjvY8T97MJILuGaGy17lEhhEpgjyyLt+/qCcipMRnAC/oUmnt0o5G8KdvAPC7ouuLDwdBT/yzlKn1woIXekH1iwPSgMJf+PWHMZjhVjxW05+dI1RP4hgCvuLrxoA30KqHoe08kWnH7h8M6v+NUXkLdbl1MpBSSR84Oy5h2xpLZB91q X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(396003)(366004)(136003)(346002)(39860400002)(230922051799003)(451199024)(186009)(1800799009)(64100799003)(6512007)(6506007)(38100700002)(86362001)(1076003)(2616005)(83380400001)(26005)(8936002)(8676002)(4326008)(2906002)(41300700001)(316002)(6916009)(5660300002)(6486002)(66556008)(66476007)(66946007)(36756003)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PNsETQERsFCEAu2qnjRQ8zELdB0k5JLbskCDfU4AwOwQTXyG7okEY1NBhL1oZN6+VOOaIKADNvnJtOcdm4o6r/W9WFgblvIH2ysFG9UOUhWFu6cq3xE9aY+A5dyDg3Gnwopljbv75Zdatvln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Y1URsdxx/sju7NZhcSESk3Rq8mYp6RplZR5hLZ0hXL17f3FAQ/rMxwiQEYtf5WFYD3jkLn+hBXsDBdXJhPbbGcxviwoe34ejV6PcFn+CJnQj7NwoVglfDRDI+YkkPCddAcvDrQU7Zq9Jxg4VH/lMwb8aszgT+ERqhzGXJoc1+76dL25Vm6y0xSA2yotuWtRPQuZW6iKmzWXw2hIydcwnESvZROXNCohQuQsflgPyEBHz+SpVWj2Fvu+/zPXAaG/B6pRSGoBNeV/wTnz+lxXATpNRdSNb3y9hx2RBSlBo+PlC6Cts0TqySrfcOTZPWuEVNRYutbc4vQ4QJQJtsyPJ/lE2U6MJLh4b/aSxw7J803BZnXzfF1 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6eab1099-a14d-4643-da13-08dbcbd412b0 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 10:06:31.5308 (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: m/aAHtt5HMc7067q527stAAEtqTu7NkQjPU/xUK6b60vXbMtOXZGj6RUgnm1XWMQLo0ZZ+8nEcBc3yHfF5d7TA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9080 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Create new endpoint name for the simulated broadcast sink that is created when registering a broadcast source endpoint. This removes the ambiguity when having registered a local broadcast sink and fixes the situation when multiple remote endpoints are created when discovering a broadcast source. --- profiles/audio/bap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index fa5cf1f54..cdb84d4bd 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1053,6 +1053,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, switch (bt_bap_pac_get_type(rpac)) { case BT_BAP_BCAST_SOURCE: case BT_BAP_BCAST_SINK: + case BT_BAP_SIMULATED_BCAST_SINK: queue = data->bcast; i = queue_length(data->bcast); suffix = "bcast"; @@ -1075,6 +1076,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, switch (bt_bap_pac_get_type(rpac)) { case BT_BAP_BCAST_SINK: + case BT_BAP_SIMULATED_BCAST_SINK: err = asprintf(&ep->path, "%s/pac_%s%d", adapter_get_path(adapter), suffix, i); ep->base = new0(struct iovec, 1); @@ -1266,6 +1268,9 @@ static bool pac_found_bcast(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, DBG("lpac %p rpac %p", lpac, rpac); + if (bt_bap_pac_get_type(lpac) == BT_BAP_SIMULATED_BCAST_SINK) + return true; + ep = ep_register_bcast(user_data, lpac, rpac); if (!ep) { error("Unable to register endpoint for pac %p", rpac); @@ -1792,7 +1797,7 @@ static void bap_listen_io_broadcast(struct bap_data *data, struct bap_ep *ep, error("%s", err->message); g_error_free(err); } - + ep->io = io; ep->data->listen_io = io; } @@ -1958,12 +1963,8 @@ static void pac_added_broadcast(struct bt_bap_pac *pac, void *user_data) { struct bap_data *data = user_data; - if (bt_bap_pac_get_type(pac) == BT_BAP_BCAST_SOURCE) - bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SOURCE, - pac_found_bcast, data); - else if (bt_bap_pac_get_type(pac) == BT_BAP_BCAST_SINK) - bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SINK, - pac_found_bcast, data); + bt_bap_foreach_pac(data->bap, bt_bap_pac_get_type(pac), + pac_found_bcast, data); } static bool ep_match_pac(const void *data, const void *match_data)