From patchwork Mon Jun 19 20:30:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13284934 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 1F6F2EB64D9 for ; Mon, 19 Jun 2023 20:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbjFSUah (ORCPT ); Mon, 19 Jun 2023 16:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbjFSUag (ORCPT ); Mon, 19 Jun 2023 16:30:36 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA089D2 for ; Mon, 19 Jun 2023 13:30:35 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-543d32eed7cso1544649a12.2 for ; Mon, 19 Jun 2023 13:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687206634; x=1689798634; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=cCaOjV86XmCjdxytEUdOthY/SkfDAI0pXNp0TJWsFZ0=; b=DGGoL5mHOpRmiDJ8jdtqtFalK1x7xRgjNS0/0nH95QB/qzGzwUHqn0QyuRkxCEQ3ft UmqxVY0Hr641d3ATXVwpexPMxxfcaG6XHxibV1x54MCoMTG2BpG4xDF0W5NzgPyMtmlK COrAgjq3/wFE38gPO7IW/feSm9ketZhAXAlTxM9jrGy08/VREYxl/2bzHCL7Z4x44mTR iCd5/GkeWBAm8FbEEZnrkSe95Mv2gbO64RgEI+uappJjQP7mFKJKK79NPkAFRtv/GeaW /Dbb8xNupEr7ZTWAG4SfuLPsZG6IBLutTEZjr99i4EQotoaIfIPpHgCZmCOB+HBvXrYY ppLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687206634; x=1689798634; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cCaOjV86XmCjdxytEUdOthY/SkfDAI0pXNp0TJWsFZ0=; b=KEit0AyZkd6MVLpgi6oPFZdTsKfuiTJuckr3lyzIulrR+cWexNnflX87EToyhNKe1C RBwG5iyOedQpFHodnOC0tXReoj7bIVXkH0MKsyuevzmZK/L4VPpQ5SMIzR7NDp5ySDob fnvDatdwk3aDem4uSviriVp0M34yFZc8bxQQGzStxi7LhKwJIRdWlg007KSIG1mOWscH KxWZZOa+RoBGwZOgOwFwvlznOsXZ3zRgE/yT5eyRvWxPzym/CR9gTokoTvhwwHMVo2Nt AJUb+o3EOxXaIEYcGROAN7X+shNGxgwhMpgrTzsQfHFJTIW2jB+d6ynLugvDw/w7+KDS lMcA== X-Gm-Message-State: AC+VfDzWcGSGHDKc0Aby4qdkCK+Nqr/GtV0XB4noFsBSx6fwSxmBMPRW wqN9ImMYRo9lGSEJNYAIJkHbP/YhQu1UsQ== X-Google-Smtp-Source: ACHHUZ6JmLqV0g84lgpZnAjSHSZw1G/iivor9g/PlpCBZm1uj37Yn1igw/QMmyk/5JcdCD0So5zNJw== X-Received: by 2002:a17:902:d4c4:b0:1b5:532e:33a9 with SMTP id o4-20020a170902d4c400b001b5532e33a9mr6496457plg.12.1687206634305; Mon, 19 Jun 2023 13:30:34 -0700 (PDT) Received: from lvondent-mobl3.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id ju18-20020a170903429200b001b045c9ababsm202714plb.264.2023.06.19.13.30.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 13:30:33 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/5] shared/bap: Add unespecified bit in audio context to PAC records Date: Mon, 19 Jun 2023 13:30:28 -0700 Message-Id: <20230619203032.6812-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes sure unespecified bit is properly marked in both audio contexts since that required by many platforms in order to work properly and while doing that add proper defines to the defaults values used in PACS. --- src/shared/bap.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/shared/bap.c b/src/shared/bap.c index 4b31536ee..270f0fd64 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -47,6 +47,14 @@ #define BAP_PROCESS_TIMEOUT 10 +#define PACS_SRC_LOCATION 0x00000001 +#define PACS_SNK_LOCATION 0x00000003 + +#define PACS_SRC_CTXT 0x000f +#define PACS_SUPPORTED_SRC_CTXT PACS_SRC_CTXT +#define PACS_SNK_CTXT 0x0fff +#define PACS_SUPPORTED_SNK_CTXT PACS_SNK_CTXT + struct bt_bap_pac_changed { unsigned int id; bt_bap_pac_func_t added; @@ -467,12 +475,12 @@ static struct bt_pacs *pacs_new(struct gatt_db *db) pacs = new0(struct bt_pacs, 1); /* Set default values */ - pacs->sink_loc_value = 0x00000003; - pacs->source_loc_value = 0x00000001; - pacs->sink_context_value = 0x0fff; - pacs->source_context_value = 0x000e; - pacs->supported_sink_context_value = 0x0fff; - pacs->supported_source_context_value = 0x000e; + pacs->sink_loc_value = PACS_SNK_LOCATION; + pacs->source_loc_value = PACS_SRC_LOCATION; + pacs->sink_context_value = PACS_SNK_CTXT; + pacs->source_context_value = PACS_SRC_CTXT; + pacs->supported_sink_context_value = PACS_SUPPORTED_SNK_CTXT; + pacs->supported_source_context_value = PACS_SUPPORTED_SRC_CTXT; /* Populate DB with PACS attributes */ bt_uuid16_create(&uuid, PACS_UUID); From patchwork Mon Jun 19 20:30:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13284935 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 30980EB64DB for ; Mon, 19 Jun 2023 20:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229895AbjFSUaj (ORCPT ); Mon, 19 Jun 2023 16:30:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbjFSUai (ORCPT ); Mon, 19 Jun 2023 16:30:38 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62783A3 for ; Mon, 19 Jun 2023 13:30:37 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1b5422163f4so23512545ad.2 for ; Mon, 19 Jun 2023 13:30:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687206636; x=1689798636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=T4/mMmUNrSITP62UEH321ZzDfclxkl4F6Eyk2fR6Nzw=; b=M2k9io6Vvf+ajtrw3/ddkQpgJ2mrVel9MYhs5/WPF1kkJueHJ+MYC2YLrj/TN1x2zR iiMR2d8wH/U9ElrRk1HnRWqLF5kKbcUd6Nh4k0TwdEi3ZmmmUG3WoewEOtbt8PhU6/Cb 0mVzhf+a10lhvvuBpZp6fjv+Xntl5U5AIxuvMOgWq89S+T9EG+pEeUnFJ8dYez9S1EUM W7ATgcTLqzAV+U4i6xfbp1wJtmEU7L4lvlwDEA62VfQg+7p6BJD3m/zjXcKVs3yq7nIU bIuQESMni5xGypLBGlEldFyZ+qwH405v8K2sqbgZ7JrIOOXvDWKgoZzS5FihT74liS/l mkeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687206636; x=1689798636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T4/mMmUNrSITP62UEH321ZzDfclxkl4F6Eyk2fR6Nzw=; b=ZdND5gOJ00aBDLhQxHskiTMgBdCaCth2UEqINIhYHj0A+bA0KIoJBvONOhncHMN8Un 9u2Zymuu31jIXi/Nv8GzB92KLvekT9lXhC611taZmBUankuUU09BBCsm+nRYkvY596hx 2En2Oe1p7g8bu1UydMWX7Ydf30CbDbk+sMvXcCMcDnc6bErD6TCpMfl2xaeFs++2cz9f tZ9HFDVvmpxbGYsm7ftwPTxrb2PZi1diLwPKGmhljQMhH4FV9PXqdx5radCaqelxBrfP icBLBxn3Zg7HBOEzvMB4J06tF9qYZa0Kt0+PKMwOaNp/FUpOkGKiBU/B2ZocSJi2Cu7/ 27XA== X-Gm-Message-State: AC+VfDx8U4+zpUVF10aMUs9kIVLpCYs1He5tHFDEtdLyWnuOVKsV5tfP p8F1r5uu0T4aOUhvxgGsiSwe8NbFuXJDAQ== X-Google-Smtp-Source: ACHHUZ6uxJUbxPEOGgwfRmOlLNabhIRr80lhyKkRVlgrLm70lgqYLQ/TS73WboB1FRJ/aUnXC12rJw== X-Received: by 2002:a17:902:c40c:b0:1b5:3aed:b078 with SMTP id k12-20020a170902c40c00b001b53aedb078mr12753380plk.53.1687206636055; Mon, 19 Jun 2023 13:30:36 -0700 (PDT) Received: from lvondent-mobl3.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id ju18-20020a170903429200b001b045c9ababsm202714plb.264.2023.06.19.13.30.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 13:30:34 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 2/5] client: Print integers decimal value Date: Mon, 19 Jun 2023 13:30:29 -0700 Message-Id: <20230619203032.6812-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230619203032.6812-1-luiz.dentz@gmail.com> References: <20230619203032.6812-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This make the code print D-Bus integer iterators also in decimal format in addition to hexadecimal. --- client/print.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/print.c b/client/print.c index 798d22c7e..66439e541 100644 --- a/client/print.c +++ b/client/print.c @@ -127,15 +127,18 @@ void print_iter(const char *label, const char *name, DBusMessageIter *iter) break; case DBUS_TYPE_UINT32: dbus_message_iter_get_basic(iter, &valu32); - bt_shell_printf("%s%s: 0x%08x\n", label, name, valu32); + bt_shell_printf("%s%s: 0x%08x (%d)\n", label, name, valu32, + valu32); break; case DBUS_TYPE_UINT16: dbus_message_iter_get_basic(iter, &valu16); - bt_shell_printf("%s%s: 0x%04x\n", label, name, valu16); + bt_shell_printf("%s%s: 0x%04x (%d)\n", label, name, valu16, + valu16); break; case DBUS_TYPE_INT16: dbus_message_iter_get_basic(iter, &vals16); - bt_shell_printf("%s%s: %d\n", label, name, vals16); + bt_shell_printf("%s%s: 0x%04x (%d)\n", label, name, vals16, + vals16); break; case DBUS_TYPE_BYTE: dbus_message_iter_get_basic(iter, &byte); From patchwork Mon Jun 19 20:30:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13284937 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 52B56EB64D9 for ; Mon, 19 Jun 2023 20:30:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbjFSUal (ORCPT ); Mon, 19 Jun 2023 16:30:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbjFSUak (ORCPT ); Mon, 19 Jun 2023 16:30:40 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 696EDD2 for ; Mon, 19 Jun 2023 13:30:39 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-54fb1bbc3f2so3032365a12.0 for ; Mon, 19 Jun 2023 13:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687206638; x=1689798638; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=W6eZOkmzK1/ccqKHeeqR3SphX0WmkzDV7Brj63U2hL8=; b=pUM6PkTOzqMWiCG1u6o8p0OnxDPBVbVDlBkb/JQD4uZlp5rjBoOb9VBEJkm2AmmfN9 SrWc8Sq10XT5Plby46aYMByGp6HgyouvAGlakeKYa2kcUtS3PdoNFIT6S4weaBAgSkRR 4kw6HBWDG1wmOSPdpRonCBXhW6xkK/j1OwmJVa+VN81TaKj0BkPn991FsuaEuRAjY3IE kRQF4omAUdbbY0vVi2AUvm4wn67hrTM2GoGEhaCZlSRIvJD1djHrGSUimkFF336gzge5 KVlqHBc4wgvsZxp9BqFJFyAMLs2fkwKtpsP3irxxlMfwXByB9QNVjE4L/e0xt10Emtt1 sltQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687206638; x=1689798638; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W6eZOkmzK1/ccqKHeeqR3SphX0WmkzDV7Brj63U2hL8=; b=iwM6VgpKYXGTgB0ArHuXKuQipYIazh+yEIOqEhtN2PhSDTVGYpACF7WcS9Tnj2imGy F6aENL6EXpOA7s4wEJX/hNABNEgHfstDJlH5Y7KgH0gDIbdfiYEJhRD2DFn/Yev1sSRZ w39JUSKEz2bcvnDfMcey+WD6Nz2zZZR3HaoaHHSoLaX8mWpmdJHkobGq0A7b4Gok8c7r nJ2WbPmPo0ZqXyD/WJrivctr8Rxh51adYbYu3Ftnn4NYLVMsyNK/zN607xSPby82uGpl Ys+bIVpjc5gFBX3HuixF7/H7uhhL0qWrAKHYKG1ZJl9d8jS7QOctnImABGgKJxHZhtd4 YNpA== X-Gm-Message-State: AC+VfDyyDFycTj2weojeTbDs6NeoFrMhCcVxhFava24ywU0lfDgmtCzU ab0XzU/B5TI70HJ448ApY5/DP4jtZA+LBg== X-Google-Smtp-Source: ACHHUZ6qejHusaJSZ1dasJ3gfX2MIaGq/GkQdB0DkQnQNUUMgze3cd7vLvqCDCfonM+fvHFBK0csng== X-Received: by 2002:a17:902:8646:b0:1b6:75b5:5fae with SMTP id y6-20020a170902864600b001b675b55faemr1468265plt.42.1687206637811; Mon, 19 Jun 2023 13:30:37 -0700 (PDT) Received: from lvondent-mobl3.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id ju18-20020a170903429200b001b045c9ababsm202714plb.264.2023.06.19.13.30.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 13:30:36 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 3/5] client/player: Fix auto registration of broadcast endpoint Date: Mon, 19 Jun 2023 13:30:30 -0700 Message-Id: <20230619203032.6812-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230619203032.6812-1-luiz.dentz@gmail.com> References: <20230619203032.6812-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz For broadcast endpoint broadcast must be set properly. --- client/player.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/client/player.c b/client/player.c index 389fc1d07..a399d82ec 100644 --- a/client/player.c +++ b/client/player.c @@ -1740,22 +1740,22 @@ struct endpoint_config { 0xa2, 0x65, 0xbb, 0xaf, 0xc6, 0xea, 0x03, 0xb8} static struct bt_iso_qos bcast_qos = { - .bcast = { - .big = BT_ISO_QOS_BIG_UNSET, - .bis = BT_ISO_QOS_BIS_UNSET, - .sync_interval = 0x07, - .packing = 0x00, - .framing = 0x00, - .encryption = 0x00, - .bcode = BCODE, - .options = 0x00, - .skip = 0x0000, - .sync_timeout = 0x4000, - .sync_cte_type = 0x00, - .mse = 0x00, - .timeout = 0x4000, - } - }; + .bcast = { + .big = BT_ISO_QOS_BIG_UNSET, + .bis = BT_ISO_QOS_BIS_UNSET, + .sync_interval = 24, + .packing = 0x00, + .framing = 0x00, + .encryption = 0x00, + .bcode = BCODE, + .options = 0x00, + .skip = 0x0000, + .sync_timeout = 0x4000, + .sync_cte_type = 0x00, + .mse = 0x00, + .timeout = 0x4000, + } +}; static void append_properties(DBusMessageIter *iter, struct endpoint_config *cfg) @@ -3175,6 +3175,7 @@ static struct endpoint *endpoint_new(const struct capabilities *cap) ep = new0(struct endpoint, 1); ep->uuid = g_strdup(cap->uuid); + ep->broadcast = strcmp(cap->uuid, BAA_SERVICE_UUID) ? false : true; ep->codec = cap->codec_id; ep->path = g_strdup_printf("%s/ep%u", BLUEZ_MEDIA_ENDPOINT_PATH, g_list_length(local_endpoints)); From patchwork Mon Jun 19 20:30:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13284936 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 2F6C7EB64DA for ; Mon, 19 Jun 2023 20:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229737AbjFSUao (ORCPT ); Mon, 19 Jun 2023 16:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbjFSUan (ORCPT ); Mon, 19 Jun 2023 16:30:43 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA4E19A for ; Mon, 19 Jun 2023 13:30:41 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1b51414b080so22042185ad.0 for ; Mon, 19 Jun 2023 13:30:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687206640; x=1689798640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=St3BaXvP4+jvWaz6Hdrms1AOT/AAru1J6W/zrvOf/+I=; b=jYxo6fZif5BQqUbJGu5IB1GSjq2uywLxWz5PnddBRxpAwSG+1jL+xzHCUj5cFUNjnX jwB2bncmjs5+iCZpbjv7FuO5SLLrzYK8y6q2D15470rFKzsuH3w7rh0J5trmq2tQMjDK xiCcxdfJrqeKVqCe5VbD4MGb1Nmu0CQuDm/kUN0A7c9r0/EWH6xK+5M1gRgjXZ0YG+Ib lgnQlZEoFeHcUch6ONUOgouo6baj63v6YXQiz935eNGR4+r6ZmBSdUvHMNc2BvUElhno KsX0PJomtpFCuObyQteDpVTqs0DeofTm50b3vVEHGt/Jo7fyFUikh9ALJewG7WLVyuLy PApw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687206640; x=1689798640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=St3BaXvP4+jvWaz6Hdrms1AOT/AAru1J6W/zrvOf/+I=; b=f436bOS8kbPLYUbNUE2OYPsu6GSSSLCDsNpjymSGnXOAGVuQyK5u0KrzSYCcpYsjkd JqdD6F7Ew25DeZ9MIp8toH7PLlrxARijK9STtgahiELJQ306Raq9NCTrRcbGhy++LZ9e zbpq6zJH+MCwTRyj0FFGWWA8CWU+1FDbvohNLI/QQBbNvd1HJXv6wIqbPh4f6bkTabs0 NkVny1CttyvlLiru+oYld3gpdwogTWuJTZUanlg1wV1gC0Q0sCOzC5mTkQcE1aNPoz/y e9oGbmxstEQqeSN4G0HM6VzR6kXyguBwxycBvjzaMcF6dQZOcj1Py9U6K8mrGB4fPUya 3lgA== X-Gm-Message-State: AC+VfDzt5FO/YYw1KvLTOV10ckg/e+LZ/LVQXiWbnBOalRIMfVptm4yy FyP62xOWeFEGsF0TMynYg3iPMYhfW8p4bw== X-Google-Smtp-Source: ACHHUZ7zaMNXhZXnF5np6KYr3+VLtcRYYW+wAKlzoPb9P96brDWFzbPXSv7SVlSoj1Ycc86koZqbtQ== X-Received: by 2002:a17:902:e543:b0:1b1:d51c:f3f6 with SMTP id n3-20020a170902e54300b001b1d51cf3f6mr10857522plf.57.1687206639756; Mon, 19 Jun 2023 13:30:39 -0700 (PDT) Received: from lvondent-mobl3.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id ju18-20020a170903429200b001b045c9ababsm202714plb.264.2023.06.19.13.30.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 13:30:38 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/5] client/player: Fix transport.acquire for linked transports Date: Mon, 19 Jun 2023 13:30:31 -0700 Message-Id: <20230619203032.6812-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230619203032.6812-1-luiz.dentz@gmail.com> References: <20230619203032.6812-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz Linked (bi-directional) transports can be acquired on single D-Bus method call which was not being handled properly by the current code causing unexpected errors. --- client/player.c | 202 +++++++++++++++++++++++++----------------------- 1 file changed, 107 insertions(+), 95 deletions(-) diff --git a/client/player.c b/client/player.c index a399d82ec..d8d632f84 100644 --- a/client/player.c +++ b/client/player.c @@ -72,11 +72,11 @@ struct endpoint { struct iovec *caps; struct iovec *meta; bool auto_accept; - bool acquiring; uint8_t max_transports; uint8_t iso_group; uint8_t iso_stream; - char *transport; + struct queue *acquiring; + struct queue *transports; DBusMessage *msg; struct preset *preset; bool broadcast; @@ -1075,8 +1075,6 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, bt_shell_printf("\tTransport %s\n", path); print_iter("\t", "Properties", &props); - free(ep->transport); - if (!ep->max_transports) { bt_shell_printf("Maximum transports reached: rejecting\n"); return g_dbus_create_error(msg, @@ -1086,7 +1084,10 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, ep->max_transports--; - ep->transport = strdup(path); + if (!ep->transports) + ep->transports = queue_new(); + + queue_push_tail(ep->transports, strdup(path)); if (ep->auto_accept) { bt_shell_printf("Auto Accepting...\n"); @@ -2030,16 +2031,26 @@ static DBusMessage *endpoint_select_properties(DBusConnection *conn, return reply; } +static bool match_str(const void *data, const void *user_data) +{ + return !strcmp(data, user_data); +} + static DBusMessage *endpoint_clear_configuration(DBusConnection *conn, DBusMessage *msg, void *user_data) { struct endpoint *ep = user_data; + DBusMessageIter args; + const char *path; + + dbus_message_iter_init(msg, &args); + + dbus_message_iter_get_basic(&args, &path); if (ep->max_transports != UINT8_MAX) ep->max_transports++; - free(ep->transport); - ep->transport = NULL; + queue_remove_if(ep->transports, match_str, (void *)path); return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); } @@ -2128,6 +2139,9 @@ static void endpoint_free(void *data) free(ep->preset); } + queue_destroy(ep->acquiring, NULL); + queue_destroy(ep->transports, free); + g_free(ep->path); g_free(ep->uuid); g_free(ep); @@ -3431,14 +3445,14 @@ static struct endpoint *find_ep_by_transport(const char *path) for (l = local_endpoints; l; l = g_list_next(l)) { struct endpoint *ep = l->data; - if (ep->transport && !strcmp(ep->transport, path)) + if (queue_find(ep->transports, match_str, path)) return ep; } return NULL; } -static struct endpoint *find_link_by_proxy(GDBusProxy *proxy) +static GDBusProxy *find_link_by_proxy(GDBusProxy *proxy) { DBusMessageIter iter, array; @@ -3450,13 +3464,13 @@ static struct endpoint *find_link_by_proxy(GDBusProxy *proxy) while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_OBJECT_PATH) { const char *transport; - struct endpoint *link; dbus_message_iter_get_basic(&array, &transport); - link = find_ep_by_transport(transport); - if (link) - return link; + proxy = g_dbus_proxy_lookup(transports, NULL, transport, + BLUEZ_MEDIA_TRANSPORT_INTERFACE); + if (proxy) + return proxy; } return NULL; @@ -3543,21 +3557,49 @@ static void transport_new(GDBusProxy *proxy, int sk, uint16_t mtu[2]) queue_push_tail(ios, transport); } +static void ep_set_acquiring(struct endpoint *ep, GDBusProxy *proxy, bool value) +{ + bt_shell_printf("Transport %s %s\n", g_dbus_proxy_get_path(proxy), + value ? "acquiring" : "acquiring complete"); + + if (value && !ep->acquiring) + ep->acquiring = queue_new(); + + if (value) + queue_push_tail(ep->acquiring, proxy); + else + queue_remove(ep->acquiring, proxy); +} + +static void transport_set_acquiring(GDBusProxy *proxy, bool value) +{ + struct endpoint *ep; + GDBusProxy *link; + + ep = find_ep_by_transport(g_dbus_proxy_get_path(proxy)); + if (!ep) + return; + + 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; + + ep_set_acquiring(ep, link, value); + } +} + static void acquire_reply(DBusMessage *message, void *user_data) { GDBusProxy *proxy = user_data; - struct endpoint *ep, *link; DBusError error; int sk; uint16_t mtu[2]; - ep = find_ep_by_transport(g_dbus_proxy_get_path(proxy)); - if (ep) { - ep->acquiring = false; - link = find_link_by_proxy(proxy); - if (link) - link->acquiring = false; - } + transport_set_acquiring(proxy, false); dbus_error_init(&error); @@ -3586,33 +3628,61 @@ static void acquire_reply(DBusMessage *message, void *user_data) return bt_shell_noninteractive_quit(EXIT_FAILURE); } -static void transport_acquire(const char *input, void *user_data) +static void prompt_acquire(const char *input, void *user_data) { GDBusProxy *proxy = user_data; - struct endpoint *ep, *link; if (!strcasecmp(input, "y") || !strcasecmp(input, "yes")) { if (g_dbus_proxy_method_call(proxy, "Acquire", NULL, - acquire_reply, proxy, NULL)) + acquire_reply, proxy, NULL)) { + transport_set_acquiring(proxy, true); return; + } bt_shell_printf("Failed acquire transport\n"); } +} - /* Reset acquiring */ +static void transport_acquire(GDBusProxy *proxy, bool prompt) +{ + struct endpoint *ep; + GDBusProxy *link; + + /* only attempt to acquire if transport is configured with a local + * endpoint. + */ ep = find_ep_by_transport(g_dbus_proxy_get_path(proxy)); - if (ep) { - ep->acquiring = false; - link = find_link_by_proxy(proxy); - if (link) - link->acquiring = false; + 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->auto_accept || !prompt) { + if (!prompt) + bt_shell_printf("auto acquiring...\n"); + if (!g_dbus_proxy_method_call(proxy, "Acquire", NULL, + acquire_reply, proxy, NULL)) { + bt_shell_printf("failed acquire transport\n"); + return; + } + + transport_set_acquiring(proxy, true); + return; } + + bt_shell_prompt_input(g_dbus_proxy_get_path(proxy), "acquire (yes/no):", + prompt_acquire, proxy); } static void transport_property_changed(GDBusProxy *proxy, const char *name, DBusMessageIter *iter) { char *str; - struct endpoint *ep, *link; str = proxy_description(proxy, "Transport", COLORED_CHG); print_iter(str, name, iter); @@ -3626,38 +3696,7 @@ static void transport_property_changed(GDBusProxy *proxy, const char *name, if (strcmp(str, "pending")) return; - /* Only attempt to acquire if transport is configured with a local - * endpoint. - */ - ep = find_ep_by_transport(g_dbus_proxy_get_path(proxy)); - if (!ep || ep->acquiring) - return; - - ep->acquiring = true; - - link = find_link_by_proxy(proxy); - if (link) { - bt_shell_printf("Link %s found\n", link->transport); - /* If link already acquiring wait it to be complete */ - if (link->acquiring) - return; - link->acquiring = true; - } - - if (ep->auto_accept) { - bt_shell_printf("Auto Acquiring...\n"); - if (!g_dbus_proxy_method_call(proxy, "Acquire", NULL, - acquire_reply, proxy, NULL)) { - bt_shell_printf("Failed acquire transport\n"); - ep->acquiring = false; - if (link) - link->acquiring = false; - } - return; - } - - bt_shell_prompt_input(g_dbus_proxy_get_path(proxy), "Acquire (yes/no):", - transport_acquire, proxy); + transport_acquire(proxy, true); } static void property_changed(GDBusProxy *proxy, const char *name, @@ -3747,7 +3786,6 @@ static void cmd_acquire_transport(int argc, char *argv[]) { GDBusProxy *proxy; int i; - struct endpoint *ep, *link; for (i = 1; i < argc; i++) { proxy = g_dbus_proxy_lookup(transports, NULL, argv[i], @@ -3763,35 +3801,7 @@ static void cmd_acquire_transport(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_FAILURE); } - ep = find_ep_by_transport(g_dbus_proxy_get_path(proxy)); - if (!ep || ep->acquiring) { - bt_shell_printf( - "Transport %s already in acquiring process\n", - argv[i]); - return bt_shell_noninteractive_quit(EXIT_FAILURE); - } - - ep->acquiring = true; - - link = find_link_by_proxy(proxy); - if (link) { - bt_shell_printf("Link %s found\n", link->transport); - /* If link already acquiring wait it to be complete */ - if (link->acquiring) { - bt_shell_printf( - "Link %s is in acquiring process\n", - argv[i]); - return bt_shell_noninteractive_quit( - EXIT_FAILURE); - } - link->acquiring = true; - } - - if (!g_dbus_proxy_method_call(proxy, "Acquire", NULL, - acquire_reply, proxy, NULL)) { - bt_shell_printf("Failed acquire transport\n"); - return bt_shell_noninteractive_quit(EXIT_FAILURE); - } + transport_acquire(proxy, false); } return bt_shell_noninteractive_quit(EXIT_SUCCESS); @@ -4076,9 +4086,11 @@ static void cmd_send_transport(int argc, char *argv[]) memset(&qos, 0, sizeof(qos)); len = sizeof(qos); if (getsockopt(transport->sk, SOL_BLUETOOTH, BT_ISO_QOS, &qos, - &len) < 0) + &len) < 0) { + bt_shell_printf("Unable to getsockopt(BT_ISO_QOS): %s", + strerror(errno)); err = transport_send(transport, fd, NULL); - else + } else err = transport_send(transport, fd, &qos); if (err < 0) { From patchwork Mon Jun 19 20:30:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13284938 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 27834EB64DB for ; Mon, 19 Jun 2023 20:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229957AbjFSUap (ORCPT ); Mon, 19 Jun 2023 16:30:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbjFSUao (ORCPT ); Mon, 19 Jun 2023 16:30:44 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C626E4A for ; Mon, 19 Jun 2023 13:30:43 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-52cb8e5e9f5so2465555a12.0 for ; Mon, 19 Jun 2023 13:30:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687206642; x=1689798642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PgesgxoUiEnt7JhH7f+sQVTH/hKqR6THmg+oGF3TcV4=; b=lAhuWM4fk6unp83MvzpBW17Lnxy/Trv/NNl/GQDWAEDIK6ZOW7EQyT1v4nPUuxTJk3 107IcfIufe+ZxLO+sfgoaIALj+PwfpDXw89V/BpwMLTGLGrU2z2kitK2bsqBk/rrQrgt C4Lbsm7zIi0gk7n/rObRELTCoNJuJdpDYxkSmAAgLx7821NQumpmp9ckg0bFlxsLwLoM TSrQS3hx8j5XwRIAAaAyG6rpdDZjo0vagBELEGRXd8mM7pthTG4aCuwjNrboothMGZoA jz4+qSI0yMLSJzccjzSZqCmLGxLBMsOvnMNGI/VR+ysNYDA22Bjfv+wiCuyw5smMofOb +EOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687206642; x=1689798642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PgesgxoUiEnt7JhH7f+sQVTH/hKqR6THmg+oGF3TcV4=; b=NZkb6IaVzIrjDBYQYF0AHiBNchcoYXGf0Z0MsI2MiOx9W4mE1ascN3Famskr8AMh3R ES1Ic1FrJvKZg0obnsyREaLxGK7FmuUV5J7h1xUKEtuFc1saJui960IsO9CWuOyu9xTn LMArgMeniR2GWaNZ6yiJgCwNS57Z+I9kq+Au7Vt7aQ9ByhadO0AM2c+6wzAEp5IYjgK4 jyUl3n8FZTnpN2g+kx9W9V8RJLMu5YnkG+wKVelvebQD1rYA0YnNgQkHnpROct0qdF1Y popOHxjoQrrsHNopH5iE4AwWnMpXVNvYuKLhLr/B5sqXW4YBc1+N0YDVvIhDeF+6xokv 354Q== X-Gm-Message-State: AC+VfDxGknnGNxjvPyJpIYEOTcxR5HBhS2q1mziScoE1IpZxotDVEGwy QOPcgFurcW/QRI9NrAznXrgAtau24AoQww== X-Google-Smtp-Source: ACHHUZ7zNqS+Rs8VRPLAtdgeKcocFYJejfUedl96NBQ3t2EoFOTWVk57E39xrrhEkcJfxxaxk49EZg== X-Received: by 2002:a17:90a:bb09:b0:25e:d6f0:f0a5 with SMTP id u9-20020a17090abb0900b0025ed6f0f0a5mr9231343pjr.19.1687206641711; Mon, 19 Jun 2023 13:30:41 -0700 (PDT) Received: from lvondent-mobl3.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id ju18-20020a170903429200b001b045c9ababsm202714plb.264.2023.06.19.13.30.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 13:30:40 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 5/5] shared/bap: Pass bcode as a reference instead of value Date: Mon, 19 Jun 2023 13:30:32 -0700 Message-Id: <20230619203032.6812-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230619203032.6812-1-luiz.dentz@gmail.com> References: <20230619203032.6812-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes bcode field a pointer which makes it simpler to detect when it is set and also fixes the usage of util_iov_free which expects it to be allocated. --- profiles/audio/bap.c | 12 +++++------- src/shared/bap.h | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index f3564c9e8..8e2fc1556 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -427,12 +427,9 @@ static int parse_properties(DBusMessageIter *props, struct iovec **caps, dbus_message_iter_get_basic(&value, &qos->bcast.timeout); } else if (!strcasecmp(key, "BroadcastCode")) { - struct iovec *iov; - if (var != DBUS_TYPE_ARRAY) goto fail; - iov = &qos->bcast.bcode; - parse_array(&value, &iov); + parse_array(&value, &qos->bcast.bcode); } dbus_message_iter_next(props); @@ -624,7 +621,7 @@ static void ep_free(void *data) util_iov_free(ep->caps, 1); util_iov_free(ep->metadata, 1); if (bt_bap_stream_get_type(ep->stream) == BT_BAP_STREAM_TYPE_BCAST) - util_iov_free(&ep->qos.bcast.bcode, 1); + util_iov_free(ep->qos.bcast.bcode, 1); free(ep->path); free(ep); } @@ -1268,7 +1265,8 @@ static void bap_create_bcast_io(struct bap_data *data, struct bap_ep *ep, iso_qos.bcast.packing = ep->qos.bcast.packing; iso_qos.bcast.framing = ep->qos.bcast.framing; iso_qos.bcast.encryption = ep->qos.bcast.encryption; - memcpy(iso_qos.bcast.bcode, ep->qos.bcast.bcode.iov_base, 16); + if (ep->qos.bcast.bcode) + memcpy(iso_qos.bcast.bcode, ep->qos.bcast.bcode->iov_base, 16); iso_qos.bcast.options = ep->qos.bcast.options; iso_qos.bcast.skip = ep->qos.bcast.skip; iso_qos.bcast.sync_timeout = ep->qos.bcast.sync_timeout; @@ -1811,7 +1809,7 @@ static struct btd_profile bap_profile = { .disconnect = bap_disconnect, .adapter_probe = bap_adapter_probe, .adapter_remove = bap_adapter_remove, - .auto_connect = true, + .auto_connect = false, .experimental = true, }; diff --git a/src/shared/bap.h b/src/shared/bap.h index 8fc41864a..50b567663 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -79,7 +79,7 @@ struct bt_bap_bcast_qos { uint8_t packing; uint8_t framing; uint8_t encryption; - struct iovec bcode; + struct iovec *bcode; uint8_t options; uint16_t skip; uint16_t sync_timeout;