[PATCH] filter-apply: Make housekeeping optional

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

 



Adds an autoclean option (defaults to TRUE) that controls whether
module-filter-apply cleans up unused modules or not. This is useful in
cases where you know that a filter will be used often and thus can avoid
overhead from repeated module load/unload.
---
 src/modules/module-filter-apply.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c
index d4bded5..12acc91 100644
--- a/src/modules/module-filter-apply.c
+++ b/src/modules/module-filter-apply.c
@@ -25,6 +25,7 @@
 
 #include <pulse/timeval.h>
 #include <pulse/rtclock.h>
+#include <pulse/i18n.h>
 
 #include <pulsecore/macro.h>
 #include <pulsecore/hashmap.h>
@@ -44,11 +45,14 @@ PA_MODULE_AUTHOR("Colin Guthrie");
 PA_MODULE_DESCRIPTION("Load filter sinks automatically when needed");
 PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_USAGE(_("autoclean=<automatically unload unused filters?>"));
 
 static const char* const valid_modargs[] = {
+    "autoclean",
     NULL
 };
 
+#define DEFAULT_AUTOCLEAN TRUE
 #define HOUSEKEEPING_INTERVAL (10 * PA_USEC_PER_SEC)
 
 struct filter {
@@ -66,6 +70,7 @@ struct userdata {
         *sink_input_proplist_slot,
         *sink_input_unlink_slot,
         *sink_unlink_slot;
+    pa_bool_t autoclean;
     pa_time_event *housekeeping_time_event;
 };
 
@@ -152,6 +157,9 @@ static void housekeeping_time_callback(pa_mainloop_api*a, pa_time_event* e, cons
 static void trigger_housekeeping(struct userdata *u) {
     pa_assert(u);
 
+    if (!u->autoclean)
+        return;
+
     if (u->housekeeping_time_event)
         return;
 
@@ -345,6 +353,12 @@ int pa__init(pa_module *m) {
 
     u->core = m->core;
 
+    u->autoclean = DEFAULT_AUTOCLEAN;
+    if (pa_modargs_get_value_boolean(ma, "autoclean", &u->autoclean) < 0) {
+        pa_log("Failed to parse autoclean value");
+        goto fail;
+    }
+
     u->filters = pa_hashmap_new(filter_hash, filter_compare);
 
     u->sink_input_put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_put_cb, u);
-- 
1.7.5.rc1




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

  Powered by Linux