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

Flavio Ceolin flavio.ceolin at profusion.mobi
Thu Aug 9 11:50:27 PDT 2012


---
 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);
 
-- 
1.7.11.2



More information about the pulseaudio-discuss mailing list