[pulseaudio-commits] 4 commits - src/modules src/pulsecore

Tanu Kaskinen tanuk at kemper.freedesktop.org
Thu Dec 5 01:07:55 PST 2013


 src/modules/bluetooth/module-bluez4-device.c |    3 +--
 src/modules/module-remap-sink.c              |    9 +++++++++
 src/modules/module-remap-source.c            |    9 +++++++++
 src/modules/module-sine-source.c             |    2 +-
 src/modules/module-sine.c                    |    7 +++++++
 src/pulsecore/modargs.c                      |    4 +---
 6 files changed, 28 insertions(+), 6 deletions(-)

New commits:
commit 3d425a3315122eb2db8f826549b54a302d3c153a
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Fri Nov 29 15:32:44 2013 +0100

    module-remap-source: Add resample_method argument
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/modules/module-remap-source.c b/src/modules/module-remap-source.c
index 7c35085..5fa6465 100644
--- a/src/modules/module-remap-source.c
+++ b/src/modules/module-remap-source.c
@@ -55,6 +55,7 @@ PA_MODULE_USAGE(
         "rate=<sample rate> "
         "channels=<number of channels> "
         "channel_map=<channel map> "
+        "resample_method=<resampler> "
         "remix=<remix channels?>");
 
 struct userdata {
@@ -75,6 +76,7 @@ static const char* const valid_modargs[] = {
     "rate",
     "channels",
     "channel_map",
+    "resample_method",
     "remix",
     NULL
 };
@@ -263,6 +265,7 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) {
 int pa__init(pa_module*m) {
     struct userdata *u;
     pa_sample_spec ss;
+    pa_resample_method_t resample_method = PA_RESAMPLER_INVALID;
     pa_channel_map source_map, stream_map;
     pa_modargs *ma;
     pa_source *master;
@@ -308,6 +311,11 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    if (pa_modargs_get_resample_method(ma, &resample_method) < 0) {
+        pa_log("Invalid resampling method");
+        goto fail;
+    }
+
     u = pa_xnew0(struct userdata, 1);
     u->module = m;
     m->userdata = u;
@@ -364,6 +372,7 @@ int pa__init(pa_module*m) {
     pa_source_output_new_data_set_sample_spec(&source_output_data, &ss);
     pa_source_output_new_data_set_channel_map(&source_output_data, &stream_map);
     source_output_data.flags = remix ? 0 : PA_SOURCE_OUTPUT_NO_REMIX;
+    source_output_data.resample_method = resample_method;
 
     pa_source_output_new(&u->source_output, m->core, &source_output_data);
     pa_source_output_new_data_done(&source_output_data);

commit 5f7dfd9b91755a2b8a26951de44a656e3c99533f
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Fri Nov 29 15:32:43 2013 +0100

    module-remap-sink: Add resample_method argument
    
    the main intent is to make testing different sample rate resampling
    implementations easier; so far there is only global control via
    resample-method (command line argument and /etc/pulse/daemon.conf)
    
    module-remap-*'s only purpose is resampling (comprising format conversion,
    channel remapping, sample rate adjustment), it can easily be introduced
    into any audio pipeline
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c
index 67e8da8..274f9f2 100644
--- a/src/modules/module-remap-sink.c
+++ b/src/modules/module-remap-sink.c
@@ -48,6 +48,7 @@ PA_MODULE_USAGE(
         "rate=<sample rate> "
         "channels=<number of channels> "
         "channel_map=<channel map> "
+        "resample_method=<resampler> "
         "remix=<remix channels?>");
 
 struct userdata {
@@ -68,6 +69,7 @@ static const char* const valid_modargs[] = {
     "rate",
     "channels",
     "channel_map",
+    "resample_method",
     "remix",
     NULL
 };
@@ -318,6 +320,7 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
 int pa__init(pa_module*m) {
     struct userdata *u;
     pa_sample_spec ss;
+    pa_resample_method_t resample_method = PA_RESAMPLER_INVALID;
     pa_channel_map sink_map, stream_map;
     pa_modargs *ma;
     pa_sink *master;
@@ -363,6 +366,11 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    if (pa_modargs_get_resample_method(ma, &resample_method) < 0) {
+        pa_log("Invalid resampling method");
+        goto fail;
+    }
+
     u = pa_xnew0(struct userdata, 1);
     u->module = m;
     m->userdata = u;
@@ -418,6 +426,7 @@ int pa__init(pa_module*m) {
     pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss);
     pa_sink_input_new_data_set_channel_map(&sink_input_data, &stream_map);
     sink_input_data.flags = (remix ? 0 : PA_SINK_INPUT_NO_REMIX);
+    sink_input_data.resample_method = resample_method;
 
     pa_sink_input_new(&u->sink_input, m->core, &sink_input_data);
     pa_sink_input_new_data_done(&sink_input_data);

commit f8e0b8659216209fe75bb9f1f49da7682320ae42
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Fri Nov 29 15:32:42 2013 +0100

    module-sine: Add rate argument
    
    useful for testing resampling
    
    Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>

diff --git a/src/modules/module-sine.c b/src/modules/module-sine.c
index 573a7c0..6bf395e 100644
--- a/src/modules/module-sine.c
+++ b/src/modules/module-sine.c
@@ -41,6 +41,7 @@ PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(false);
 PA_MODULE_USAGE(
         "sink=<sink to connect to> "
+        "rate=<sample rate> "
         "frequency=<frequency in Hz>");
 
 struct userdata {
@@ -53,6 +54,7 @@ struct userdata {
 
 static const char* const valid_modargs[] = {
     "sink",
+    "rate",
     "frequency",
     NULL,
 };
@@ -138,6 +140,11 @@ int pa__init(pa_module*m) {
     ss.rate = sink->sample_spec.rate;
     ss.channels = 1;
 
+    if (pa_modargs_get_sample_rate(ma, &ss.rate) < 0) {
+        pa_log("Invalid rate specification");
+        goto fail;
+    }
+
     frequency = 440;
     if (pa_modargs_get_value_u32(ma, "frequency", &frequency) < 0 || frequency < 1 || frequency > ss.rate/2) {
         pa_log("Invalid frequency specification");

commit e74d4244a285a7e29300c19df7b202ba7c51ecef
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Fri Nov 29 15:32:41 2013 +0100

    modules: Make use of new function pa_modargs_get_sample_rate()
    
    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>

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;



More information about the pulseaudio-commits mailing list