From: Takashi Iwai <tiwai@suse.de>
To: Arun Raghavan <arun@accosted.net>
Cc: Arun Raghavan <git@arunraghavan.net>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: Re: [PATCH] control: Allow cset'ing specific values in the multi-value case
Date: Wed, 10 Jun 2015 11:58:50 +0200 [thread overview]
Message-ID: <s5h8ubropet.wl-tiwai@suse.de> (raw)
In-Reply-To: <CACuU-+jXEyNL1+tXC0zBRRRW+RtsmRgvOwYK=hA3hOXfF9nRVA@mail.gmail.com>
At Wed, 10 Jun 2015 14:26:48 +0530,
Arun Raghavan wrote:
>
> On 9 June 2015 at 17:33, Takashi Iwai <tiwai@suse.de> wrote:
> > At Tue, 9 Jun 2015 16:25:07 +0530,
> > arun@accosted.net wrote:
> >>
> >> From: Arun Raghavan <git@arunraghavan.net>
> >>
> >> This works with syntax like ...
> >>
> >> amixer cset 'IIR1 Band1' ,,200
> >>
> >> ... to set the third value of the control to 200.
> >> ---
> >> src/control/ctlparse.c | 10 ++++++----
> >> 1 file changed, 6 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/src/control/ctlparse.c b/src/control/ctlparse.c
> >> index 8d6c385..64c6480 100644
> >> --- a/src/control/ctlparse.c
> >> +++ b/src/control/ctlparse.c
> >> @@ -48,9 +48,9 @@ static inline long int convert_prange1(long val, long min, long max)
> >> #define check_range(val, min, max) \
> >> ((val < min) ? (min) : ((val > max) ? (max) : (val)))
> >>
> >> -static long get_integer(const char **ptr, long min, long max)
> >> +static long get_integer(const char **ptr, long def, long min, long max)
> >> {
> >> - long val = min;
> >> + long val = def;
> >> char *p = (char *)*ptr, *s;
> >>
> >> if (*p == ':')
> >> @@ -351,6 +351,8 @@ int snd_ctl_ascii_value_parse(snd_ctl_t *handle,
> >> break;
> >> case SND_CTL_ELEM_TYPE_INTEGER:
> >> tmp = get_integer(&ptr,
> >> + snd_ctl_elem_value_get_integer(dst,
> >> + idx),
> >> snd_ctl_elem_info_get_min(info),
> >> snd_ctl_elem_info_get_max(info));
> >> snd_ctl_elem_value_set_integer(dst, idx, tmp);
> >> @@ -364,12 +366,12 @@ int snd_ctl_ascii_value_parse(snd_ctl_t *handle,
> >> case SND_CTL_ELEM_TYPE_ENUMERATED:
> >> tmp = get_ctl_enum_item_index(handle, info, &ptr);
> >> if (tmp < 0)
> >> - tmp = get_integer(&ptr, 0,
> >> + tmp = get_integer(&ptr, 0, 0,
> >> snd_ctl_elem_info_get_items(info) - 1);
> >> snd_ctl_elem_value_set_enumerated(dst, idx, tmp);
> >> break;
> >> case SND_CTL_ELEM_TYPE_BYTES:
> >> - tmp = get_integer(&ptr, 0, 255);
> >> + tmp = get_integer(&ptr, 0, 0, 255);
> >> snd_ctl_elem_value_set_byte(dst, idx, tmp);
> >> break;
> >
> > Hmm, if it's just about skipping the empty element, how about the
> > patch below instead?
>
> Thanks, this works and does look better.
Pushed to git tree now. Thanks.
Takashi
prev parent reply other threads:[~2015-06-10 9:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 10:55 [PATCH] control: Allow cset'ing specific values in the multi-value case arun
2015-06-09 12:03 ` Takashi Iwai
2015-06-10 8:56 ` Arun Raghavan
2015-06-10 9:58 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=s5h8ubropet.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=arun@accosted.net \
--cc=git@arunraghavan.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox