From patchwork Fri Nov 15 10:38:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 843602 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2040.outbound.protection.outlook.com [40.107.249.40]) (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 CABC11B3921 for ; Fri, 15 Nov 2024 10:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731667123; cv=fail; b=HScsTXLm0z5eTk2nmszm9C8kSoBomECEntue5rchMzwP3ksdFXEfS8bRQmjKNdBlKurbvg4WCUF8OD4Y6bxFrZjVM2jOwxl/2+7NI8ChqnzSO7RLL9rA/LVy7LoJ5WttU+ABKUjpdQT7+qA0ILakkxbJ27y7DpK6V/rXQ1c9PDs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731667123; c=relaxed/simple; bh=ORIyVquidOZMpGSPVGSBQyLO4+6IqpxPVwrm+cUTi/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=RppZBfjp3OKTo2RQGoDsVJfYStR034V0/gBiHD+uMoZ/BBmTXYuFHBp+asQoBhJrp4kyXp2005niUSY4KPGgjJJy4JEwwNOwO757oSoHI6vDqnovodwGPSUB5EwZcPR1g7mbfI01CBd1jX9Rd1+NsydMs6Qm0/OSO7Js5U7LXLA= 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=jkBHoOWd; arc=fail smtp.client-ip=40.107.249.40 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="jkBHoOWd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RpiapO5frP5KxXM1UtL+ELCmP95bsYjlWhHfa/i52IWdfJ4R+nIov4+O1OdbvyKC6x+98CqRBqf/5O5WIFjLXnf6cn+I+7Owjf3pIMz4zbXG+rpctTBok9gqvwT+NMuvjvSAA0fCn+vc0akq54b5UC0s6ogKCoAbML33yhYSXNhgZfcI10aA4+205pIThjQnQso1nmyox72/G5RvUH8wQwZUm6wwwk9VCoqqSbeadZ0BBypt1jQfIUYa6bCTHPIVgT5kaIqtpRH2fmon73w1tn09+afZwdwEW+bTKVJ4hxBVVyfzSCEv5IqGdO2jMjkQ0XqXf3rMxAn5M3ryD1CBVA== 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=ptKvC9TgbCdy729sgSCIx6PPwcWTvfoKcwCRf2GInT8=; b=nksxLZVDSgemBp894o8uD881kN3bpgexRxFC6Xo2BxjsJbcGY47wGvsty4rpNsiMygkXIgtx0o9/CNfeDA4TEpnGtIXZbvtqH778bfPx23Lja0rh9vOfqp3TQw5/xHK4jx6yC62EFMKUJXvnITRMAYO9MXm/fkGdfBVR4KRC7vLA533VeaPb1QxOTGtycQu4Xi2FU9bEQ6RJXHO7W1gXaNVKBuXCzpTWFt+gXk+kE5LYDHt2tBaQwdf3rEkYd+bZunohroF/c3DHHM11vmjuVoO3yLOltCNx9HnU/3RMgNhw1geE2tRurXFiNTPdyu8doHAiO908IlL9foE/kiVmVQ== 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=ptKvC9TgbCdy729sgSCIx6PPwcWTvfoKcwCRf2GInT8=; b=jkBHoOWd1CCRiZ3nde5s68oKqA/yLzhgVY8JQarTKGMt8lVNMBHIfeW8/NF1Q+BxrUB31CF/ay5NsiaxTi+U4ungXFvFi3taP5G+cvcg/CgBnymUeJa4wjKMnmRqyopxRz+7j4kO0VKlH8I3xCp79gvHIzLhhZh+DTDnnwlmcuNrg/6LAOTJlWLd8GtdRUlVuqED1dGuRbokAn7yQcT6x5Oyzta5CNz55hJc//Ty5d8qFZwPrzPqUP+JJ/NbvnIV3BAvSnY5w8VaRcJJr9QlszuT1f9ErpolZZRCFALhUf+oZOnpmm38W4uAqrTvzAQizJ4MX5kPGFLzvolP9JDTnA== 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 DU2PR04MB8776.eurprd04.prod.outlook.com (2603:10a6:10:2e3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.19; Fri, 15 Nov 2024 10:38:39 +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.8158.017; Fri, 15 Nov 2024 10:38:39 +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 2/6] bap: Make default PA sync QoS public Date: Fri, 15 Nov 2024 12:38:20 +0200 Message-ID: <20241115103825.19761-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241115103825.19761-1-iulia.tanasescu@nxp.com> References: <20241115103825.19761-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P189CA0019.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5db::10) 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_|DU2PR04MB8776:EE_ X-MS-Office365-Filtering-Correlation-Id: 8bd7ee3a-e98e-4fb0-f35d-08dd0561aaa8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: bT/D1O4JRbc39ke5p5uYFlabFRaR0N/HmoNQY/b00w4f3MmjXDLHBlpfo8VHwJU8liPaZbtq3O9zol+8RIn5xjw4BUlXrBuCudjTGRV2toqa2d6tHZvJPqbwddoiUshbf5frQC4X00Lxl7OcFBdJnZMMjLwsGVGHXObF0nvriRGuox/uqfpAuu5Xi6sxBFJHGFvl/66kw1rNi5iyeXo+KBZ8wD1zVKp5d2avml9zw7dDQrx647aIElwhvmRaW5hyLhIOXkn/VzgKJzwZrBZCEgCK95/jUEV9h8eUf9bW19TdYPVOO0S5lONOntpXep3PZ49XvQzTGCUnace+eXs9G6g7HafvGBZRzYtFMTQ/mrAD2gZl36NRB2SlY1x9cD76Q9oxaknw5dr6aPy9A132FvcRIycEhZC0R9vG4nNmyClY5BJD1+EuJAe9Uftd7Wz0W3OBTwfeNYdrLs8fSsj7kRTppdCzhIsjIg/0VhkSyiSDxMGulm60XZrXDm+SyIbmDYZmh/4nfyd2zZVE0Wjap+38TTvhiDiQ3FxVY9Lyol0RG5WY4ZBrQgxap6eCbCCUjfGg2aj3S5wba2zjzv3ZQY2uWChVx8l6xjlbSQ/tTlS4AMy3tBEXhp9LkFMPI3+6p9QcE5qHSfQ0nQBHrkWRjh6T4RdAnX1qBxTJsV2SpGxPI0byHVdL5nk1mB1T8iJMqSIZhtQsToiRUkXwZhq96SkS50MP/4Uks2RGP6fj5ruPtY5OX3+SrNZbB/MuVmebKeOpX00QZs2k2QIqnE0SkOkwzAoE7KDGE+3h1rn5Q2Wldbkv4/bbpwKfQG/ss0d552pHpIt1GsiVrGJEZBa8U0k+mnfivuoabZUc7NTjQv1TC7h63vsMRUlgw0bcq8jmB7WpcW4M/oV56p7pRvAMCHMgnr+x1A74PgdguzSsfR1B2+/gGdScLab6kofotJkrVVCNDACRIZqRsiX5ySebJKMmFg9jKgPNqdt0qgajakJi4tEn4D/LHFDyyPyEgLKCsK6AFAuPabujrFp4U0l3NPj2BGxgdF2bY86mm8an1GSc2dynbaASYNyaJU+hxgEhOM2TMB9gK+PZtkGwFABjpMZgCRMw95B3sMUTa/v7gFaoJZmo6GaHClSerrjymNkx3DSaPZ2G7xIVxxeGwllQCE7UnIMm2uWczjI0pioNGuxKWHGOVGSclD7AVgo5bk2GzEONHfXc++7b79lf6ew5hz0VCxZnQO7U67D/RaeLGAbREpgLA8IpqxZ2Z5aa292VKT2dv9OhfZ9ca514MnQBhC+Fe7msS69b3jZt3949aF9/pQ3ruIpovGsclWiaDIpD 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)(366016)(376014)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 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3LFZuhZueM3XhYZimxisjqmI09awwfDLrdnL/7aH8vkzdUzmWhqe6sRi9dntfZud7sMVxbrTv0EaEL+18PvBR1I9jbhaWFQfs+yAS+UFrEvZEgbO2ldnRZ/dHv9ztEobdMrKyadfMUuKavVKS9gwJdhNPjmv+s1yV3r/Ewxj+A7yu2bSXAGe/e2FoaobgvKztDZwrKhY5J5ivnDg0akFzsT3aOAJG9GmVK4zi5OI3c9yN4MoaGoV3G8pRpeD+GsX/jIxikeW0IUs/oJzi6s8K0Qg4PFFYRhfeqYDerjg7Vz+vAgJmaC2zgPTJTyPS/vClvOGwVKrcr25Ag+kJHTn3sKUsZ+2KEi9y9ZnswAMKNKTayPL5FU07K52PrVG631/YKwCgeADEOtO+Xj3gyNDXPzWAJFi1ERroIiRPpU/rTwg/VLIkiY8DLMivUCTKYpKStf5FqCkG4qmJya4txToSZ39VfMiWM5yU/HyKeWCMFvQztpfs50KMmjf4Bjhqp77zLcdDB+Fbg6/NLPSMZk8FYwufjKslVwpVRdAKFBpfqqCtIYakFENeBDFoxJ3/B5HVg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bd7ee3a-e98e-4fb0-f35d-08dd0561aaa8 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 10:38:39.3570 (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: yXKEBzoQGWNRqbGOqGHiqr90Qptyj8yorWjC0nw1lIH9KCLou7JuscyHIvSNtzgoESUfLLDWPv5ut4LPEVgSWg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8776 This make the default BAP QoS parameters for PA Create Sync public, to be available to other plugins that might need to listen for Broadcasters (like BASS). --- profiles/audio/bap.c | 2 +- profiles/audio/bap.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 98b28f15a..dbea59776 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -150,7 +150,7 @@ static struct queue *adapters; * The full QOS is populated at the time the user selects and endpoint and * configures it using SetConfiguration. */ -static struct bt_iso_qos bap_sink_pa_qos = { +struct bt_iso_qos bap_sink_pa_qos = { .bcast = { .options = 0x00, .skip = 0x0000, diff --git a/profiles/audio/bap.h b/profiles/audio/bap.h index cf2593db8..98bea558c 100644 --- a/profiles/audio/bap.h +++ b/profiles/audio/bap.h @@ -11,6 +11,8 @@ typedef void (*bap_stream_cb_t)(uint8_t bis, uint8_t sgrp, struct iovec *caps, struct iovec *meta, struct bt_iso_qos *qos, void *user_data); +extern struct bt_iso_qos bap_sink_pa_qos; + struct bt_bap *bap_get_session(struct btd_device *device); void bap_scan_delegator_probe(struct btd_device *device); From patchwork Fri Nov 15 10:38:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 843601 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2069.outbound.protection.outlook.com [40.107.103.69]) (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 AEA5918FDDB for ; Fri, 15 Nov 2024 10:38:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731667134; cv=fail; b=BSy0/w/pQSBMjEpfACALbd7DyFK6Fzx0beiIYHKmUDmNNbUOwTUbb662nAaR/F64tIEnX2Dwt8rjfL2yeTb4Ue9lO3t3kRA77vsrRcVtfR7V2O4VNu6P5bQJOUvgbeLwRH/RWXSiZLYJ3qTzLlrI54tb5RNtIMsUmiUOnvgvz6Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731667134; c=relaxed/simple; bh=6sfnvi2UZ0xRsZkgqHHQvSmz09FVKeSj1ApvrOnSEBU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Bq/WmdzlIa+kJMNaMuve7VchMoHl0WBvhdctjy/YksZZ0/+aauApcL+1GJn+yCObQacgbwisdoUxcRpCck5v9U0/kZPhu3FE3piE4Y81n1DbUZx1R9nlHK92Zwjh9+oehhbAu4sLOxYZmx61vhdCzJ/CQvgEHqSHyGHpvAlUv+o= 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=jzK1CXnF; arc=fail smtp.client-ip=40.107.103.69 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="jzK1CXnF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bX0AhwgFpfXPAxCf9gVDJft7n7VeKtcZ3Xh5pPCN0Y9qvr4iNl6euQaFQt67I1gzhGQ1jwkIdJS+uwoV22X0/8wFjdPIs0peN600Aw13P7S5BbV2SAN4E3UC+rV1Uswbv7mDtyw/KYPx9hoiwCMU2YeAldiXXn5ofxpNrBcBOV+WZ/CsKGrqDtgn6NKuPw3Bs5sNvcFjfooTHjqKmF3FIyjzxkiEEAvtRkEGh3sP2KHkxR2xJr9oL7Dx/vFORfHtgg6viQFipI/3vLiOkKxzVfx8s3W+0klV88AUeQ5tDQ/o/sxeLSXLXV48+COzz22vNlC7nl4I0B9JI2agEclrEQ== 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=k4uugzXthhrM3auc+WFqqLF8g8zQF/FpSguKSElC1JU=; b=vxmPTy+Bm7T0pqmpDRVB6JB0K0hTwUu7SO4yvNkOtIMe+k2Z05WO/Kw+B//CViQF07yoyjyJrNgUY0CaUHG2iV+U6QKmEsum+x6RccCqqeON3zvX4WGaV4PSAMDZqNO3bde38ODJuuQlKEj11P9LPMRcniBUNTOlK4Al/rHfIYlBq9AJB9Bt+rtH22vyDOg795xOcWL7Bq3xBTVUq9Tkjx2fJvfak1gRzWZLepN4Db0kkgoBWiA0auGI3hMzq8pYyojklmKgnEkNTX52FGX8+7OEJGzKloTu1i/x+Y5ZBsQrkF9f3N/VTY3HdddewZ+vrsq/SDEthHONgllPvq+LDQ== 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=k4uugzXthhrM3auc+WFqqLF8g8zQF/FpSguKSElC1JU=; b=jzK1CXnFQNKpwVOVcWAKraz27Tur+dcZkI47k70Mz0HWIYwRLQyQmvPuyvIC8xoKjNcpVxveTtvw4AN0TLJRHxVjtBVaHtqCVX6e/iz3w8loWT1mj2pEgWpNSyF9pigrA/E/v+jo1+MoHicCvzypg5NhjpADa7+0Dxm14xKhY+fvMQnwq5nE/zvk/ycxVQDqUwPmA7no/cBaNhI4eOy5yDs5ErvEqoFOfhTPpe3DGfD2pXPEM49wbS6aifX+5YOZtha5J2UwISJfmVzhfobyIhUEYH38T7ClD6t5pa9ECDfmsxB0tRAxe2OZREgeqrQmfaf+R0b2SysqNXYwfFVIjQ== 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 AM9PR04MB7714.eurprd04.prod.outlook.com (2603:10a6:20b:2dd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Fri, 15 Nov 2024 10:38:44 +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.8158.017; Fri, 15 Nov 2024 10:38:44 +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 4/6] bass: Rework Scan Delegator to handle BAP streams Date: Fri, 15 Nov 2024 12:38:22 +0200 Message-ID: <20241115103825.19761-5-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241115103825.19761-1-iulia.tanasescu@nxp.com> References: <20241115103825.19761-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P251CA0006.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:5d2::15) 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_|AM9PR04MB7714:EE_ X-MS-Office365-Filtering-Correlation-Id: db17b700-eb63-4fb4-c0fc-08dd0561ad93 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: grDarMHsC1s30I2iewWu/SGFVdCNHy28eTOueTVb3BAlyqLP1v7bnhg1iIBSw1qQGNzxVZpk7wwCaQAcooVTIBbikXYpzNzHa/MVqjGYdiPRxH6/Z6dxB0sz4YGt0E63AcRlmtLhZ4n2lo4KYMFV+lc7QrkHGCmAV75XAnkOKyktaAbjXd3Vr1/A7GYiOYISJrElCSjXcKXG+GKOV8tG6lU2M3QIsgg0SaVTOMi8PyDYbvwnwPfjC1fQSKQ3f2VyVztylboP8YG5uS+Qxb1jir5GxPNYtnp7gsz2zthcWXLqKBN5KqHQ+hE/dPdsHF81XydO9pa1KPN08b2ThZW79mRIDGjsRUfhtZ6ostJVLoBKnG6Uj2GmXA594lXIll+832ax/1qzi5GdQb7syN9z8moT41ZXeIKriDDccRxIcA8Z/DuvqYSb1tY9bi0d+BSRRg7LT4Uoq5HCZ68a4Nr3VLelt6kJmtW/j4Wvv+orrPzwLsRq8Y8gvQFpqU8Hy/t7PEYbpVIGe9OubVUV5GAlEc69+VckR8zCPo08bUqSvk23elNojhCyP4P5f4GnqToK62VqybbYt48uI3OtRK4hWFKxDUOnthXz6+j6W1/DGhseFNwE/RMvHt9JziKdCvmCHlK1FT0mXPVZSam8lUifPRXbs7zwEtRoSbH7zj2LI4+K5KBuqM9tIpO5N6QoIZ+5IYui5sYLevKJK0ovAOOyv2Qpm9SWJ1t0Xv7kXjsOvZ3uCTuQdhCY6HR1Y2zPcEYFhhERdN8HvOV4l+iBG95LC59QTuQ3cj9Vuda2nDvoXFJbMWGP4aDGEnt8PqvSkOdbMQ78Wk4K2FnMF7NdjIsu+Xaq+tbi9maovvOjzsrPrS3zM6gl6haUCsVA7NFNzOqlhgCEfGGbSgJmpYOjQm5NNFM2TqKTFiTryhiK/bnDmCOV1lhRaM2fA6rs/cpDIzkfcNlC6brwZE8keT+AGprvJExcPwdudYigzFmMRwQ4oVO1u6BcITw0wfZCwusGXFYdxKZ7e/iE2poUPM6hcylxCzxlNUidThCePhCOhSCfx0liXkiB/Y7BcosRWZlhanHXCQRC8QCZkMMNp4hAYplEtw/iGrsVfC2CMCFIOmAF0OsUFY9hIDjjysaYFiHFlWNPZg8m7dfmrH31Bdw3NeXkjh7CtuJI6REBTgMZ8etLHPEMleYZ27hRZ7jFIbUjzL6Q9+fgFf4MNAx/WTgJYHbSr2ZpXPlZW6bpiVmMCMCa8yTPUJ6WPs9GW9/icIOx/WUhQTV0l97ngqoJtF2/y+rD+DcwJfTLKCr2+/2t9B5HsL/UvokanV8VOd9TrzTTLv0d 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)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y/NoeF2Taa7HCCqSHw3SvrdKHitolJTqgAQu2ogwB0KY+SX12o7UUwbQ4N14Oeg7JqGG/I5xCqAv/9kxmpiESlpq3A0eFX+Q3ylQDX9uGZ9P+wcwGR4m44R3/iw9HBNVAX0vqVWBDWMf3wlg20Ulm3T9O28b/M2v3GMDy1b6zLMO9Tj+v2b/lQlbM+yXryInsqxfqoPdG1YeuA3jp58bEVGPxC51DH+xZ+phfIQrHLlAfh7d0ZgrmxeIHfdXO7Xp8SYZPosQAdJ6pm8Y2013xUw88PgnSWUhoEq1UoTF4Ql6VU2k71E4I4zZNPaztcTQrQeRF/aWvW6uIF7oBPVEnDJl5eiqwTaeTsR/SnaRiNvtPbtnqUiF/XKUVR0pQkpRzIghzdmui3tdsfbgJWOA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ak/TRa+kzU5psS5fA2ZyKvnEHyqRAubR2Gwm/mBSs+flgxDM8LVXnD8RsYgqy2K0GXpfw7euqI/JPebcUsl7EHWlzaTChJSuxEZIvESbpR54ZdOHEj42wgciU5OPDjhMW7d/FYamWqLkxyhy68ml/k4BJcQxxYnQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: db17b700-eb63-4fb4-c0fc-08dd0561ad93 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 10:38:44.1702 (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: nJw18SHWkWHW+BrO8hj+HoInh1GLcEdh/ebJNT8HaSo79IsuY2FS2BKkWl+ZipXyQvS+1zHd9blmv29o7aYYOA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7714 This updates the Scan Delegator implementation to be handled internally in BASS: The BASS Server is responsible to handle Write Commands for the Add Source operation by creating long-lived PA sync, parsing the BASE, creating and configuring BAP streams, as well as enabling them. --- profiles/audio/bap.c | 18 ++- profiles/audio/bass.c | 264 ++++++++++++++++++++++++++++++++++++------ profiles/audio/bass.h | 4 +- 3 files changed, 237 insertions(+), 49 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 8635c383d..6e6d68b57 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1125,14 +1125,6 @@ static void bis_handler(uint8_t bis, uint8_t sgrp, struct iovec *caps, bass_add_stream(data->device, meta, caps, qos, sgrp, bis); - if (!bass_check_bis(data->device, bis)) - /* If this Broadcast Sink is acting as a Scan - * Delegator, only attempt to create streams - * for the BISes required by the peer Broadcast - * Assistant. - */ - return; - /* Check if this BIS matches any local PAC */ bt_bap_verify_bis(data->bap, bis, caps, &lpac); @@ -1325,9 +1317,6 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, g_io_channel_shutdown(io, TRUE, NULL); } - /* Notify the BASS plugin about the session. */ - bass_bcast_probe(data->device, data->bap); - /* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities */ @@ -2729,6 +2718,8 @@ static void bap_state_bcast_sink(struct bt_bap_stream *stream, return; setup = bap_find_setup_by_stream(data, stream); + if (!setup) + return; switch (new_state) { case BT_BAP_STREAM_STATE_IDLE: @@ -3276,6 +3267,7 @@ static int bap_bcast_probe(struct btd_service *service) struct bap_bcast_pa_req *req; uint8_t type = BAP_PA_LONG_REQ; struct bap_data *data; + int ret = 0; if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) { error("BAP requires ISO Socket which is not enabled"); @@ -3329,6 +3321,10 @@ static int bap_bcast_probe(struct btd_service *service) bt_bap_set_user_data(data->bap, service); + if (bass_bcast_probe(service, &ret)) + /* Return if probed device was handled inside BASS. */ + return ret; + /* Start the PA timer if it hasn't been started yet */ if (data->adapter->pa_timer_id == 0) data->adapter->pa_timer_id = g_timeout_add_seconds( diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index 6237f5acc..e53241a1a 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -29,6 +29,7 @@ #include "lib/bluetooth.h" #include "lib/uuid.h" +#include "lib/iso.h" #include "src/dbus-common.h" #include "src/shared/util.h" @@ -42,6 +43,7 @@ #include "src/shared/bap.h" #include "src/shared/ad.h" +#include "btio/btio.h" #include "src/plugin.h" #include "src/gatt-database.h" #include "src/device.h" @@ -101,12 +103,16 @@ struct bass_assistant { struct bass_delegator { struct btd_device *device; /* Broadcast source device */ + struct btd_service *service; struct bt_bcast_src *src; struct bt_bap *bap; unsigned int state_id; uint8_t *bcode; unsigned int timeout; struct queue *bcode_reqs; + struct queue *streams; + unsigned int io_id; + GIOChannel *io; }; struct bass_bcode_req { @@ -218,18 +224,58 @@ static bool delegator_match_device(const void *data, const void *match_data) return dg->device == device; } -bool bass_check_bis(struct btd_device *device, uint8_t bis) +static int stream_get_bis(struct bt_bap_stream *stream) { - struct bass_delegator *dg; + char *path = bt_bap_stream_get_user_data(stream); + const char *strbis; + int bis; - dg = queue_find(delegators, delegator_match_device, device); - if (!dg) - return true; + strbis = strstr(path, "/bis"); + if (!strbis) + return 0; - if (!bt_bass_check_bis(dg->src, bis)) - return false; + if (sscanf(strbis, "/bis%d", &bis) < 0) + return 0; - return true; + return bis; +} + +static void append_stream(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + struct sockaddr_iso_bc *addr = user_data; + uint8_t bis = stream_get_bis(stream); + + DBG("%d", bis); + + addr->bc_bis[addr->bc_num_bis] = bis; + addr->bc_num_bis++; +} + +static bool link_io_unset(const void *data, const void *match_data) +{ + struct bt_bap_stream *link = (struct bt_bap_stream *)data; + + return !bt_bap_stream_get_io(link); +} + +static void connect_cb(GIOChannel *io, GError *err, void *user_data) +{ + struct bt_bap_stream *stream = user_data; + struct queue *links = bt_bap_stream_io_get_links(stream); + int fd; + + DBG(""); + + /* Set fds for the stream and all its links. */ + if (bt_bap_stream_get_io(stream)) + stream = queue_find(links, link_io_unset, NULL); + + fd = g_io_channel_unix_get_fd(io); + + if (bt_bap_stream_set_io(stream, fd)) { + g_io_channel_set_close_on_unref(io, FALSE); + } } static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, @@ -237,31 +283,54 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, { struct bass_delegator *dg = user_data; int bis; - char *path = bt_bap_stream_get_user_data(stream); struct bt_bap *bap = bt_bap_stream_get_session(stream); - const char *strbis; - int err; + struct sockaddr_iso_bc iso_bc_addr = {0}; + struct queue *links; + GError *gerr = NULL; + struct bt_bap_qos *bap_qos = bt_bap_stream_get_qos(stream); + struct bt_iso_qos qos; if (dg->bap != bap) return; - strbis = strstr(path, "/bis"); - if (strbis == NULL) { - DBG("bis index cannot be found"); - return; - } - - err = sscanf(strbis, "/bis%d", &bis); - if (err < 0) { - DBG("sscanf error"); - return; - } + bis = stream_get_bis(stream); DBG("stream %p: %s(%u) -> %s(%u)", stream, bt_bap_stream_statestr(old_state), old_state, bt_bap_stream_statestr(new_state), new_state); switch (new_state) { + case BT_BAP_STREAM_STATE_ENABLING: + iso_bc_addr.bc_bdaddr_type = + btd_device_get_bdaddr_type(dg->device); + memcpy(&iso_bc_addr.bc_bdaddr, device_get_address(dg->device), + sizeof(bdaddr_t)); + + append_stream(stream, &iso_bc_addr); + + links = bt_bap_stream_io_get_links(stream); + + queue_foreach(links, append_stream, &iso_bc_addr); + + bap_qos_to_iso_qos(bap_qos, &qos); + + if (!bt_io_set(dg->io, &gerr, + BT_IO_OPT_QOS, &qos, + BT_IO_OPT_INVALID)) { + error("bt_io_set: %s", gerr->message); + g_error_free(gerr); + break; + } + + if (!bt_io_bcast_accept(dg->io, + connect_cb, stream, NULL, &gerr, + BT_IO_OPT_ISO_BC_NUM_BIS, + iso_bc_addr.bc_num_bis, BT_IO_OPT_ISO_BC_BIS, + iso_bc_addr.bc_bis, BT_IO_OPT_INVALID)) { + error("bt_io_bcast_accept: %s", gerr->message); + g_error_free(gerr); + } + break; case BT_BAP_STREAM_STATE_STREAMING: /* BAP stream was started. Mark BIS index as synced inside the * Broadcast Receive State characteristic and notify peers about @@ -280,17 +349,79 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, } } -bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap) +static void bis_handler(uint8_t bis, uint8_t sgrp, struct iovec *caps, + struct iovec *meta, struct bt_iso_qos *qos, void *user_data) { - struct bass_delegator *dg; + struct bass_delegator *dg = user_data; + struct bt_bap_pac *lpac; + char *path; + struct bt_bap_stream *stream; + struct bt_bap_qos bap_qos = {0}; - dg = queue_find(delegators, delegator_match_device, device); - if (!dg) - return false; + /* Only handle streams required by the Brodcast Assistant. */ + if (!bt_bass_check_bis(dg->src, bis)) + return; - DBG("%p", dg); + /* Check if this stream caps match any local PAC */ + bt_bap_verify_bis(dg->bap, bis, caps, &lpac); + if (!lpac) + return; + + if (asprintf(&path, "%s/bis%d", device_get_path(dg->device), bis) < 0) + return; + + bap_iso_qos_to_bap_qos(qos, &bap_qos); + + stream = bt_bap_stream_new(dg->bap, lpac, NULL, &bap_qos, caps); + if (!stream) + return; + + queue_push_tail(dg->streams, stream); + + bt_bap_stream_set_user_data(stream, path); + bt_bap_stream_config(stream, &bap_qos, + caps, NULL, NULL); + bt_bap_stream_metadata(stream, meta, + NULL, NULL); +} + +static gboolean big_info_cb(GIOChannel *io, GIOCondition cond, + gpointer user_data) +{ + struct bass_delegator *dg = user_data; + GError *err = NULL; + struct bt_iso_base base; + struct bt_iso_qos qos; + + dg->io_id = 0; + + bt_io_get(io, &err, + BT_IO_OPT_BASE, &base, + BT_IO_OPT_QOS, &qos, + BT_IO_OPT_INVALID); + if (err) { + error("%s", err->message); + g_error_free(err); + return FALSE; + } + + parse_base(&base, &qos, bass_debug, bis_handler, dg); + + return FALSE; +} + +static void confirm_cb(GIOChannel *io, void *user_data) +{ + struct bass_delegator *dg = user_data; + + DBG(""); - dg->bap = bap; + /* Close the listen io */ + g_io_channel_shutdown(dg->io, TRUE, NULL); + g_io_channel_unref(dg->io); + + g_io_channel_ref(io); + dg->io = io; /* Update Broadcast Receive State characteristic value and notify * peers. @@ -298,15 +429,64 @@ bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap) if (bt_bass_set_pa_sync(dg->src, BT_BASS_SYNCHRONIZED_TO_PA)) DBG("Failed to update Broadcast Receive State characteristic"); - /* Register BAP stream state changed callback, to keep up to - * date with BIG/PA sync state. - */ - dg->state_id = bt_bap_state_register(bap, bap_state_changed, + /* Register BAP stream state changed callback. */ + dg->state_id = bt_bap_state_register(dg->bap, bap_state_changed, NULL, dg, NULL); + dg->io_id = g_io_add_watch(io, G_IO_OUT, big_info_cb, dg); +} + +bool bass_bcast_probe(struct btd_service *service, int *ret) +{ + struct btd_device *device = btd_service_get_device(service); + struct btd_adapter *adapter = device_get_adapter(device); + struct bass_delegator *dg; + GError *err = NULL; + + dg = queue_find(delegators, delegator_match_device, device); + if (!dg) + /* Only probe devices added via Broadcast Assistants */ + return false; + + if (dg->service) { + /* Service has already been probed */ + *ret = -EINVAL; + return true; + } + + dg->service = service; + dg->bap = bap_get_session(device); + + dg->io = bt_io_listen(NULL, confirm_cb, dg, + NULL, &err, + BT_IO_OPT_SOURCE_BDADDR, + btd_adapter_get_address(adapter), + BT_IO_OPT_SOURCE_TYPE, + btd_adapter_get_address_type(adapter), + BT_IO_OPT_DEST_BDADDR, + device_get_address(device), + BT_IO_OPT_DEST_TYPE, + btd_device_get_bdaddr_type(device), + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_QOS, &bap_sink_pa_qos, + BT_IO_OPT_INVALID); + if (!dg->io) { + error("%s", err->message); + *ret = -err->code; + g_error_free(err); + } + return true; } +static void stream_clear(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + struct bass_delegator *dg = user_data; + + bt_bass_clear_bis_sync(dg->src, stream_get_bis(stream)); +} + bool bass_bcast_remove(struct btd_device *device) { struct bass_delegator *dg; @@ -317,6 +497,17 @@ bool bass_bcast_remove(struct btd_device *device) DBG("%p", dg); + if (dg->io_id) + g_source_remove(dg->io_id); + + if (dg->io) { + g_io_channel_shutdown(dg->io, TRUE, NULL); + g_io_channel_unref(dg->io); + } + + queue_foreach(dg->streams, stream_clear, dg); + queue_destroy(dg->streams, NULL); + /* Update Broadcast Receive State characteristic value and notify * peers. */ @@ -895,6 +1086,7 @@ probe: dg->device = device; dg->src = bcast_src; dg->bcode_reqs = queue_new(); + dg->streams = queue_new(); if (!delegators) delegators = queue_new(); @@ -903,8 +1095,10 @@ probe: DBG("delegator %p", dg); - /* Probe device with BAP. */ - bap_scan_delegator_probe(device); + /* Add Broadcast Audio Announcement Service UUID + * to device and probe service. + */ + btd_device_add_uuid(device, BCAAS_UUID_STR); return 0; } diff --git a/profiles/audio/bass.h b/profiles/audio/bass.h index 257346374..f299ac029 100644 --- a/profiles/audio/bass.h +++ b/profiles/audio/bass.h @@ -12,11 +12,9 @@ void bass_add_stream(struct btd_device *device, struct iovec *meta, uint8_t sgrp, uint8_t bis); void bass_remove_stream(struct btd_device *device); -bool bass_bcast_probe(struct btd_device *device, struct bt_bap *bap); +bool bass_bcast_probe(struct btd_service *service, int *ret); bool bass_bcast_remove(struct btd_device *device); -bool bass_check_bis(struct btd_device *device, uint8_t bis); - typedef void (*bt_bass_bcode_func_t)(void *user_data, int err); void bass_req_bcode(struct bt_bap_stream *stream, From patchwork Fri Nov 15 10:38:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 843600 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2069.outbound.protection.outlook.com [40.107.103.69]) (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 8F1891B4F0D for ; Fri, 15 Nov 2024 10:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731667139; cv=fail; b=DIiYuJdqq8jZ9ay1kwdJoJqzdc3oo5pAscqYZlvjnjmDsRgYuH9gdn0ZnZ6bE/iU108ZICvN1BY05laoyAbBLB3zSGsm2TYKVKr9AOZDNTnyt28us3FXJRvK6QF+WQ9MrclFeYtav0NFV0hSN3Zp/reBOLMCY6vbtCfuQ7jvVN0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731667139; c=relaxed/simple; bh=DaEyLzGrhJKD5UOukuCqfbFY+vb5x4iXX3w7Ro/bBnY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=MqPS4KmveurK1XTqN93MaR4KLpHV3f/Wo803niJjJbUWFZvTG2v5V9KCc5rXoYnY3/W01RJ+EU+tbHIDSulLHk01LOLxde52rD3vGvK5I3X+La9h8uH/GG09HuctKOLjQ7xT72VmqK/4lWA0U1ywj0ZoEjJeRLtJ8SDOyO0Hd7A= 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=P625B4xK; arc=fail smtp.client-ip=40.107.103.69 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="P625B4xK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BabBo9f4KUtSE6WG1qKfDavRSL7tspdcRdx65L5dVJ4N9PQJ/zbke3gnF1/ZXy8Smrc6acVczpy55mGXFzbHrC0FoftPdTgdwqWnIVMYF7YcpwJdtocvhug3qVqDgHJTwtE1wG6CCZnRlpgFIvgpG1exmXrQVFf3DiSOHJIAVTJQelTh/gnA0v3OhLlJ3aCWRpl6vekvWfOva+DnUkrjdGmiWJDxXCeOyDIAca67zTZwFYuCGYdy+bZmf+Xu5WpqJyC7lKQP3E8oNk5ClzUNSsa3szAr4+5G/Mr/A5TkM3p/SsJ32DMzqTQTZAbNQwJdigUObnagBvzoNm2cVfzgUw== 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=AyUGRdJgN2J8d/rVi2mbRLQ+UUB/Xe8ctafwKJyA4M4=; b=gZe3osiTqHCgU80Um9U9CUVCGzpC/OeoMvcsJCP8z6PD0qgW/XGB5j/5q/r7K8FWNnAwtL5XSYXi/XZy1KGqzyeC6eu4ziVuJLQyuvG3XZpx0Ckmg4Lua94Jxtre4CqgzzxdfKcf3PpI5+Jy4FQ+Q0/opiDxkmVhN1HjXhepSVK0CASYCJXUw4ePGcW9lkPTA/2CLOOW06MLYK1oqHLL/rIYHuXd4zh0DT2iZNeCI6xvEBD7rlw/LLEz4wV+4+fCKO2YGOytSPd1pb6mrtfcXzOjjVNt4R/2zdbjMHHpj3bD/p5GxdAIq1zTYoswUXeCr4mQBjnSTcB73+Taez2A+Q== 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=AyUGRdJgN2J8d/rVi2mbRLQ+UUB/Xe8ctafwKJyA4M4=; b=P625B4xKxfWGJTpy8HGASpx0oGzh57ZC+RE4+VK4oLb6JorxudbgNqss3aFr4rGqX2zwhD768zHbFfPeFAbQVx8huwL+GguFvYf/hNJc0XidC4rLAducv4Av8XL7jRAAD1GNYrfl/V4DZeDDXvOvF0nUFKdYSnxzngbs2yM5fguMLBeFxzR6Kaq5tpbgBvePg5aizQpFNi84njoTC6djRyzInelxiwURLCfaL3bhLFx9yVXKIu9Qdt9+/J+QsT9L4nUjD4GyDjT8/peQ8mExeHShYhXmuF/6W7W4bhJQ7ylhhpx+NH2v3vAUbWQo6KnWYImuzyT4Nby7g1hjZXSSUg== 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 AM9PR04MB7714.eurprd04.prod.outlook.com (2603:10a6:20b:2dd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Fri, 15 Nov 2024 10:38:51 +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.8158.017; Fri, 15 Nov 2024 10:38:51 +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 6/6] bap: Remove PA idle timer logic Date: Fri, 15 Nov 2024 12:38:24 +0200 Message-ID: <20241115103825.19761-7-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241115103825.19761-1-iulia.tanasescu@nxp.com> References: <20241115103825.19761-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: AS4P195CA0001.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:5e2::8) 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_|AM9PR04MB7714:EE_ X-MS-Office365-Filtering-Correlation-Id: 95c25b06-56b7-4604-6e5f-08dd0561b0f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: GhPiy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MqJhG94DSjJIKSEuKn7sYmzAMwvBLe6nMfVrAa04I/DVYcO/VZ9yoZQaec4qIJzD54F0iqGwc0+ML9cZFzJD7GhsELL1D6rKToelxyqOmNgF7yama+9jHoeyXWaEZs9WSCu3WTgq39Lq5idlviySmGJCddB0US8/uJ/CydofhkzPqNbSb0aZu/8cgL2B7qoLq7tMd4cecE44jURXgMK6/8UcYUt+/oPiTAHEdfhjHpkUeM62XYU4gkAjN6DNQJB207Hco2Px354xPsC/Si4M 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)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tbb6HNU809tkEF/g+nSFboW9DwgQoBbXTjoPBc6Ugb5xuB0IfWf0sGLAfz4x7RgLPx3N4/THdXCEBIwoXaKwt8zlDqdYsR0iGq1V5O2qDaM1B9GJ+JwfiL4LZcRQwvjVnQRz4TWgop9oa9cI4ZAGnNOOVX6li87ObY44Tk3mElEneFCtjSEJNPAh8r7FnrK80c9G25J3yJEHDYYbqzRQQiAmBbL14+Kj3lcb4JgiC2qGlUE6v4v+eEZ2GDs7Ir9HsIkFt23Mq8br0aWCcQxVyUNzT3No+EEd2y+6oL/G6WEe/0QXj5tBHRnQYjkemKJzQpw9q3c3/w0vUEqxBWhs/l2mgpWXKv2XA/etyBrZiks+JfiWNas76mS866vLmHNva2873HfTdjztB8Dn+urMW8kSjv33kn+NIVLmh9Z6uuQzK1A4C1e5UOX1VG9nflCnmxKmefxHOJIDjadanYLwJy2WX6PluytIVH27tEtQ9lfVAm25Plm2gsms/VegjgDhLK2Ql5qEwTHuUM5HeLGFmtn3+kUwQ9/O8PBy5LnCkyHzFel1Nr1WLfZfBl8/eYp2/Hn6uqmgbNQBQZxRg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-4604-6e5f-08dd0561b0f3 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8898.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 10:38:49.8636 (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: Qz6SHmEJn3O7ATS2BI/+l9w9ZhmF7bYVD0h/1+pDCWDcN/N3RjrjGhO3kUgVYZYMNM/4Z2+bbuwUWzx8c0POnQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7714 This removes BAP support for long-lived PA sync (added for Scan Delegator support), since it is now handled inside the BASS plugin. This also removes the PA idle timer logic, since PA/BIG sync requests are now ordered inside the kernel. --- profiles/audio/bap.c | 368 ++++++++++--------------------------------- 1 file changed, 80 insertions(+), 288 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index beab85cff..e927a4404 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -65,15 +65,9 @@ #define MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1" #define MEDIA_INTERFACE "org.bluez.Media1" -/* Periodic advertisments are performed by an idle timer, which, - * at every tick, checks a queue for pending PA requests. - * When there is no pending requests, an item is popped from the - * queue, marked as pending and then it gets processed. - */ -#define PA_IDLE_TIMEOUT 2 - struct bap_setup { struct bap_ep *ep; + struct bap_data *data; struct bt_bap_stream *stream; struct bt_bap_qos qos; int (*qos_parser)(struct bap_setup *setup, const char *key, int var, @@ -101,15 +95,9 @@ struct bap_ep { struct queue *setups; }; -struct bap_adapter { - struct btd_adapter *adapter; - unsigned int pa_timer_id; - struct queue *bcast_pa_requests; -}; - struct bap_data { struct btd_device *device; - struct bap_adapter *adapter; + struct btd_adapter *adapter; struct btd_service *service; struct bt_bap *bap; unsigned int ready_id; @@ -121,30 +109,12 @@ struct bap_data { struct queue *bcast_snks; struct queue *streams; GIOChannel *listen_io; + unsigned int io_id; int selecting; void *user_data; }; -enum { - BAP_PA_SHORT_REQ = 0, /* Request for short PA sync */ - BAP_PA_LONG_REQ, /* Request for long PA sync */ - BAP_PA_BIG_SYNC_REQ, /* Request for PA Sync and BIG Sync */ -}; - -struct bap_bcast_pa_req { - uint8_t type; - bool in_progress; - struct bap_data *bap_data; - union { - struct btd_service *service; - struct queue *setups; - } data; - unsigned int io_id; /* io_id for BIG Info watch */ - GIOChannel *io; -}; - static struct queue *sessions; -static struct queue *adapters; /* Structure holding the parameters for Periodic Advertisement create sync. * The full QOS is populated at the time the user selects and endpoint and @@ -219,6 +189,9 @@ static void bap_data_free(struct bap_data *data) g_io_channel_unref(data->listen_io); } + if (data->io_id) + g_source_remove(data->io_id); + if (data->service) { btd_service_set_user_data(data->service, NULL); bt_bap_set_user_data(data->bap, NULL); @@ -382,7 +355,7 @@ static gboolean get_device(const GDBusPropertyTable *property, const char *path; if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) - path = adapter_get_path(ep->data->adapter->adapter); + path = adapter_get_path(ep->data->adapter); else path = device_get_path(ep->data->device); @@ -996,12 +969,19 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return NULL; } +static bool stream_io_unset(const void *data, const void *user_data) +{ + struct bt_bap_stream *stream = (struct bt_bap_stream *)data; + + return !bt_bap_stream_get_io(stream); +} + 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; + struct bap_setup *setup = user_data; + struct bt_bap_stream *stream = setup->stream; int fd; - struct bap_data *bap_data = req->bap_data; + struct bap_data *bap_data = setup->data; DBG("BIG Sync completed"); @@ -1009,28 +989,23 @@ static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) * to the order of the BISes that were enqueued before * calling bt_io_bcast_accept. */ - setup = queue_pop_head(req->data.setups); - - if (queue_isempty(req->data.setups)) { - /* All fds have been notified. Mark service as connected. */ - btd_service_connecting_complete(bap_data->service, 0); - - 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); - queue_destroy(req->data.setups, NULL); - free(req); - } + if (bt_bap_stream_get_io(stream)) + stream = queue_find(bt_bap_stream_io_get_links(stream), + stream_io_unset, NULL); fd = g_io_channel_unix_get_fd(io); - if (bt_bap_stream_set_io(setup->stream, fd)) { + if (bt_bap_stream_set_io(stream, fd)) g_io_channel_set_close_on_unref(io, FALSE); - return; + + if (!queue_find(bt_bap_stream_io_get_links(stream), + stream_io_unset, NULL)) { + /* All fds have been notified. Mark service as connected. */ + btd_service_connecting_complete(bap_data->service, 0); + + g_io_channel_unref(bap_data->listen_io); + g_io_channel_shutdown(bap_data->listen_io, TRUE, NULL); + bap_data->listen_io = NULL; } } @@ -1099,6 +1074,7 @@ static void create_stream_for_bis(struct bap_data *bap_data, struct bap_setup *setup; setup = setup_new(NULL); + setup->data = bap_data; /* Create BAP QoS structure */ bap_iso_qos_to_bap_qos(qos, &setup->qos); @@ -1280,8 +1256,7 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, gpointer user_data) { GError *err = NULL; - struct bap_bcast_pa_req *req = user_data; - struct bap_data *data = btd_service_get_user_data(req->data.service); + struct bap_data *data = user_data; struct bt_iso_base base; struct bt_iso_qos qos; @@ -1295,7 +1270,7 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, error("%s", err->message); g_error_free(err); g_io_channel_shutdown(io, TRUE, NULL); - req->io_id = 0; + data->io_id = 0; return FALSE; } @@ -1304,41 +1279,31 @@ static gboolean big_info_report_cb(GIOChannel *io, GIOCondition cond, g_io_channel_unref(data->listen_io); data->listen_io = NULL; - if (req->type == BAP_PA_LONG_REQ) { - /* If long-lived PA sync was requested, keep a reference - * to the PA sync io to keep the sync active. - */ - data->listen_io = io; - g_io_channel_ref(io); - } else { - /* For short-lived PA, the sync is no longer needed at - * this point, so the io can be closed. - */ - g_io_channel_shutdown(io, TRUE, NULL); - } + /* For short-lived PA, the sync is no longer needed at + * this point, so the io can be closed. + */ + g_io_channel_shutdown(io, TRUE, NULL); /* Analyze received BASE data and create remote media endpoints for each * BIS matching our capabilities */ parse_base(&base, &qos, bap_debug, bis_handler, data); - service_set_connecting(req->data.service); + service_set_connecting(data->service); - queue_remove(data->adapter->bcast_pa_requests, req); - req->io_id = 0; - free(req); + data->io_id = 0; return FALSE; } static void iso_pa_sync_confirm_cb(GIOChannel *io, void *user_data) { - struct bap_bcast_pa_req *req = user_data; + struct bap_data *data = user_data; /* PA Sync was established, wait for BIG Info report so that the * encryption flag is also available. */ DBG("PA Sync done"); - req->io_id = g_io_add_watch(io, G_IO_OUT, big_info_report_cb, + data->io_id = g_io_add_watch(io, G_IO_OUT, big_info_report_cb, user_data); } @@ -1393,7 +1358,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, struct bt_bap_pac *lpac, struct bt_bap_pac *rpac) { - struct btd_adapter *adapter = data->adapter->adapter; + struct btd_adapter *adapter = data->adapter; struct btd_device *device = data->device; struct bap_ep *ep; struct queue *queue; @@ -2240,95 +2205,13 @@ static void setup_listen_io(struct bap_data *data, struct bt_bap_stream *stream, data->listen_io = io; } -static void check_pa_req_in_progress(void *data, void *user_data) -{ - struct bap_bcast_pa_req *req = data; - - if (req->in_progress == TRUE) - *((bool *)user_data) = TRUE; -} - -static int pa_sync(struct bap_bcast_pa_req *req); -static void pa_and_big_sync(struct bap_bcast_pa_req *req); - -static gboolean pa_idle_timer(gpointer user_data) -{ - struct bap_adapter *adapter = user_data; - struct bap_bcast_pa_req *req; - bool in_progress = FALSE; - - /* Handle timer if no request is in progress */ - queue_foreach(adapter->bcast_pa_requests, check_pa_req_in_progress, - &in_progress); - if (in_progress == FALSE) { - req = queue_peek_head(adapter->bcast_pa_requests); - if (req != NULL) - switch (req->type) { - case BAP_PA_SHORT_REQ: - DBG("do short lived PA Sync"); - pa_sync(req); - break; - case BAP_PA_LONG_REQ: - DBG("do long lived PA Sync"); - pa_sync(req); - break; - case BAP_PA_BIG_SYNC_REQ: - DBG("do PA Sync and BIG Sync"); - pa_and_big_sync(req); - break; - } - else { - /* pa_req queue is empty, stop the timer by returning - * FALSE and set the pa_timer_id to 0. This will later - * be used to check if the timer is active. - */ - adapter->pa_timer_id = 0; - return FALSE; - } - } - - return TRUE; -} +static int pa_sync(struct bap_data *data); +static void pa_and_big_sync(struct bap_setup *setup); static void setup_accept_io_broadcast(struct bap_data *data, struct bap_setup *setup) { - 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 - * can also be treated. - */ - if (adapter->pa_timer_id == 0) - adapter->pa_timer_id = g_timeout_add_seconds(PA_IDLE_TIMEOUT, - pa_idle_timer, - adapter); - - /* Add this request to the PA queue. - * We don't need to check the queue here, as we cannot have - * BAP_PA_BIG_SYNC_REQ before a short PA (BAP_PA_SHORT_REQ) - */ - req->type = BAP_PA_BIG_SYNC_REQ; - req->in_progress = FALSE; - 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); + pa_and_big_sync(setup); } static void setup_create_ucast_io(struct bap_data *data, @@ -3083,10 +2966,8 @@ static void bap_detached(struct bt_bap *bap, void *user_data) bap_data_remove(data); } -static int pa_sync(struct bap_bcast_pa_req *req) +static int pa_sync(struct bap_data *data) { - struct btd_service *service = req->data.service; - struct bap_data *data = btd_service_get_user_data(service); GError *err = NULL; if (data->listen_io) { @@ -3095,13 +2976,13 @@ static int pa_sync(struct bap_bcast_pa_req *req) } DBG("Create PA sync with this source"); - req->in_progress = TRUE; - data->listen_io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, req, + + data->listen_io = bt_io_listen(NULL, iso_pa_sync_confirm_cb, data, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, - btd_adapter_get_address(data->adapter->adapter), + btd_adapter_get_address(data->adapter), BT_IO_OPT_SOURCE_TYPE, - btd_adapter_get_address_type(data->adapter->adapter), + btd_adapter_get_address_type(data->adapter), BT_IO_OPT_DEST_BDADDR, device_get_address(data->device), BT_IO_OPT_DEST_TYPE, @@ -3119,9 +3000,9 @@ static int pa_sync(struct bap_bcast_pa_req *req) static void append_setup(void *data, void *user_data) { - struct bap_setup *setup = data; + struct bt_bap_stream *stream = data; struct sockaddr_iso_bc *addr = user_data; - char *path = bt_bap_stream_get_user_data(setup->stream); + char *path = bt_bap_stream_get_user_data(stream); int bis = 1; int s_err; const char *strbis = NULL; @@ -3146,39 +3027,36 @@ static void append_setup(void *data, void *user_data) static void setup_refresh_qos(void *data, void *user_data) { - struct bap_setup *setup = data; + struct bt_bap_stream *stream = data; + struct bap_data *bap_data = user_data; + struct bap_setup *setup = bap_find_setup_by_stream(bap_data, stream); - setup->qos = *bt_bap_stream_get_qos(setup->stream); + setup->qos = *bt_bap_stream_get_qos(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 bap_setup *setup = user_data; + struct bap_data *data = setup->data; struct sockaddr_iso_bc iso_bc_addr = {0}; struct bt_iso_qos qos; + struct queue *links = bt_bap_stream_io_get_links(setup->stream); 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)); + g_io_channel_unref(data->listen_io); + g_io_channel_shutdown(data->listen_io, TRUE, NULL); + data->listen_io = io; + g_io_channel_ref(data->listen_io); /* Append each linked BIS to the BIG sync request */ - queue_foreach(setups, append_setup, &iso_bc_addr); + append_setup(setup->stream, &iso_bc_addr); + queue_foreach(links, append_setup, &iso_bc_addr); /* Refresh qos stored in setups */ - queue_foreach(setups, setup_refresh_qos, NULL); + setup->qos = *bt_bap_stream_get_qos(setup->stream); + queue_foreach(links, setup_refresh_qos, data); /* Set the user requested QOS */ bap_qos_to_iso_qos(&setup->qos, &qos); @@ -3192,7 +3070,7 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) if (!bt_io_bcast_accept(io, iso_bcast_confirm_cb, - req, NULL, &err, + setup, NULL, &err, BT_IO_OPT_ISO_BC_NUM_BIS, iso_bc_addr.bc_num_bis, BT_IO_OPT_ISO_BC_BIS, iso_bc_addr.bc_bis, BT_IO_OPT_INVALID)) { @@ -3201,28 +3079,16 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) } } -static void pa_and_big_sync(struct bap_bcast_pa_req *req) +static void pa_and_big_sync(struct bap_setup *setup) { GError *err = NULL; - struct bap_data *bap_data = req->bap_data; - - req->in_progress = TRUE; - - if (bap_data->listen_io) { - /* If there is an active listen io for the BAP session - * with the Broadcast Source, it means that PA sync is - * already established. Go straight to establishing BIG - * sync. - */ - iso_do_big_sync(bap_data->listen_io, req); - return; - } + struct bap_data *bap_data = setup->data; DBG("Create PA sync with this source"); - req->io = bt_io_listen(NULL, iso_do_big_sync, req, + bap_data->listen_io = bt_io_listen(NULL, iso_do_big_sync, setup, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, - btd_adapter_get_address(bap_data->adapter->adapter), + btd_adapter_get_address(bap_data->adapter), BT_IO_OPT_DEST_BDADDR, device_get_address(bap_data->device), BT_IO_OPT_DEST_TYPE, @@ -3230,26 +3096,17 @@ 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 (!req->io) { + if (!bap_data->listen_io) { error("%s", err->message); g_error_free(err); } } -static bool match_bap_adapter(const void *data, const void *match_data) -{ - struct bap_adapter *adapter = (struct bap_adapter *)data; - - return adapter->adapter == match_data; -} - static int bap_bcast_probe(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); struct btd_adapter *adapter = device_get_adapter(device); struct btd_gatt_database *database = btd_adapter_get_database(adapter); - struct bap_bcast_pa_req *req; - uint8_t type = BAP_PA_LONG_REQ; struct bap_data *data; int ret = 0; @@ -3258,27 +3115,10 @@ static int bap_bcast_probe(struct btd_service *service) return -ENOTSUP; } - data = queue_find(sessions, match_device, device); - if (data && data->service) { - error("Profile probed twice for the same device!"); - return -EINVAL; - } - - if (!data) { - data = bap_data_new(device); - data->device = device; - bap_data_add(data); - - /* The Broadcaster was scanned autonomously, - * so it should be probed short-lived. - */ - type = BAP_PA_SHORT_REQ; - } - + data = bap_data_new(device); data->service = service; - btd_service_set_user_data(service, data); - - data->adapter = queue_find(adapters, match_bap_adapter, adapter); + data->adapter = adapter; + data->device = device; data->bap = bt_bap_new(btd_gatt_database_get_db(database), btd_gatt_database_get_db(database)); if (!data->bap) { @@ -3286,9 +3126,6 @@ static int bap_bcast_probe(struct btd_service *service) free(data); return -EINVAL; } - - bt_bap_set_debug(data->bap, bap_debug, NULL, NULL); - data->bcast_snks = queue_new(); if (!bt_bap_attach(data->bap, NULL)) { @@ -3296,6 +3133,8 @@ static int bap_bcast_probe(struct btd_service *service) return -EINVAL; } + bap_data_add(data); + data->ready_id = bt_bap_ready_register(data->bap, bap_ready, service, NULL); data->state_id = bt_bap_state_register(data->bap, bap_state_bcast_sink, @@ -3309,36 +3148,15 @@ static int bap_bcast_probe(struct btd_service *service) /* Return if probed device was handled inside BASS. */ return ret; - /* Start the PA timer if it hasn't been started yet */ - if (data->adapter->pa_timer_id == 0) - data->adapter->pa_timer_id = g_timeout_add_seconds( - PA_IDLE_TIMEOUT, - pa_idle_timer, - data->adapter); - - /* Enqueue this device advertisement so that we can create PA sync. */ - DBG("enqueue service: %p", service); - req = new0(struct bap_bcast_pa_req, 1); - req->type = type; - req->in_progress = FALSE; - req->data.service = service; - queue_push_tail(data->adapter->bcast_pa_requests, req); + pa_sync(data); return 0; } -static bool match_service(const void *data, const void *match_data) -{ - struct bap_bcast_pa_req *req = (struct bap_bcast_pa_req *)data; - - return req->data.service == match_data; -} - static void bap_bcast_remove(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); struct bap_data *data; - struct bap_bcast_pa_req *req; char addr[18]; ba2str(device_get_address(device), addr); @@ -3349,17 +3167,6 @@ static void bap_bcast_remove(struct btd_service *service) error("BAP service not handled by profile"); return; } - /* Remove the corresponding entry from the pa_req queue. Any pa_req that - * are in progress will be stopped by bap_data_remove which calls - * bap_data_free. - */ - req = queue_remove_if(data->adapter->bcast_pa_requests, - match_service, service); - if (req && req->io_id) { - g_source_remove(req->io_id); - req->io_id = 0; - } - free(req); /* Notify the BASS plugin about the removed session. */ bass_bcast_remove(device); @@ -3501,13 +3308,7 @@ static int bap_adapter_probe(struct btd_profile *p, struct btd_adapter *adapter) bt_bap_set_user_data(data->bap, adapter); bap_data_set_user_data(data, adapter); - data->adapter = new0(struct bap_adapter, 1); - data->adapter->adapter = adapter; - - if (adapters == NULL) - adapters = queue_new(); - data->adapter->bcast_pa_requests = queue_new(); - queue_push_tail(adapters, data->adapter); + data->adapter = adapter; return 0; } @@ -3522,15 +3323,6 @@ static void bap_adapter_remove(struct btd_profile *p, ba2str(btd_adapter_get_address(adapter), addr); DBG("%s", addr); - queue_destroy(data->adapter->bcast_pa_requests, free); - queue_remove(adapters, data->adapter); - free(data->adapter); - - if (queue_isempty(adapters)) { - queue_destroy(adapters, NULL); - adapters = NULL; - } - if (!data) { error("BAP service not handled by profile"); return;