[pulseaudio-discuss] [PATCH] pactl: Fix relative volume parsing

Arun Raghavan arun at accosted.net
Wed Apr 1 23:07:16 PDT 2015


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.

The original reason for removing it seems to be pretty arbitrary. :-)

>  src/utils/pactl.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/utils/pactl.c b/src/utils/pactl.c
> index 1dc8c3f..a13c7fb 100644
> --- a/src/utils/pactl.c
> +++ b/src/utils/pactl.c
> @@ -1456,6 +1456,7 @@ static void exit_signal_callback(pa_mainloop_api *m, pa_signal_event *e, int sig
>  static int parse_volume(const char *vol_spec, pa_volume_t *vol, enum volume_flags *vol_flags) {
>      double v;
>      char *vs;
> +    const char *atod_input;
>
>      pa_assert(vol_spec);
>      pa_assert(vol);
> @@ -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.

-- Arun


More information about the pulseaudio-discuss mailing list