public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1 1/2] client/player: Add 'auto' option to transport.acquire
@ 2025-10-14 19:48 Luiz Augusto von Dentz
  2025-10-14 19:48 ` [PATCH BlueZ v1 2/2] client/player: Add 'auto' option to transport.select Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2025-10-14 19:48 UTC (permalink / raw)
  To: linux-bluetooth

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

This enables transport.acquire auto which enables to overwrite the
default behavior of prompting when endpoint is registering without
setting auto accept.
---
 client/player.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/client/player.c b/client/player.c
index a8d05cf175c9..4f8293ce7842 100644
--- a/client/player.c
+++ b/client/player.c
@@ -134,6 +134,7 @@ static GList *local_endpoints = NULL;
 static GList *transports = NULL;
 static struct queue *ios = NULL;
 static uint8_t bcast_code[] = BCAST_CODE;
+static bool auto_acquire = false;
 
 struct transport {
 	GDBusProxy *proxy;
@@ -5072,10 +5073,8 @@ static void transport_property_changed(GDBusProxy *proxy, const char *name,
 
 	dbus_message_iter_get_basic(iter, &str);
 
-	if (strcmp(str, "pending"))
-		return;
-
-	transport_acquire(proxy, true);
+	if (!strcmp(str, "pending") || !strcmp(str, "broadcasting"))
+		transport_acquire(proxy, !auto_acquire);
 }
 
 static void property_changed(GDBusProxy *proxy, const char *name,
@@ -5224,6 +5223,11 @@ static void cmd_acquire_transport(int argc, char *argv[])
 	GDBusProxy *proxy;
 	int i;
 
+	if (argc == 2 && !strcmp(argv[1], "auto")) {
+		auto_acquire = true;
+		return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+	}
+
 	for (i = 1; i < argc; i++) {
 		proxy = g_dbus_proxy_lookup(transports, NULL, argv[i],
 					BLUEZ_MEDIA_TRANSPORT_INTERFACE);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH BlueZ v1 2/2] client/player: Add 'auto' option to transport.select
  2025-10-14 19:48 [PATCH BlueZ v1 1/2] client/player: Add 'auto' option to transport.acquire Luiz Augusto von Dentz
@ 2025-10-14 19:48 ` Luiz Augusto von Dentz
  2025-10-14 21:15 ` [BlueZ,v1,1/2] client/player: Add 'auto' option to transport.acquire bluez.test.bot
  2025-10-14 22:30 ` [PATCH BlueZ v1 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2025-10-14 19:48 UTC (permalink / raw)
  To: linux-bluetooth

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

This enables transport.select auto which enables to auto select the
broadcast transport configured with the local endpoints, the selecting
process will also dealt with linking the transport so it needs a timer
that waits all transports to be configure to then start linking and
finally select.
---
 client/player.c | 98 ++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 85 insertions(+), 13 deletions(-)

diff --git a/client/player.c b/client/player.c
index 4f8293ce7842..54fcbb7601c0 100644
--- a/client/player.c
+++ b/client/player.c
@@ -43,6 +43,7 @@
 #include "src/shared/shell.h"
 #include "src/shared/io.h"
 #include "src/shared/queue.h"
+#include "src/shared/timeout.h"
 #include "src/shared/bap-debug.h"
 #include "print.h"
 #include "player.h"
@@ -115,6 +116,8 @@ struct endpoint {
 	uint8_t iso_group;
 	uint8_t iso_stream;
 	struct queue *acquiring;
+	struct queue *selecting;
+	unsigned int selecting_id;
 	struct queue *transports;
 	DBusMessage *msg;
 	struct preset *preset;
@@ -135,6 +138,7 @@ static GList *transports = NULL;
 static struct queue *ios = NULL;
 static uint8_t bcast_code[] = BCAST_CODE;
 static bool auto_acquire = false;
+static bool auto_select = false;
 
 struct transport {
 	GDBusProxy *proxy;
@@ -1096,6 +1100,76 @@ static void confirm_response(const char *input, void *user_data)
 									NULL);
 }
 
+static bool match_proxy(const void *data, const void *user_data)
+{
+	const struct transport *transport = data;
+	const GDBusProxy *proxy = user_data;
+
+	return transport->proxy == proxy;
+}
+
+static struct transport *find_transport(GDBusProxy *proxy)
+{
+	return queue_find(ios, match_proxy, proxy);
+}
+
+static bool ep_selecting_process(void *user_data)
+{
+	struct endpoint *ep = user_data;
+	struct transport_select_args *args;
+	const struct queue_entry *entry;
+
+	if (queue_isempty(ep->selecting))
+		return true;
+
+	args = g_new0(struct transport_select_args, 1);
+
+	for (entry = queue_get_entries(ep->selecting); entry;
+					entry = entry->next) {
+		GDBusProxy *link;
+
+		link = g_dbus_proxy_lookup(transports, NULL, entry->data,
+					BLUEZ_MEDIA_TRANSPORT_INTERFACE);
+		if (!link)
+			continue;
+
+		if (find_transport(link))
+			continue;
+
+		if (!args->proxy) {
+			args->proxy = link;
+			continue;
+		}
+
+		if (!args->links)
+			args->links = queue_new();
+
+		/* Enqueue all links */
+		queue_push_tail(args->links, link);
+	}
+
+	queue_destroy(ep->selecting, NULL);
+	ep->selecting = NULL;
+
+	transport_set_links(args);
+
+	return true;
+}
+
+static void ep_set_selecting(struct endpoint *ep, const char *path)
+{
+	bt_shell_printf("Transport %s selecting\n", path);
+
+	if (!ep->selecting)
+		ep->selecting = queue_new();
+
+	queue_push_tail(ep->selecting, strdup(path));
+
+	if (!ep->selecting_id)
+		ep->selecting_id = timeout_add(1000, ep_selecting_process, ep,
+						NULL);
+}
+
 static DBusMessage *endpoint_set_configuration(DBusConnection *conn,
 					DBusMessage *msg, void *user_data)
 {
@@ -1133,6 +1207,9 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn,
 	queue_push_tail(ep->transports, strdup(path));
 
 	if (ep->auto_accept) {
+		if (auto_select && ep->broadcast)
+			ep_set_selecting(ep, path);
+
 		bt_shell_printf("Auto Accepting...\n");
 		return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 	}
@@ -2936,7 +3013,10 @@ static void endpoint_free(void *data)
 	if (ep->codec == 0xff)
 		free(ep->preset);
 
+	timeout_remove(ep->selecting_id);
+
 	queue_destroy(ep->acquiring, NULL);
+	queue_destroy(ep->selecting, free);
 	queue_destroy(ep->transports, free);
 
 	g_free(ep->path);
@@ -5205,19 +5285,6 @@ static void cmd_show_transport(int argc, char *argv[])
 	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
 }
 
-static bool match_proxy(const void *data, const void *user_data)
-{
-	const struct transport *transport = data;
-	const GDBusProxy *proxy = user_data;
-
-	return transport->proxy == proxy;
-}
-
-static struct transport *find_transport(GDBusProxy *proxy)
-{
-	return queue_find(ios, match_proxy, proxy);
-}
-
 static void cmd_acquire_transport(int argc, char *argv[])
 {
 	GDBusProxy *proxy;
@@ -5446,6 +5513,11 @@ static void cmd_select_transport(int argc, char *argv[])
 	struct transport_select_args *args;
 	int i;
 
+	if (argc == 2 && !strcmp(argv[1], "auto")) {
+		auto_select = true;
+		return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+	}
+
 	args = g_new0(struct transport_select_args, 1);
 
 	for (i = 1; i < argc; i++) {
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [BlueZ,v1,1/2] client/player: Add 'auto' option to transport.acquire
  2025-10-14 19:48 [PATCH BlueZ v1 1/2] client/player: Add 'auto' option to transport.acquire Luiz Augusto von Dentz
  2025-10-14 19:48 ` [PATCH BlueZ v1 2/2] client/player: Add 'auto' option to transport.select Luiz Augusto von Dentz
@ 2025-10-14 21:15 ` bluez.test.bot
  2025-10-14 22:30 ` [PATCH BlueZ v1 1/2] " patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2025-10-14 21:15 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1262 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1011502

---Test result---

Test Summary:
CheckPatch                    PENDING   0.26 seconds
GitLint                       PENDING   0.33 seconds
BuildEll                      PASS      20.14 seconds
BluezMake                     PASS      2768.37 seconds
MakeCheck                     PASS      20.77 seconds
MakeDistcheck                 PASS      187.02 seconds
CheckValgrind                 PASS      240.32 seconds
CheckSmatch                   PASS      313.96 seconds
bluezmakeextell               PASS      129.24 seconds
IncrementalBuild              PENDING   0.29 seconds
ScanBuild                     PASS      925.07 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH BlueZ v1 1/2] client/player: Add 'auto' option to transport.acquire
  2025-10-14 19:48 [PATCH BlueZ v1 1/2] client/player: Add 'auto' option to transport.acquire Luiz Augusto von Dentz
  2025-10-14 19:48 ` [PATCH BlueZ v1 2/2] client/player: Add 'auto' option to transport.select Luiz Augusto von Dentz
  2025-10-14 21:15 ` [BlueZ,v1,1/2] client/player: Add 'auto' option to transport.acquire bluez.test.bot
@ 2025-10-14 22:30 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2025-10-14 22:30 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 14 Oct 2025 15:48:54 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This enables transport.acquire auto which enables to overwrite the
> default behavior of prompting when endpoint is registering without
> setting auto accept.
> ---
>  client/player.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)

Here is the summary with links:
  - [BlueZ,v1,1/2] client/player: Add 'auto' option to transport.acquire
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fb183b2805ee
  - [BlueZ,v1,2/2] client/player: Add 'auto' option to transport.select
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5d2616a70c5e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-14 22:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-14 19:48 [PATCH BlueZ v1 1/2] client/player: Add 'auto' option to transport.acquire Luiz Augusto von Dentz
2025-10-14 19:48 ` [PATCH BlueZ v1 2/2] client/player: Add 'auto' option to transport.select Luiz Augusto von Dentz
2025-10-14 21:15 ` [BlueZ,v1,1/2] client/player: Add 'auto' option to transport.acquire bluez.test.bot
2025-10-14 22:30 ` [PATCH BlueZ v1 1/2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox