From: Takashi Iwai Date: Wed, 10 Jun 2015 09:56:23 +0000 (+0200) Subject: control: Allow cset'ing specific values in the multi-value case X-Git-Tag: v1.1.0~68 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=2fd098b587e8e5137c05ea6248c2aa87294e13c2;p=alsa-lib.git control: Allow cset'ing specific values in the multi-value case Improve the parser to allow empty elements followed by a comma. Now amixer works like below for setting only the third element. % amixer cset 'IIR1 Band1' ,,200 Reported-and-tested-by: Arun Raghavan Signed-off-by: Takashi Iwai --- diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c index 8d6c3859..877a05e3 100644 --- a/src/control/ctlparse.c +++ b/src/control/ctlparse.c @@ -325,6 +325,8 @@ int snd_ctl_ascii_value_parse(snd_ctl_t *handle, snd_ctl_elem_value_set_id(dst, myid); for (idx = 0; idx < count && idx < 128 && ptr && *ptr; idx++) { + if (*ptr == ',') + goto skip; switch (type) { case SND_CTL_ELEM_TYPE_BOOLEAN: tmp = 0; @@ -375,6 +377,7 @@ int snd_ctl_ascii_value_parse(snd_ctl_t *handle, default: break; } + skip: if (!strchr(value, ',')) ptr = value; else if (*ptr == ',')