[pulseaudio-discuss] [PATCH] filter-apply: Mark modules as being autoloaded

Arun Raghavan arun.raghavan at collabora.co.uk
Sun May 1 21:41:47 PDT 2011


(Based on Colin's review) We mark modules as being autoloaded so that
they can handle this as a special case if needed (which is required by
module-echo-cancel for now). This inverts how things were done and makes
using these modules manually less error-prone.
---
 src/modules/echo-cancel/module-echo-cancel.c |   18 +++++++++---------
 src/modules/module-equalizer-sink.c          |   13 ++++++++++++-
 src/modules/module-filter-apply.c            |    2 +-
 src/modules/module-virtual-sink.c            |    3 +++
 src/modules/module-virtual-source.c          |    3 +++
 5 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 746028b..3787962 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -78,7 +78,7 @@ PA_MODULE_USAGE(
           "aec_method=<implementation to use> "
           "aec_args=<parameters for the AEC engine> "
           "save_aec=<save AEC data in /tmp> "
-          "manual_load=<set if this module is being loaded manually> "
+          "autoloaded=<set if this module is being loaded automatically> "
         ));
 
 /* NOTE: Make sure the enum and ec_table are maintained in the correct order */
@@ -107,7 +107,7 @@ static const pa_echo_canceller ec_table[] = {
 
 #define DEFAULT_ADJUST_TIME_USEC (1*PA_USEC_PER_SEC)
 #define DEFAULT_SAVE_AEC 0
-#define DEFAULT_MANUAL_LOAD FALSE
+#define DEFAULT_AUTOLOADED FALSE
 
 #define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
 
@@ -158,7 +158,7 @@ struct userdata {
     pa_core *core;
     pa_module *module;
 
-    pa_bool_t manual_load;
+    pa_bool_t autoloaded;
     uint32_t save_aec;
 
     pa_echo_canceller *ec;
@@ -213,7 +213,7 @@ static const char* const valid_modargs[] = {
     "aec_method",
     "aec_args",
     "save_aec",
-    "manual_load",
+    "autoloaded",
     NULL
 };
 
@@ -1398,9 +1398,9 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
-    u->manual_load = DEFAULT_MANUAL_LOAD;
-    if (pa_modargs_get_value_boolean(ma, "manual_load", &u->manual_load) < 0) {
-        pa_log("Failed to parse manual_load value");
+    u->autoloaded = DEFAULT_AUTOLOADED;
+    if (pa_modargs_get_value_boolean(ma, "autoloaded", &u->autoloaded) < 0) {
+        pa_log("Failed to parse autoloaded value");
         goto fail;
     }
 
@@ -1423,7 +1423,7 @@ int pa__init(pa_module*m) {
     pa_source_new_data_set_channel_map(&source_data, &source_map);
     pa_proplist_sets(source_data.proplist, PA_PROP_DEVICE_MASTER_DEVICE, source_master->name);
     pa_proplist_sets(source_data.proplist, PA_PROP_DEVICE_CLASS, "filter");
-    if (u->manual_load)
+    if (!u->autoloaded)
         pa_proplist_sets(source_data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone");
     pa_proplist_sets(source_data.proplist, "device.echo-cancel.name", source_data.name);
 
@@ -1471,7 +1471,7 @@ int pa__init(pa_module*m) {
     pa_sink_new_data_set_channel_map(&sink_data, &sink_map);
     pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_MASTER_DEVICE, sink_master->name);
     pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_CLASS, "filter");
-    if (u->manual_load)
+    if (!u->autoloaded)
         pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone");
     pa_proplist_sets(sink_data.proplist, "device.echo-cancel.name", sink_data.name);
 
diff --git a/src/modules/module-equalizer-sink.c b/src/modules/module-equalizer-sink.c
index 0bbb23a..9a85fe5 100644
--- a/src/modules/module-equalizer-sink.c
+++ b/src/modules/module-equalizer-sink.c
@@ -83,14 +83,18 @@ PA_MODULE_USAGE(
           "format=<sample format> "
           "rate=<sample rate> "
           "channels=<number of channels> "
-          "channel_map=<channel map>"));
+          "channel_map=<channel map> "
+          "autoloaded=<set if this module is being loaded automatically> "
+         ));
 
 #define MEMBLOCKQ_MAXLENGTH (16*1024*1024)
+#define DEFAULT_AUTOLOADED FALSE
 
 struct userdata {
     pa_module *module;
     pa_sink *sink;
     pa_sink_input *sink_input;
+    pa_bool_t autoloaded;
 
     size_t channels;
     size_t fft_size;//length (res) of fft
@@ -138,6 +142,7 @@ static const char* const valid_modargs[] = {
     "rate",
     "channels",
     "channel_map",
+    "autoloaded",
     NULL
 };
 
@@ -1170,6 +1175,12 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    u->autoloaded = DEFAULT_AUTOLOADED;
+    if (pa_modargs_get_value_boolean(ma, "autoloaded", &u->autoloaded) < 0) {
+        pa_log("Failed to parse autoloaded value");
+        goto fail;
+    }
+
     u->sink = pa_sink_new(m->core, &sink_data,
                           PA_SINK_HW_MUTE_CTRL|PA_SINK_HW_VOLUME_CTRL|PA_SINK_DECIBEL_VOLUME|
                           (master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)));
diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index 79558f2..e9c9f65 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -314,7 +314,7 @@ static pa_hook_result_t process(struct userdata *u, pa_object *o, pa_bool_t is_s
             char *args;
             pa_module *m;
 
-            args = pa_sprintf_malloc("%s_master=%s", is_sink_input ? "sink" : "source", parent_name);
+            args = pa_sprintf_malloc("autoloaded=1 %s_master=%s", is_sink_input ? "sink" : "source", parent_name);
             pa_log_debug("Loading %s with arguments '%s'", module_name, args);
 
             if ((m = pa_module_load(u->core, module_name, args))) {
diff --git a/src/modules/module-virtual-sink.c b/src/modules/module-virtual-sink.c
index f772314..9bcff8c 100644
--- a/src/modules/module-virtual-sink.c
+++ b/src/modules/module-virtual-sink.c
@@ -66,6 +66,9 @@ PA_MODULE_USAGE(
 struct userdata {
     pa_module *module;
 
+    /* FIXME: Uncomment this and take "autoloaded" as a modarg if this is a filter */
+    /* pa_bool_t autoloaded; */
+
     pa_sink *sink;
     pa_sink_input *sink_input;
 
diff --git a/src/modules/module-virtual-source.c b/src/modules/module-virtual-source.c
index b8f2ab0..835cf3c 100644
--- a/src/modules/module-virtual-source.c
+++ b/src/modules/module-virtual-source.c
@@ -69,6 +69,9 @@ PA_MODULE_USAGE(
 struct userdata {
     pa_module *module;
 
+    /* FIXME: Uncomment this and take "autoloaded" as a modarg if this is a filter */
+    /* pa_bool_t autoloaded; */
+
     pa_source *source;
     pa_source_output *source_output;
 
-- 
1.7.5.rc1




More information about the pulseaudio-discuss mailing list