[pulseaudio-discuss] [PATCH] pactl: Fix relative volume parsing
Tanu Kaskinen
tanu.kaskinen at linux.intel.com
Thu Apr 2 03:55:10 PDT 2015
On Thu, 2015-04-02 at 11:37 +0530, Arun Raghavan wrote:
> On 1 April 2015 at 22:10, Tanu Kaskinen <tanu.kaskinen at linux.intel.com> wrote:
> > The recent change to reject leading '+' in pa_atod() broke the
> > relative volume parsing in pactl. This fixes that.
> > ---
>
> I'm wondering if we should just have pa_atod() deal with leading '+
> signs, so we don't have to explicitly think about his sort of thing
> anywhere else, if it comes up.
IMHO it's worth thinking about in situations like this, where the sign
is actually a marker for different semantics. "10%" and "+10%" are not
equal, so I don't see it as a problem if pa_atod() doesn't treat them as
equal either.
If you can find someone else who would prefer to allow the plus sign in
pa_atod(), I'll make a different patch, otherwise I'll stand behind this
patch.
> > @@ -1475,7 +1476,12 @@ static int parse_volume(const char *vol_spec, pa_volume_t *vol, enum volume_flag
> > vs[strlen(vs)-2] = 0;
> > }
> >
> > - if (pa_atod(vs, &v) < 0) {
> > + atod_input = vs;
> > +
> > + if (atod_input[0] == '+')
> > + atod_input++; /* pa_atod() doesn't accept leading '+', so skip it. */
>
> Probably want this to be a pa_startswith() in case of an empty string.
An empty string should get handled just fine with this code.
--
Tanu
More information about the pulseaudio-discuss
mailing list