diff mbox series

[BlueZ,v3,1/5] player: Add reconfiguration prompt for broadcast source

Message ID 20240315150158.79715-2-silviu.barbulescu@nxp.com (mailing list archive)
State Superseded
Headers show
Series Broadcast source reconfiguration support | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS

Commit Message

Silviu Florian Barbulescu March 15, 2024, 3:01 p.m. UTC
endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 48_4_1
[/local/endpoint/ep0] BIS Index for reconfiguration? (value(1-31)/no): n
[/local/endpoint/ep0] BIG (auto/value): 0
[/local/endpoint/ep0] Enter channel location (value/no): 1
[/local/endpoint/ep0] Enter Metadata (value/no): n
---
 client/player.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

Comments

Guilherme Giacomo Simoes March 15, 2024, 4:41 p.m. UTC | #1
I am sorry if what I say is wrong... but for me, the label done is unnecessary.

+static void endpoint_is_reconfigure_cfg(const char *input, void *user_data)
+{
+       struct endpoint_config *cfg = user_data;
+       int value;
+       char *endptr = NULL;
+
+       if (!strcasecmp(input, "n") || !strcasecmp(input, "no")) {
+               cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
/// this command "goto done" is unnecessary, because if the if()
statement is executed
///the else is not execute, and the chunk of code, that the label done
coverage, go to execute
+               goto done;
+       } else {
+               value = strtol(input, &endptr, 0);
+
+               if (!endptr || *endptr != '\0' || value > UINT8_MAX) {
+                       bt_shell_printf("Invalid argument: %s\n", input);
+                       return bt_shell_noninteractive_quit(EXIT_FAILURE);
+               }
+
+               if (value == 0x0)
+                       cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
+               else
+                       cfg->ep->iso_stream = value;
+       }
+
/// this label done, is unnecessary, because if the if() executes, the
else does not execute.
/// then, the chunk that the label done is include, already execute
without "goto done;"
+done:
+       bt_shell_prompt_input(cfg->ep->path,
+               "BIG (auto/value):",
+               config_endpoint_iso_group, cfg);
+}


this chunk of code, can rrepalced for this:
+static void endpoint_is_reconfigure_cfg(const char *input, void *user_data)
+{
+       struct endpoint_config *cfg = user_data;
+       int value;
+       char *endptr = NULL;
+
+       if (!strcasecmp(input, "n") || !strcasecmp(input, "no"))
+               cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
+       else {
+               value = strtol(input, &endptr, 0);
+
+               if (!endptr || *endptr != '\0' || value > UINT8_MAX) {
+                       bt_shell_printf("Invalid argument: %s\n", input);
+                       return bt_shell_noninteractive_quit(EXIT_FAILURE);
+               }
+
+               if (value == 0x0)
+                       cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
+               else
+                       cfg->ep->iso_stream = value;
+       }
+
+       bt_shell_prompt_input(cfg->ep->path,
+               "BIG (auto/value):",
+               config_endpoint_iso_group, cfg);
+}
+


Em sex., 15 de mar. de 2024 às 12:02, Silviu Florian Barbulescu
<silviu.barbulescu@nxp.com> escreveu:
>
> endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 48_4_1
> [/local/endpoint/ep0] BIS Index for reconfiguration? (value(1-31)/no): n
> [/local/endpoint/ep0] BIG (auto/value): 0
> [/local/endpoint/ep0] Enter channel location (value/no): 1
> [/local/endpoint/ep0] Enter Metadata (value/no): n
> ---
>  client/player.c | 33 +++++++++++++++++++++++++++++++--
>  1 file changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/client/player.c b/client/player.c
> index 8081ddc13..c754af33d 100644
> --- a/client/player.c
> +++ b/client/player.c
> @@ -3659,6 +3659,35 @@ static void config_endpoint_iso_group(const char *input, void *user_data)
>         }
>  }
>
> +static void endpoint_is_reconfigure_cfg(const char *input, void *user_data)
> +{
> +       struct endpoint_config *cfg = user_data;
> +       int value;
> +       char *endptr = NULL;
> +
> +       if (!strcasecmp(input, "n") || !strcasecmp(input, "no")) {
> +               cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
> +               goto done;
> +       } else {
> +               value = strtol(input, &endptr, 0);
> +
> +               if (!endptr || *endptr != '\0' || value > UINT8_MAX) {
> +                       bt_shell_printf("Invalid argument: %s\n", input);
> +                       return bt_shell_noninteractive_quit(EXIT_FAILURE);
> +               }
> +
> +               if (value == 0x0)
> +                       cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
> +               else
> +                       cfg->ep->iso_stream = value;
> +       }
> +
> +done:
> +       bt_shell_prompt_input(cfg->ep->path,
> +               "BIG (auto/value):",
> +               config_endpoint_iso_group, cfg);
> +}
> +
>  static void endpoint_set_config_bcast(struct endpoint_config *cfg)
>  {
>         cfg->ep->bcode = g_new0(struct iovec, 1);
> @@ -3674,8 +3703,8 @@ static void endpoint_set_config_bcast(struct endpoint_config *cfg)
>         }
>
>         bt_shell_prompt_input(cfg->ep->path,
> -               "BIG (auto/value):",
> -               config_endpoint_iso_group, cfg);
> +               "BIS Index for reconfiguration? (value(1-31)/no):",
> +               endpoint_is_reconfigure_cfg, cfg);
>  }
>
>  static void cmd_config_endpoint(int argc, char *argv[])
> --
> 2.39.2
>
>
diff mbox series

Patch

diff --git a/client/player.c b/client/player.c
index 8081ddc13..c754af33d 100644
--- a/client/player.c
+++ b/client/player.c
@@ -3659,6 +3659,35 @@  static void config_endpoint_iso_group(const char *input, void *user_data)
 	}
 }
 
+static void endpoint_is_reconfigure_cfg(const char *input, void *user_data)
+{
+	struct endpoint_config *cfg = user_data;
+	int value;
+	char *endptr = NULL;
+
+	if (!strcasecmp(input, "n") || !strcasecmp(input, "no")) {
+		cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
+		goto done;
+	} else {
+		value = strtol(input, &endptr, 0);
+
+		if (!endptr || *endptr != '\0' || value > UINT8_MAX) {
+			bt_shell_printf("Invalid argument: %s\n", input);
+			return bt_shell_noninteractive_quit(EXIT_FAILURE);
+		}
+
+		if (value == 0x0)
+			cfg->ep->iso_stream = BT_ISO_QOS_STREAM_UNSET;
+		else
+			cfg->ep->iso_stream = value;
+	}
+
+done:
+	bt_shell_prompt_input(cfg->ep->path,
+		"BIG (auto/value):",
+		config_endpoint_iso_group, cfg);
+}
+
 static void endpoint_set_config_bcast(struct endpoint_config *cfg)
 {
 	cfg->ep->bcode = g_new0(struct iovec, 1);
@@ -3674,8 +3703,8 @@  static void endpoint_set_config_bcast(struct endpoint_config *cfg)
 	}
 
 	bt_shell_prompt_input(cfg->ep->path,
-		"BIG (auto/value):",
-		config_endpoint_iso_group, cfg);
+		"BIS Index for reconfiguration? (value(1-31)/no):",
+		endpoint_is_reconfigure_cfg, cfg);
 }
 
 static void cmd_config_endpoint(int argc, char *argv[])