mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									e727068956
								
							
						
					
					
						commit
						e5f547fe70
					
				
					 1 changed files with 14 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue