Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp874948rwe; Fri, 26 Aug 2022 17:07:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR7+Q9O+pQ7q5Fkdq+u4tQLKQC4DkUSZG8vvl9KSRz3KEJ1JJniZSIl3jfFgWZyAkxFfXPaB X-Received: by 2002:a17:906:8442:b0:73d:a2fc:a87 with SMTP id e2-20020a170906844200b0073da2fc0a87mr6754544ejy.625.1661558845630; Fri, 26 Aug 2022 17:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661558845; cv=none; d=google.com; s=arc-20160816; b=ct6vSn3TQaT+zdURNBek9qO5A7c7NOnnqS/vTdytQIGYknk9ElKTWOxyRIq/jdxmOu JwN2O2ILf5rawE6D/DaDGoAjOu2burhrfub7yHI7BDS1i9dBsX9RB2VId4sgQ3u5Igc5 oN2xh/JW5VrmVz8fovxvB+JpduYsVAiPtEyCC6EHe1Z6JJNNnRq/d0RA5CzSvO62i9tK erDJ7X+AtjALEX501aSyg3sOc7zxwPhcDwa89OkT4FnAB3thGtI26KHzQ24a6J3wNBJH 0mTOvKweUabFLyiHvKkdxqNd1f8NJjXAGYJxiLmaaOSi7xxv9lZZcGCuP6hucC8G/Lnz kzbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=OewMMH2FhTMDlAG1e4dJh9VaKQQF/YVhC1cCT3PeBg8=; b=X7pkqq4JqYdpYJeAxY+/3f1KZL4gMtRk1M3vpQrPb/VeUbwckKC5SfU3JMfDd4phx7 3mGEf+mErHDd0Nhi+qDC6Pexxc1rlXY7I6AWbyMp/u3QQrDHDrEIVyH7w9e+KccZpYZD OMc6pBkjlHlrMLz0Yrg5QkzbZgqHHnKDkHF3Tka6VSSy0PrQ6f58yyK5pr9DKDTe5wiu V+/buKvT6gEXZE6VqNSNcs3BfKy9dZ1TW24pLzf4FppQlU55Vn7/b2d1rrBV2f4qQjpL 0Nj/hOxYUmDt3JmKg3oz5Fmtai6B1FyBW33InPrkA/ICb3gB++UKq+YuxQI/ezuue6e5 KbVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FwbS5Ffx; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a056402254900b00446512358d5si2646253edb.377.2022.08.26.17.06.59; Fri, 26 Aug 2022 17:07:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FwbS5Ffx; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345131AbiH0AGC (ORCPT + 99 others); Fri, 26 Aug 2022 20:06:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345111AbiH0AF7 (ORCPT ); Fri, 26 Aug 2022 20:05:59 -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 136F2E8337 for ; Fri, 26 Aug 2022 17:05:57 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id y1so1031259plb.2 for ; Fri, 26 Aug 2022 17:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc; bh=OewMMH2FhTMDlAG1e4dJh9VaKQQF/YVhC1cCT3PeBg8=; b=FwbS5FfxBJeXPqU+BpdMLFYjyhhzAPkqAiid5GolgEluI2GHOzsq0ve+KIdw17mSTD MoGcx7AihUUUo1HBkROBerHQJtuvsQbRtVw9eGyUwWInQtwX0ekdcOEUhvrNMZWkosal ltAn02/vA/beTe6+jR6No3gltTf/Q8bjL5KBX0TWr/eEqiVLv+gqfkAxvbQH3HnA7b78 iZWItAkGyzv4m4rG727dXEiHfz8DNioC5DL1MiltJjkmghHW++1hU7OZnqOiYHesoipJ 6IGkuDK0GN6Fa/VsBlEj1jG/8G6fQgaqDQkPiNVBesGMhnR+71uKffJQoMXoQ+yC9svU 1w1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=OewMMH2FhTMDlAG1e4dJh9VaKQQF/YVhC1cCT3PeBg8=; b=4nkXqK6qFGFcXPNNSe9dk1ullacxF3ngR+dos2+TvLAKDe3g/rQEPAmQYU/PyOont2 9UZyPWbHNtkaHYVq1eLm9a6mVAS1Nf3JJ8eNIKMXlmO7nKE1SwOCKS0MnbuuwZZcVz1j 06yXZ74vMXMuRXTPthkDxMGfC22lPEKd1zuPk6gZ4YLcpwEhlAW7qjiEV5NyP10ltIMF 7LD5SZv5NwIs0MJ6Nt7oEX7DYnG8CjPuDM255SzSBEnUrZVRP+kbciQtUHZoWzbtVPlj VYPfSbwNvHMHjTnRK+EY4ZG0qOnQ76dqdkurf93Ma19k+WFkY/5F2BdUdRJu0ejWFmYn t0ng== X-Gm-Message-State: ACgBeo1Tu3fZBCnZstM8g30vBGqV27JJhKZoMOr2Sro/kWkZq8//pOoP ydNawvfnMeGvsoVD66lrVZwWBVQjqCM= X-Received: by 2002:a17:90b:3149:b0:1fb:71ad:256b with SMTP id ip9-20020a17090b314900b001fb71ad256bmr6735949pjb.18.1661558756164; Fri, 26 Aug 2022 17:05:56 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id o1-20020a17090a168100b001fa8b909ef0sm2249487pja.7.2022.08.26.17.05.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 17:05:55 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v3 10/11] profiles: Allow linked transport to release the fd Date: Fri, 26 Aug 2022 17:05:39 -0700 Message-Id: <20220827000540.113414-11-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220827000540.113414-1-luiz.dentz@gmail.com> References: <20220827000540.113414-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Frédéric Danis Multiple transports can be linked when using LE Audio BAP. In this case only one transport is used to Acquire the file descriptor which will be shared by all linked transports. In the same way, any transport can Release the file descriptor. --- profiles/audio/transport.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 47db2a8026b2..f36e609cbd7a 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -281,9 +281,26 @@ static void media_owner_free(struct media_owner *owner) g_free(owner); } +static void linked_transport_remove_owner(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + struct media_owner *owner = user_data; + struct media_transport *transport; + + transport = find_transport_by_bap_stream(stream); + if (!transport) { + error("Unable to find transport"); + return; + } + + DBG("Transport %s Owner %s", transport->path, owner->name); + transport->owner = NULL; +} + static void media_transport_remove_owner(struct media_transport *transport) { struct media_owner *owner = transport->owner; + struct bap_transport *bap = transport->data; if (!transport->owner) return; @@ -295,6 +312,9 @@ static void media_transport_remove_owner(struct media_transport *transport) media_request_reply(owner->pending, EIO); transport->owner = NULL; + if (bap->linked) + queue_foreach(bt_bap_stream_io_get_links(bap->stream), + linked_transport_remove_owner, owner); if (owner->watch) g_dbus_remove_watch(btd_get_dbus_connection(), owner->watch); @@ -452,11 +472,34 @@ static void media_owner_exit(DBusConnection *connection, void *user_data) media_transport_remove_owner(owner->transport); } +static void linked_transport_set_owner(void *data, void *user_data) +{ + struct bt_bap_stream *stream = data; + struct media_owner *owner = user_data; + struct media_transport *transport; + + transport = find_transport_by_bap_stream(stream); + if (!transport) { + error("Unable to find transport"); + return; + } + + DBG("Transport %s Owner %s", transport->path, owner->name); + transport->owner = owner; +} + static void media_transport_set_owner(struct media_transport *transport, struct media_owner *owner) { + struct bap_transport *bap = transport->data; + DBG("Transport %s Owner %s", transport->path, owner->name); transport->owner = owner; + + if (bap->linked) + queue_foreach(bt_bap_stream_io_get_links(bap->stream), + linked_transport_set_owner, owner); + owner->transport = transport; owner->watch = g_dbus_add_disconnect_watch(btd_get_dbus_connection(), owner->name, -- 2.37.2