[pulseaudio-discuss] [PATCH 1/2] modargs: New function: pa_modargs_get_value_double().

Tanu Kaskinen tanuk at iki.fi
Fri Oct 19 11:37:25 PDT 2012


On Tue, 2012-10-09 at 15:16 -0300, Flavio Ceolin wrote:
> ---
>  src/pulsecore/modargs.c | 14 ++++++++++++++
>  src/pulsecore/modargs.h |  3 +++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/src/pulsecore/modargs.c b/src/pulsecore/modargs.c
> index 58a7045..af9fabf 100644
> --- a/src/pulsecore/modargs.c
> +++ b/src/pulsecore/modargs.c
> @@ -336,6 +336,20 @@ int pa_modargs_get_value_boolean(pa_modargs *ma, const char *key, pa_bool_t *val
>      return 0;
>  }
>  
> +int pa_modargs_get_value_double(pa_modargs *ma, const char *key, double *value) {
> +    const char *v;
> +
> +    pa_assert(value);
> +
> +    if (!(v = pa_modargs_get_value(ma, key, NULL)))
> +        return 0;
> +
> +    if (pa_atod(v, value) < 0)
> +        return -1;
> +
> +    return 0;
> +}
> +
>  int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *rss) {
>      const char *format;
>      uint32_t channels;
> diff --git a/src/pulsecore/modargs.h b/src/pulsecore/modargs.h
> index f6e1861..5da9cf1 100644
> --- a/src/pulsecore/modargs.h
> +++ b/src/pulsecore/modargs.h
> @@ -45,6 +45,9 @@ int pa_modargs_get_value_u32(pa_modargs *ma, const char *key, uint32_t *value);
>  int pa_modargs_get_value_s32(pa_modargs *ma, const char *key, int32_t *value);
>  int pa_modargs_get_value_boolean(pa_modargs *ma, const char *key, pa_bool_t *value);
>  
> +/* Return a module argument as double value in *value */
> +int pa_modargs_get_value_double(pa_modargs *ma, const char *key, double *value);
> +
>  /* Return sample spec data from the three arguments "rate", "format" and "channels" */
>  int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *ss);
>  

I've pushed this patch, even if the new function ends up being unused. I
think it makes sense to have the function available anyway - you never
know when you're going to need it, and when you do, it's nice to have it
ready.

-- 
Tanu



More information about the pulseaudio-discuss mailing list