[PATCHv2 1/4] modules: Make use of new function pa_modargs_get_sample_rate()

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

 



From: Peter Meerwald <p.meerwald@xxxxxxxxxxxxxxxxxx>

by using pa_modargs_get_sample_rate() we avoid inconsistant validity
checking of the sample rate in various places

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/modules/bluetooth/module-bluez4-device.c |    3 +--
 src/modules/module-sine-source.c             |    2 +-
 src/pulsecore/modargs.c                      |    4 +---
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c
index 047332b..f419cb9 100644
--- a/src/modules/bluetooth/module-bluez4-device.c
+++ b/src/modules/bluetooth/module-bluez4-device.c
@@ -2450,8 +2450,7 @@ int pa__init(pa_module *m) {
         goto fail;
     }
 
-    if (pa_modargs_get_value_u32(ma, "rate", &u->sample_spec.rate) < 0 ||
-        u->sample_spec.rate <= 0 || u->sample_spec.rate > PA_RATE_MAX) {
+    if (pa_modargs_get_sample_rate(ma, &u->sample_spec.rate) < 0) {
         pa_log_error("Failed to get rate from module arguments");
         goto fail;
     }
diff --git a/src/modules/module-sine-source.c b/src/modules/module-sine-source.c
index bb3f8c4..338fedb 100644
--- a/src/modules/module-sine-source.c
+++ b/src/modules/module-sine-source.c
@@ -213,7 +213,7 @@ int pa__init(pa_module*m) {
     ss.channels = 1;
     ss.rate = 44100;
 
-    if (pa_modargs_get_value_u32(ma, "rate", &ss.rate) < 0 || ss.rate <= 1) {
+    if (pa_modargs_get_sample_rate(ma, &ss.rate) < 0) {
         pa_log("Invalid rate specification");
         goto fail;
     }
diff --git a/src/pulsecore/modargs.c b/src/pulsecore/modargs.c
index 04e60fd..432e480 100644
--- a/src/pulsecore/modargs.c
+++ b/src/pulsecore/modargs.c
@@ -387,9 +387,7 @@ int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *rss) {
     pa_assert(rss);
 
     ss = *rss;
-    if ((pa_modargs_get_value_u32(ma, "rate", &ss.rate)) < 0 ||
-        ss.rate <= 0 ||
-        ss.rate > PA_RATE_MAX)
+    if ((pa_modargs_get_sample_rate(ma, &ss.rate)) < 0)
         return -1;
 
     channels = ss.channels;
-- 
1.7.9.5



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

  Powered by Linux