Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp170158pxv; Wed, 7 Jul 2021 23:25:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz126tQOptplDttKOyiagnRAF1DtqclW70zW9AYi+jsbrP8qSwo74eam4bl5YdEGZzopp62 X-Received: by 2002:a17:906:b204:: with SMTP id p4mr589603ejz.239.1625725550220; Wed, 07 Jul 2021 23:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625725550; cv=none; d=google.com; s=arc-20160816; b=QZLnnZMwdfDpJR6WqJL7f/gV//obItYoWIkExjVJ7+a6eRsWfZKhL5d6H2V84jd52P ECQv2QKCEMuZioEMkWZNuGKq5vKjK6HwTkLvHIKWtCi/SxpJ/1Ptk+sFCgq2vTTHwfLr vytvY9qqoDMytCZrtMqDAA+9XMA3P2xwzXUUYY/KeFW7cxCXIECluRkhLSPrnCmYq1PN Qvt7hOJHUUMQUw78PPgGKmv4LzzJkxZv0k/j1GrnHKcqHaqRT5HBMVK7LrHlzKlmZqG7 i+Pq/x0ZSm2HNFNSRuIPZLFGgP3Bx/xcmPnuLxb98AoJQK5YcVxMemfcg3AHm6K1YXiS 8nQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=aOqA8U5BHV+P1I3p5Zk/+AMkeiZJOsUk1qheCnJv3iU=; b=En0bZtMca/sC/i7VHD+nStM8f42nFhgQ6g64csXOdOS9T+nSrbcB0IKOLEM6WVG8Rj JR5E1T61elVwNyuWykFdgl0UoDIJhzZvPKrFVtoX7v4PHWA8hfAq1hGCcbUYIFDjkhXQ OdWv28J9BwSuqf16jDad0ebm6+teRHX44Hhuh5Xu1HEYGCHNeHh2Qib+Cdi8mClvKfVN ikCL1/XYvQy48tEAfWCcGebXTa2QxBDoJLu5c8ZEerWpecTgv+6T0BVCz9H3ZhFmM6IA fJMenaEbYZMpUW6Y6NqM2WpyJQw6kaIpx0oclDjQmx4u0PtQuV0WXE7XcsiceCANwYqZ rY0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ztz7RQ0z; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a18si2032661edr.24.2021.07.07.23.24.51; Wed, 07 Jul 2021 23:25:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ztz7RQ0z; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbhGHG01 (ORCPT + 99 others); Thu, 8 Jul 2021 02:26:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbhGHG01 (ORCPT ); Thu, 8 Jul 2021 02:26:27 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8C4C061574 for ; Wed, 7 Jul 2021 23:23:46 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id y35-20020a0cb8a30000b0290270c2da88e8so3369976qvf.13 for ; Wed, 07 Jul 2021 23:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=aOqA8U5BHV+P1I3p5Zk/+AMkeiZJOsUk1qheCnJv3iU=; b=Ztz7RQ0zfm73o30rz29q3wGXZEcjU+jNzJ9LPUgN3iDDlflEm8AZaxuByBmZY2FOQ5 nDPVElfXKP0P+vukODyFYj2cycGu4MAoDMsqLNbTCnWdggsLkl3jnuhgWMDo/eCyR9Pk kjT1CG4RWk8OVbGUZdyx7+PRGEVXRsVmdw7UDij5ig70RJWlyXFNXbavo2kkh/uEpQ9W vJEJoIwzf0bxluP964LYNI3EfaOT1DGhohI0N/8fQRa/UpQg49+p6FvHX8mqZljuS+nj 10WJyXbw9NHR+E6sW3OPVSGtdn10fvZUGHplkC3CgoV+Zm2ySveYwyRXovB+nwkTxdaU HXUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=aOqA8U5BHV+P1I3p5Zk/+AMkeiZJOsUk1qheCnJv3iU=; b=jAuNWojqPG6CyvpnkTh987U+t25t0JV+PL01RrTD7HhIduLqh61xDwe4cd3ecqaMvi 4XMQwImInXdxTNhFY/Ysboak5oqH0KkGQqoE0/PgFDwyNB04AH+faT08ALz+DBy4vx2y 8v9WP+yl39xSXXroIhxzHE3MUJ5pEHHqp7zcOhvctO15EAykSmqiWAZI65M3zdgLtmDF BShHG3xZZCzF+mEaGJGD7eiRhCWCUXzs37gsOABUTwVjyF/KI17l4B928E/jcBkvAflS uVj5mhw2j/U3G3iiIjcAO6y0hMg6put9BkWdzih0ph3wd4oH1uv30PFzNOq8CHgJh9uy rJgQ== X-Gm-Message-State: AOAM530+pt3EIG/FCzZX1DoLvGgpdEpWMjxy9oGZr0/UllJx9SBVqoDT xChpHDUpcc19C7LWxIjzsQA1jLtQoRTX8R5R3ZvORtcw+gc0YkZry/5g+zFDQUiJolWIjeKcvhx M8807/Qoxv28szHLMS9kW/WTVrxGoG5KrOwDabTMnvzgs7POriqsQIrTFqhyxLuoQUqZk9VIQ+D MANsMV36kmh5Q= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:de70:7033:67f7:8d0b]) (user=howardchung job=sendgmr) by 2002:ad4:538c:: with SMTP id i12mr28407230qvv.51.1625725425227; Wed, 07 Jul 2021 23:23:45 -0700 (PDT) Date: Thu, 8 Jul 2021 14:23:06 +0800 In-Reply-To: <20210708062314.245754-1-howardchung@google.com> Message-Id: <20210708142059.Bluez.v1.6.I123189fa93aad2c2d1be645d38dbc494aa15563c@changeid> Mime-Version: 1.0 References: <20210708062314.245754-1-howardchung@google.com> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog Subject: [Bluez PATCH v1 06/14] audio: Remove Media1 interface when a2dp source disallowed From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Cc: Howard Chung , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When A2DP source profile is removed from adapter, a2dp_server and everything inside the object will be removed, which also releases all MediaEndpoints and MediaPlayer. When A2DP source profile is re-added, although a2dp_server will be created, clients are not able to know they can register their endpoints and player by then. This patch handles this case by unregistering Media1 interface when we remove a2dp_server, and register it back when a2dp_source is allowed. Reviewed-by: Miao-chen Chou --- perform following steps 1. SetServiceAllowList to empty list 2. pair with an LE headset, then turn off the headset 3. SetServiceAllowList to "0x1234" 4. SetServiceAllowList to empty list 5. turn on the headset and check if it is reconnected. profiles/audio/a2dp.c | 2 ++ profiles/audio/avrcp.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c index d31ed845cbe7..26d4f365207e 100644 --- a/profiles/audio/a2dp.c +++ b/profiles/audio/a2dp.c @@ -3275,6 +3275,7 @@ static int a2dp_source_server_probe(struct btd_profile *p, { struct a2dp_server *server; + media_register(adapter); DBG("path %s", adapter_get_path(adapter)); server = find_server(servers, adapter); @@ -3315,6 +3316,7 @@ static void a2dp_source_server_remove(struct btd_profile *p, return; a2dp_server_unregister(server); + media_unregister(adapter); } static int a2dp_sink_server_probe(struct btd_profile *p, diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index ccf34b2207a9..997a5be9a0f4 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -4751,6 +4751,8 @@ static void avrcp_controller_server_remove(struct btd_profile *p, if (server->tg_record_id == 0) avrcp_server_unregister(server); + + media_unregister(adapter); } static int avrcp_controller_server_probe(struct btd_profile *p, @@ -4761,6 +4763,7 @@ static int avrcp_controller_server_probe(struct btd_profile *p, DBG("path %s", adapter_get_path(adapter)); + media_register(adapter); server = find_server(servers, adapter); if (server != NULL) goto done; -- 2.32.0.93.g670b81a890-goog