filter-apply: Add "autoclean_interval" module argument 45/137245/2 accepted/tizen/unified/20170717.021035 submit/tizen/20170713.021221
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 5 Jul 2017 05:04:09 +0000 (14:04 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Wed, 5 Jul 2017 12:46:55 +0000 (12:46 +0000)
Now it is possible to set interval time of "autoclean" behavior.
Deafult time is 10 seconds which is the same as before.

[Version] 5.0.119
[Issue Type] New feature

Change-Id: I30d11b4e7a735ba37a7c1983c6ab7944721641aa
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio.spec
src/modules/module-filter-apply.c

index aa9bab0..1f426bb 100644 (file)
@@ -12,7 +12,7 @@
 Name:             pulseaudio
 Summary:          Improved Linux sound server
 Version:          5.0
-Release:          118
+Release:          119
 Group:            Multimedia/Audio
 License:          LGPL-2.1
 URL:              http://pulseaudio.org
index 54651f0..8b630a8 100644 (file)
@@ -48,15 +48,18 @@ 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?>"));
+PA_MODULE_USAGE(
+    _("autoclean=<automatically unload unused filters?> "
+      "autoclean_internal=<interval time(sec) of unloading filters. Default: 10> "));
 
 static const char* const valid_modargs[] = {
     "autoclean",
+    "autoclean_interval",
     NULL
 };
 
 #define DEFAULT_AUTOCLEAN true
-#define HOUSEKEEPING_INTERVAL (10 * PA_USEC_PER_SEC)
+#define DEFAULT_AUTOCLEAN_INTERVAL 10
 
 struct filter {
     char *name;
@@ -84,6 +87,7 @@ struct userdata {
         *source_output_unlink_slot,
         *source_unlink_slot;
     bool autoclean;
+    uint32_t autoclean_interval;
     pa_time_event *housekeeping_time_event;
 };
 
@@ -376,6 +380,12 @@ static void housekeeping_time_callback(pa_mainloop_api*a, pa_time_event* e, cons
     pa_log_info("Housekeeping Done.");
 }
 
+static pa_usec_t get_housekeeping_interval(struct userdata *u) {
+    pa_assert(u);
+
+    return u->autoclean_interval * PA_USEC_PER_SEC;
+}
+
 static void trigger_housekeeping(struct userdata *u) {
     pa_assert(u);
 
@@ -385,7 +395,7 @@ static void trigger_housekeeping(struct userdata *u) {
     if (u->housekeeping_time_event)
         return;
 
-    u->housekeeping_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + HOUSEKEEPING_INTERVAL, housekeeping_time_callback, u);
+    u->housekeeping_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + get_housekeeping_interval(u), housekeeping_time_callback, u);
 }
 
 static int do_move(pa_object *obj, pa_object *parent, bool restore, bool is_input) {
@@ -815,6 +825,12 @@ int pa__init(pa_module *m) {
         goto fail;
     }
 
+    u->autoclean_interval = DEFAULT_AUTOCLEAN_INTERVAL;
+    if (pa_modargs_get_value_u32(ma, "autoclean_interval", &u->autoclean_interval) < 0) {
+        pa_log("Failed to parse autoclean_interval 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);