alsaucm: add 'getval' and 'getival' commands

Print the value only without the variable name prefix

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-05-13 11:54:13 +02:00
parent bc80344625
commit 76b4af2616

View file

@ -58,7 +58,9 @@ enum uc_cmd {
/* set/get */ /* set/get */
OM_SET, OM_SET,
OM_GET, OM_GET,
OM_GET_VAL,
OM_GETI, OM_GETI,
OM_GETI_VAL,
/* misc */ /* misc */
OM_HELP, OM_HELP,
@ -82,7 +84,9 @@ static struct cmd cmds[] = {
{ OM_LIST2, 1, 1, "list" }, { OM_LIST2, 1, 1, "list" },
{ OM_SET, 2, 1, "set" }, { OM_SET, 2, 1, "set" },
{ OM_GET, 1, 1, "get" }, { OM_GET, 1, 1, "get" },
{ OM_GET_VAL, 1, 1, "getval" },
{ OM_GETI, 1, 1, "geti" }, { OM_GETI, 1, 1, "geti" },
{ OM_GETI_VAL, 1, 1, "getival" },
{ OM_DUMP, 1, 1, "dump" }, { OM_DUMP, 1, 1, "dump" },
{ OM_HELP, 0, 0, "help" }, { OM_HELP, 0, 0, "help" },
{ OM_QUIT, 0, 0, "quit" }, { OM_QUIT, 0, 0, "quit" },
@ -328,6 +332,7 @@ static int do_one(struct context *context, struct cmd *cmd, char **argv)
} }
break; break;
case OM_GET: case OM_GET:
case OM_GET_VAL:
err = snd_use_case_get(context->uc_mgr, argv[0], &str); err = snd_use_case_get(context->uc_mgr, argv[0], &str);
if (err < 0) { if (err < 0) {
fprintf(stderr, fprintf(stderr,
@ -336,10 +341,14 @@ static int do_one(struct context *context, struct cmd *cmd, char **argv)
snd_strerror(err)); snd_strerror(err));
return err; return err;
} }
printf(" %s=%s\n", argv[0], str); if (cmd->code == OM_GET)
printf(" %s=%s\n", argv[0], str);
else
printf("%s\n", str);
free((void *)str); free((void *)str);
break; break;
case OM_GETI: case OM_GETI:
case OM_GETI_VAL:
err = snd_use_case_geti(context->uc_mgr, argv[0], &lval); err = snd_use_case_geti(context->uc_mgr, argv[0], &lval);
if (err < 0) { if (err < 0) {
fprintf(stderr, fprintf(stderr,
@ -348,7 +357,10 @@ static int do_one(struct context *context, struct cmd *cmd, char **argv)
snd_strerror(err)); snd_strerror(err));
return lval; return lval;
} }
printf(" %s=%li\n", argv[0], lval); if (cmd->code == OM_GETI)
printf(" %s=%li\n", argv[0], lval);
else
printf("%li\n", lval);
break; break;
case OM_QUIT: case OM_QUIT:
context->do_exit = 1; context->do_exit = 1;