linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Howard Chung <howardchung@google.com>
To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com
Cc: Howard Chung <howardchung@google.com>,
	Miao-chen Chou <mcchou@chromium.org>
Subject: [Bluez PATCH v1 06/14] audio: Remove Media1 interface when a2dp source disallowed
Date: Thu,  8 Jul 2021 14:23:06 +0800	[thread overview]
Message-ID: <20210708142059.Bluez.v1.6.I123189fa93aad2c2d1be645d38dbc494aa15563c@changeid> (raw)
In-Reply-To: <20210708062314.245754-1-howardchung@google.com>

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 <mcchou@chromium.org>
---
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


  parent reply	other threads:[~2021-07-08  6:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08  6:23 [Bluez PATCH v1 00/14] Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 01/14] lib: add hash functions for bt_uuid_t Howard Chung
2021-07-08  6:36   ` [Bluez,v1,01/14] " bluez.test.bot
2021-07-09  5:21   ` [Bluez PATCH v1 01/14] " Luiz Augusto von Dentz
2021-07-12  3:20     ` Yun-hao Chung
2021-07-08  6:23 ` [Bluez PATCH v1 02/14] unit: add uuid unit tests Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 03/14] core: add is_allowed property in btd_service Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 04/14] core: add adapter and device allowed_uuid functions Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 05/14] core: add device state and state callbacks Howard Chung
2021-07-09  5:34   ` Luiz Augusto von Dentz
2021-07-12  3:56     ` Yun-hao Chung
2021-07-08  6:23 ` Howard Chung [this message]
2021-07-09  5:49   ` [Bluez PATCH v1 06/14] audio: Remove Media1 interface when a2dp source disallowed Luiz Augusto von Dentz
2021-07-12  8:16     ` Yun-hao Chung
2021-07-12 16:37       ` Luiz Augusto von Dentz
2021-07-08  6:23 ` [Bluez PATCH v1 07/14] plugins: add a new plugin for admin_policy Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 08/14] plugins/admin_policy: add admin_policy adapter driver Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 09/14] plugins/admin_policy: add ServiceAllowList method Howard Chung
2021-07-09  6:01   ` Luiz Augusto von Dentz
2021-07-12  9:09     ` Yun-hao Chung
2021-07-12 16:41       ` Luiz Augusto von Dentz
2021-07-08  6:23 ` [Bluez PATCH v1 10/14] plugins/admin_policy: add ServiceAllowList property Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 11/14] plugins/admin_policy: add device state callback Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 12/14] plugins/admin_policy: add AffectedByPolicy property Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 13/14] plugins/admin_policy: persist policy settings Howard Chung
2021-07-08  6:23 ` [Bluez PATCH v1 14/14] core: fix a possible crash when removing devices Howard Chung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210708142059.Bluez.v1.6.I123189fa93aad2c2d1be645d38dbc494aa15563c@changeid \
    --to=howardchung@google.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=mcchou@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).