Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp2216030rdb; Sun, 21 Jan 2024 12:27:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHggGFbXzhKS52NFWWPA6x3Xou6dPIFHTaOp9nUTuIB9VSma2tXiylMuVFuPdWFewbTZz0z X-Received: by 2002:a05:6830:2056:b0:6dd:ec89:1e79 with SMTP id f22-20020a056830205600b006ddec891e79mr3716599otp.22.1705868854240; Sun, 21 Jan 2024 12:27:34 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1705868854; cv=pass; d=google.com; s=arc-20160816; b=mOvyx+1g8yxtzSLTDaAqquHDsN9wCtdnjHOqu28mWnmdsGhQi+ABEf0YSEbNcM1aYw xp/Ch7glD8cBXQXGUbNwWTmODHb9kH8mSmqcLPUvEFrsZYRUDFNyXV5o1sRIVWutO2n3 S/dRmbMNO9xqAbMHFrQvleXrJbAe2oZHb1pGm1GJLaiccbmMFvglK/SoXyE1t0qrpwRc r+ElhNOD6uqB2jYvFfOXZS9rOYvsgDWYvokCAyRSi3jrvW41AF//DQoLhVvoZV3rEfNU ThLO1K42CRmC/IUpdVAKmn95a6VEPr5yr/+0kXdvREcNtR2aqBArvr8ag/r3/nr+esW/ DgUg== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=i1c5Zrs0aoB4BTBRuJnjGsTLsmWcJnKOcaUe7WoUgUM=; fh=ExGhjNQEFJgRqHmYATVc5UXZbS7abAmaHDitrfHKOuE=; b=GrRLml4QXEVo2otf2KXmMehS0rfpcjlGbOIygHFs5D/DF4t3jHirGZ872o9ohXWDNv YyTQLLhVfpyAcs1I4ffxPfdfqQ1WiGMANeIpqkSEy8CJMFADu39wMdgg0DHWuVWWIj2S raGkRVumzQW2mazGGSRt4NwpLKXP80aRBQ/OhzXPYvU5qneBLUccynKA+7gBdDxm5qhn pfOJZwA+yRyxg4S8BbnX2C1XuURWLNo7oNrPXgGSjAFn8vI9t7XcbS/u3vhCucXm+sNQ wMLBKJMBAP2VdMckZGPsTePomcPcZvAgvK2+9Paa+dbiROpzGpd6gJTLM3T7tEWi2zZP Q28Q== ARC-Authentication-Results: i=3; mx.google.com; dkim=fail header.i=@iki.fi header.s=meesny header.b=lnr+rKWH; arc=pass (i=2 spf=pass spfdomain=iki.fi); spf=pass (google.com: domain of linux-bluetooth+bounces-1215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1215-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jw2-20020a056a00928200b006dbe36273c6si358407pfb.264.2024.01.21.12.27.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 12:27:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-1215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=fail header.i=@iki.fi header.s=meesny header.b=lnr+rKWH; arc=pass (i=2 spf=pass spfdomain=iki.fi); spf=pass (google.com: domain of linux-bluetooth+bounces-1215-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-1215-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 44FB9281D24 for ; Sun, 21 Jan 2024 20:27:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2C65383A6; Sun, 21 Jan 2024 20:27:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=iki.fi header.i=@iki.fi header.b="lnr+rKWH" X-Original-To: linux-bluetooth@vger.kernel.org Received: from meesny.iki.fi (meesny.iki.fi [195.140.195.201]) (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 0C35838DE2 for ; Sun, 21 Jan 2024 20:27:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=195.140.195.201 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705868849; cv=pass; b=LlCgYoB72dCHc71tl1AEDIWvMDt0z+w9o9aDN1hMnTZqQjA4Qv3Pb65yJsFSmnozH0CVt3/+J0hrJPSakBV6ndd/ET1mHH0cDqPyMGkPf+sN2YXQjxtaxq+kS7LFJ4gPaBOudh5+Ov+J3ivdVFdapVpK+xOahJ2wfeWN326zZAI= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705868849; c=relaxed/simple; bh=4fWVwnWG/4Tavpeco9/zAQJAzLZpa6iP5Sn2kHmw4m8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=X3L1AsoWcOmmsBMJq1BAQdiVqkzD6nrjWdHISL1t2vGG0S7WAAfHM2FgNMXcwDjpUpZZqCtI6sHysoVIqp0U6tCjbzWQCmDEPjpeClyJ899I98YrsceuU97CzeI8sBbKjMgMCf7akFO3KKw9bVstd+3S0f85L1bIDTLIOFunGq0= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi; spf=pass smtp.mailfrom=iki.fi; dkim=fail (1024-bit key) header.d=iki.fi header.i=@iki.fi header.b=lnr+rKWH reason="signature verification failed"; arc=pass smtp.client-ip=195.140.195.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iki.fi Received: from monolith.lan (unknown [193.138.7.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by meesny.iki.fi (Postfix) with ESMTPSA id 4TJ4dt3gcRzyNX; Sun, 21 Jan 2024 22:27:14 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1705868835; h=from:from:from:from:from:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=i1c5Zrs0aoB4BTBRuJnjGsTLsmWcJnKOcaUe7WoUgUM=; b=lnr+rKWHrOgy4uh24RdR31PCHivYRc+7MuP919dzy6IJRVPqOJ0qiwRe0YjoIE79/LBkmI 9YWaVP4quB7bDgqeZNLbxmTPCs2eQ+jKFD6xdo4d3qRTW3weH9C2fSGMGmInIAu48GSash dQ+oM6Ba3O+w+iI/nX/u2DfISJ5dMCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1705868835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=i1c5Zrs0aoB4BTBRuJnjGsTLsmWcJnKOcaUe7WoUgUM=; b=Nlx6wHzH48wopBt4QmE7tDT5cLOpm3qCeD3fmNn7dK91kzfoRBkLL+6pEOEKbJvQceh4z7 loJ2bPjQ9utqJwLcbxT8HIJNhBxkCmQ8EpgZQ3L4U/owUMR72X3sHOOjA23zXiisGk8lCq /NqTxreloivNwX/+SoRbUXhnLhQbGZ4= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1705868835; a=rsa-sha256; cv=none; b=hSwtq7gXmck8xu3w9t9/gW8WYMn8M74xC3tWeeD2FmQtwue6f32EM0zC3SQcSfymjjUxN7 DMKxA+iZFRau9VxcRkaX88qdncRCHHXAC5WKsXlKZWUUvv3Dc7XWmW9ZkNIpjBIAjNNWX0 dq9+aQdo93WdJHrWXEtsuuT0IOyekEs= From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ] bap: register all endpoints before starting config select Date: Sun, 21 Jan 2024 22:27:06 +0200 Message-ID: <447a1b2f472b1c0c83de357e1c8094eec73308f0.1705868192.git.pav@iki.fi> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Register all BAP endpoints first, so that they all become visible in DBus before we start calling SelectProperties() on them. This allows sound servers to know ahead of time what capabilities the device has, and plan the configuration. For example, a sound server might select different configuration for sink+source configurations as opposed to sink or source only, due to bandwidth etc. concerns. --- profiles/audio/bap.c | 48 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 69e982832..8d44e48fe 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1285,7 +1285,7 @@ done: queue_foreach(ep->data->bcast, bap_config, NULL); } -static bool pac_found(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, +static bool pac_register(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, void *user_data) { struct btd_service *service = user_data; @@ -1294,8 +1294,35 @@ static bool pac_found(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, DBG("lpac %p rpac %p", lpac, rpac); ep = ep_register(service, lpac, rpac); - if (!ep) { + if (!ep) error("Unable to register endpoint for pac %p", rpac); + + return true; +} + +static bool pac_select(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, + void *user_data) +{ + struct btd_service *service = user_data; + struct bap_data *data = btd_service_get_user_data(service); + struct match_ep match = { lpac, rpac }; + struct queue *queue; + struct bap_ep *ep; + + switch (bt_bap_pac_get_type(rpac)) { + case BT_BAP_SINK: + queue = data->snks; + break; + case BT_BAP_SOURCE: + queue = data->srcs; + break; + default: + return true; + } + + ep = queue_find(queue, match_ep, &match); + if (!ep) { + error("Unable to find endpoint for pac %p", rpac); return true; } @@ -1328,8 +1355,14 @@ static void bap_ready(struct bt_bap *bap, void *user_data) DBG("bap %p", bap); - bt_bap_foreach_pac(bap, BT_BAP_SOURCE, pac_found, service); - bt_bap_foreach_pac(bap, BT_BAP_SINK, pac_found, service); + /* Register all ep before selecting, so that sound server + * knows all. + */ + bt_bap_foreach_pac(bap, BT_BAP_SOURCE, pac_register, service); + bt_bap_foreach_pac(bap, BT_BAP_SINK, pac_register, service); + + bt_bap_foreach_pac(bap, BT_BAP_SOURCE, pac_select, service); + bt_bap_foreach_pac(bap, BT_BAP_SINK, pac_select, service); } static bool match_setup_stream(const void *data, const void *user_data) @@ -2044,8 +2077,11 @@ static void pac_added(struct bt_bap_pac *pac, void *user_data) data = btd_service_get_user_data(service); - bt_bap_foreach_pac(data->bap, BT_BAP_SOURCE, pac_found, service); - bt_bap_foreach_pac(data->bap, BT_BAP_SINK, pac_found, service); + bt_bap_foreach_pac(data->bap, BT_BAP_SOURCE, pac_register, service); + bt_bap_foreach_pac(data->bap, BT_BAP_SINK, pac_register, service); + + bt_bap_foreach_pac(data->bap, BT_BAP_SOURCE, pac_select, service); + bt_bap_foreach_pac(data->bap, BT_BAP_SINK, pac_select, service); } static void pac_added_broadcast(struct bt_bap_pac *pac, void *user_data) -- 2.43.0