mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-09 17:15:43 +01:00
alsaucm: add also card index for '-c' argument
Make semantics for this argument in sync with other ALSA utilities. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
dad2161d3c
commit
58f92d6175
1 changed files with 23 additions and 0 deletions
|
@ -123,6 +123,20 @@ static void dump_help(struct context *context)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_long(const char *str)
|
||||||
|
{
|
||||||
|
char *end;
|
||||||
|
if (!*str)
|
||||||
|
return 0;
|
||||||
|
errno = 0;
|
||||||
|
strtol(str, &end, 10);
|
||||||
|
if (errno)
|
||||||
|
return 0;
|
||||||
|
if (*end)
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_line(struct context *context, char *line)
|
static int parse_line(struct context *context, char *line)
|
||||||
{
|
{
|
||||||
char *start, **nargv;
|
char *start, **nargv;
|
||||||
|
@ -202,6 +216,15 @@ static void do_initial_open(struct context *context)
|
||||||
|
|
||||||
/* open library */
|
/* open library */
|
||||||
if (!context->no_open) {
|
if (!context->no_open) {
|
||||||
|
if (is_long(context->card)) {
|
||||||
|
snprintf(name, sizeof(name), "hw:%s", context->card);
|
||||||
|
free(context->card);
|
||||||
|
context->card = strdup(name);
|
||||||
|
}
|
||||||
|
if (context->card == NULL) {
|
||||||
|
fprintf(stderr, "%s: empty card name\n", context->command);
|
||||||
|
my_exit(context, EXIT_FAILURE);
|
||||||
|
}
|
||||||
err = snd_use_case_mgr_open(&context->uc_mgr,
|
err = snd_use_case_mgr_open(&context->uc_mgr,
|
||||||
context->card);
|
context->card);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
|
|
Loading…
Reference in a new issue