All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] media: Fix registering PAC endpoints if ISO socket are not supported
Date: Tue, 30 Aug 2022 14:54:44 -0700	[thread overview]
Message-ID: <20220830215444.1141653-1-luiz.dentz@gmail.com> (raw)

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If adapter don't support ISO sockets the PAC UUIDs shall not be allowed
to be registered as they depend on ISO sockets to work properly.
---
 profiles/audio/media.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 85278a6d9be4..a7fa85d60310 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -1254,20 +1254,23 @@ static bool endpoint_properties_get(const char *uuid,
 	return true;
 }
 
-static bool endpoint_supported(void)
+static bool endpoint_supported(struct btd_adapter *adapter)
 {
 	return true;
 }
 
-static bool experimental_endpoint_supported(void)
+static bool experimental_endpoint_supported(struct btd_adapter *adapter)
 {
+	if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET))
+		return false;
+
 	return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL;
 }
 
 static struct media_endpoint_init {
 	const char *uuid;
 	bool (*func)(struct media_endpoint *endpoint, int *err);
-	bool (*supported)(void);
+	bool (*supported)(struct btd_adapter *adapter);
 } init_table[] = {
 	{ A2DP_SOURCE_UUID, endpoint_init_a2dp_source, endpoint_supported },
 	{ A2DP_SINK_UUID, endpoint_init_a2dp_sink, endpoint_supported },
@@ -1315,6 +1318,9 @@ media_endpoint_create(struct media_adapter *adapter,
 	for (i = 0; i < ARRAY_SIZE(init_table); i++) {
 		init = &init_table[i];
 
+		if (!init->supported(adapter->btd_adapter))
+			continue;
+
 		if (!strcasecmp(init->uuid, uuid)) {
 			succeeded = init->func(endpoint, err);
 			break;
@@ -2971,6 +2977,7 @@ static const GDBusMethodTable media_methods[] = {
 static gboolean supported_uuids(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
+	struct media_adapter *adapter = data;
 	DBusMessageIter entry;
 	size_t i;
 
@@ -2980,7 +2987,7 @@ static gboolean supported_uuids(const GDBusPropertyTable *property,
 	for (i = 0; i < ARRAY_SIZE(init_table); i++) {
 		struct media_endpoint_init *init = &init_table[i];
 
-		if (init->supported())
+		if (init->supported(adapter->btd_adapter))
 			dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
 							&init->uuid);
 	}
-- 
2.37.2


             reply	other threads:[~2022-08-30 22:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30 21:54 Luiz Augusto von Dentz [this message]
2022-08-30 23:00 ` [BlueZ] media: Fix registering PAC endpoints if ISO socket are not supported bluez.test.bot
2022-08-31 23:10 ` [PATCH BlueZ] " patchwork-bot+bluetooth

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=20220830215444.1141653-1-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.