[PATCH 2/6] modargs: Add pa_modargs_get_sample_rate()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



return sample rate from the "rate" module argument

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/pulsecore/modargs.c | 11 +++++++++++
 src/pulsecore/modargs.h |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/src/pulsecore/modargs.c b/src/pulsecore/modargs.c
index 7133906..65bc669 100644
--- a/src/pulsecore/modargs.c
+++ b/src/pulsecore/modargs.c
@@ -364,6 +364,17 @@ int pa_modargs_get_value_volume(pa_modargs *ma, const char *key, pa_volume_t *va
     return 0;
 }
 
+int pa_modargs_get_sample_rate(pa_modargs *ma, uint32_t *rate) {
+    pa_assert(rate);
+
+    if ((pa_modargs_get_value_u32(ma, "rate", rate)) < 0 ||
+        *rate <= 0 ||
+        *rate > PA_RATE_MAX)
+        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 274e943..6d6b477 100644
--- a/src/pulsecore/modargs.h
+++ b/src/pulsecore/modargs.h
@@ -53,6 +53,9 @@ int pa_modargs_get_value_double(pa_modargs *ma, const char *key, double *value);
 /* Return a module argument as pa_volume_t value in *value */
 int pa_modargs_get_value_volume(pa_modargs *ma, const char *key, pa_volume_t *value);
 
+/* Return sample rate from the "rate" argument */
+int pa_modargs_get_sample_rate(pa_modargs *ma, uint32_t *rate);
+
 /* 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.8.3.4



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux