From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1] client: Fix transport.acquire auto not working as initiator
Date: Tue, 2 Dec 2025 15:18:10 -0500 [thread overview]
Message-ID: <20251202201810.2022976-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Transports configured as client/initiator do not transit to
State:pending since that is used to indicate that a stream has been
configured and has to be accepted, when acting as initiator role
SelectProperties/SelectConfiguration can used to indicate that
endpoint stream configuration has been initiated locally so use that
to mark endpoint to auto configure if that has been set.
---
client/player.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/client/player.c b/client/player.c
index 121c64f0a8d4..b6b02a0001b8 100644
--- a/client/player.c
+++ b/client/player.c
@@ -112,10 +112,13 @@ struct endpoint {
uint16_t supported_context;
uint16_t context;
bool auto_accept;
+ bool auto_acquire;
uint8_t max_transports;
uint8_t iso_group;
uint8_t iso_stream;
struct queue *acquiring;
+ struct queue *auto_acquiring;
+ unsigned int auto_acquiring_id;
struct queue *selecting;
unsigned int selecting_id;
struct queue *transports;
@@ -1170,6 +1173,51 @@ static void ep_set_selecting(struct endpoint *ep, const char *path)
NULL);
}
+static void transport_acquire(GDBusProxy *proxy, bool prompt);
+
+static bool ep_auto_acquiring_process(void *user_data)
+{
+ struct endpoint *ep = user_data;
+ const struct queue_entry *entry;
+
+ ep->auto_acquiring_id = 0;
+
+ if (queue_isempty(ep->auto_acquiring))
+ return true;
+
+ for (entry = queue_get_entries(ep->auto_acquiring); entry;
+ entry = entry->next) {
+ GDBusProxy *proxy;
+
+ proxy = g_dbus_proxy_lookup(transports, NULL, entry->data,
+ BLUEZ_MEDIA_TRANSPORT_INTERFACE);
+ if (!proxy)
+ continue;
+
+ transport_acquire(proxy, false);
+ }
+
+ queue_destroy(ep->auto_acquiring, NULL);
+ ep->auto_acquiring = NULL;
+
+ return true;
+}
+
+static void ep_set_auto_acquiring(struct endpoint *ep, const char *path)
+{
+ bt_shell_printf("Transport %s auto acquiring\n", path);
+
+ if (!ep->auto_acquiring)
+ ep->auto_acquiring = queue_new();
+
+ queue_push_tail(ep->auto_acquiring, strdup(path));
+
+ if (!ep->auto_acquiring_id)
+ ep->auto_acquiring_id = timeout_add(1000,
+ ep_auto_acquiring_process,
+ ep, NULL);
+}
+
static DBusMessage *endpoint_set_configuration(DBusConnection *conn,
DBusMessage *msg, void *user_data)
{
@@ -1209,6 +1257,8 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn,
if (ep->auto_accept) {
if (auto_select && ep->broadcast)
ep_set_selecting(ep, path);
+ else if (ep->auto_acquire && !ep->broadcast)
+ ep_set_auto_acquiring(ep, path);
bt_shell_printf("Auto Accepting...\n");
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
@@ -1815,6 +1865,11 @@ static DBusMessage *endpoint_select_configuration(DBusConnection *conn,
bt_shell_printf("Auto Accepting using %s...\n", p->name);
+ /* Mark auto_acquire if set so the transport is acquired upon
+ * SetConfiguration.
+ */
+ ep->auto_acquire = auto_acquire;
+
return reply;
}
@@ -2264,6 +2319,11 @@ static DBusMessage *endpoint_select_properties(DBusConnection *conn,
if (!reply)
return NULL;
+ /* Mark auto_acquire if set so the transport is acquired upon
+ * SetConfiguration.
+ */
+ ep->auto_acquire = auto_acquire;
+
return reply;
}
@@ -3015,8 +3075,10 @@ static void endpoint_free(void *data)
free(ep->preset);
timeout_remove(ep->selecting_id);
+ timeout_remove(ep->auto_acquiring_id);
queue_destroy(ep->acquiring, NULL);
+ queue_destroy(ep->auto_acquiring, free);
queue_destroy(ep->selecting, free);
queue_destroy(ep->transports, free);
--
2.52.0
next reply other threads:[~2025-12-02 20:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 20:18 Luiz Augusto von Dentz [this message]
2025-12-02 21:13 ` [BlueZ,v1] client: Fix transport.acquire auto not working as initiator bluez.test.bot
2025-12-04 16:00 ` [PATCH BlueZ v1] " 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=20251202201810.2022976-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox