mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
control: Simplify using snd_config_get_bool()
snd_config_get_bool() was improved to parse also ASCII strings now, so we don't have to open-code the boolean parser in src/control/setup.c any longer. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
3e7dc283ed
commit
8c6da54073
1 changed files with 6 additions and 31 deletions
|
|
@ -400,7 +400,6 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
|
||||||
{
|
{
|
||||||
snd_config_t *conf;
|
snd_config_t *conf;
|
||||||
snd_config_iterator_t i, next;
|
snd_config_iterator_t i, next;
|
||||||
char *tmp;
|
|
||||||
int iface = SND_CTL_ELEM_IFACE_MIXER;
|
int iface = SND_CTL_ELEM_IFACE_MIXER;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
long index = 0;
|
long index = 0;
|
||||||
|
|
@ -464,33 +463,17 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcmp(id, "lock") == 0) {
|
if (strcmp(id, "lock") == 0) {
|
||||||
if ((err = snd_config_get_ascii(n, &tmp)) < 0) {
|
err = snd_config_get_bool(n);
|
||||||
SNDERR("field %s has an invalid type", id);
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
|
||||||
err = snd_config_get_bool_ascii(tmp);
|
|
||||||
if (err < 0) {
|
|
||||||
SNDERR("field %s is not a boolean", id);
|
|
||||||
free(tmp);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
lock = err;
|
lock = err;
|
||||||
free(tmp);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcmp(id, "preserve") == 0) {
|
if (strcmp(id, "preserve") == 0) {
|
||||||
if ((err = snd_config_get_ascii(n, &tmp)) < 0) {
|
err = snd_config_get_bool(n);
|
||||||
SNDERR("field %s has an invalid type", id);
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
|
||||||
err = snd_config_get_bool_ascii(tmp);
|
|
||||||
if (err < 0) {
|
|
||||||
SNDERR("field %s is not a boolean", id);
|
|
||||||
free(tmp);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
preserve = err;
|
preserve = err;
|
||||||
free(tmp);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcmp(id, "value") == 0) {
|
if (strcmp(id, "value") == 0) {
|
||||||
|
|
@ -502,18 +485,10 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcmp(id, "optional") == 0) {
|
if (strcmp(id, "optional") == 0) {
|
||||||
if ((err = snd_config_get_ascii(n, &tmp)) < 0) {
|
err = snd_config_get_bool(n);
|
||||||
SNDERR("field %s has an invalid type", id);
|
if (err < 0)
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
|
||||||
err = snd_config_get_bool_ascii(tmp);
|
|
||||||
if (err < 0) {
|
|
||||||
SNDERR("field %s is not a boolean", id);
|
|
||||||
free(tmp);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
optional = err;
|
optional = err;
|
||||||
free(tmp);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SNDERR("Unknown field %s", id);
|
SNDERR("Unknown field %s", id);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue