From: Arun Raghavan Date: Wed, 20 Apr 2011 08:15:48 +0000 (+0530) Subject: filter-apply: Make housekeeping optional X-Git-Tag: 1.0_branch~629 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5f547fe705c4e51cb09d72c2e1682d345c8f3e4;p=profile%2Fivi%2Fpulseaudio.git 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. --- diff --git a/src/modules/module-filter-apply.c b/src/modules/module-filter-apply.c index c29e74d..c898971 100644 --- a/src/modules/module-filter-apply.c +++ b/src/modules/module-filter-apply.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -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=")); 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);