mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-23 01:40:06 -05:00
PCM: Fix the conversion from string to chmap position
Use strncasecmp() to allow lower cases, and also evaluate the inverted phase suffix, too. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
f7300682dc
commit
c6db60e327
1 changed files with 27 additions and 10 deletions
|
|
@ -7471,24 +7471,41 @@ int snd_pcm_chmap_print(const snd_pcm_chmap_t *map, size_t maxlen, char *buf)
|
||||||
static int str_to_chmap(const char *str, int len)
|
static int str_to_chmap(const char *str, int len)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
|
unsigned long v;
|
||||||
|
char *p;
|
||||||
|
|
||||||
if (isdigit(*str)) {
|
if (isdigit(*str)) {
|
||||||
val = atoi(str);
|
v = strtoul(str, &p, 0);
|
||||||
if (val < 0)
|
if (v == ULONG_MAX)
|
||||||
return -1;
|
return -1;
|
||||||
return val | SND_CHMAP_DRIVER_SPEC;
|
val = v;
|
||||||
} else if (str[0] == 'C' && str[1] == 'h') {
|
val |= SND_CHMAP_DRIVER_SPEC;
|
||||||
val = atoi(str + 2);
|
str = p;
|
||||||
if (val < 0)
|
} else if (!strncasecmp(str, "ch", 2)) {
|
||||||
|
v = strtoul(str + 2, &p, 0);
|
||||||
|
if (v == ULONG_MAX)
|
||||||
return -1;
|
return -1;
|
||||||
return val;
|
val = v;
|
||||||
|
str = p;
|
||||||
} else {
|
} else {
|
||||||
for (val = 0; val <= SND_CHMAP_LAST; val++) {
|
for (val = 0; val <= SND_CHMAP_LAST; val++) {
|
||||||
if (!strncmp(str, chmap_names[val], len))
|
int slen;
|
||||||
return val;
|
assert(chmap_names[val]);
|
||||||
|
slen = strlen(chmap_names[val]);
|
||||||
|
if (slen > len)
|
||||||
|
continue;
|
||||||
|
if (!strncasecmp(str, chmap_names[val], slen) &&
|
||||||
|
!isalpha(str[slen])) {
|
||||||
|
str += slen;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
if (val > SND_CHMAP_LAST)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (str && !strncasecmp(str, "[INV]", 5))
|
||||||
|
val |= SND_CHMAP_PHASE_INVERSE;
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int snd_pcm_chmap_from_string(const char *str)
|
unsigned int snd_pcm_chmap_from_string(const char *str)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue