diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-04-20 13:45:48 +0530 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2011-04-20 09:39:17 +0100 |
commit | e5f547fe705c4e51cb09d72c2e1682d345c8f3e4 (patch) | |
tree | 56c26e1112736d19587ca395e605455fc68eac87 /src | |
parent | e7270689567c55e4b68299cd9f399ca8ec34a85c (diff) |
filter-apply: Make housekeeping optional
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.
Diffstat (limited to 'src')
-rw-r--r-- | 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 c29e74d2..c8989711 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> @@ -41,11 +42,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 { @@ -63,6 +67,7 @@ struct userdata { *sink_input_proplist_slot, *sink_input_unlink_slot, *sink_unlink_slot; + pa_bool_t autoclean; pa_time_event *housekeeping_time_event; }; @@ -149,6 +154,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; @@ -342,6 +350,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); |