diff options
-rw-r--r-- | src/modules/module-alsa-sink.c | 9 | ||||
-rw-r--r-- | src/modules/module-alsa-source.c | 9 | ||||
-rw-r--r-- | src/modules/module-defs.h.m4 | 2 | ||||
-rw-r--r-- | src/modules/module-esound-sink.c | 9 | ||||
-rw-r--r-- | src/modules/module-jack-sink.c | 9 | ||||
-rw-r--r-- | src/modules/module-jack-source.c | 9 | ||||
-rw-r--r-- | src/modules/module-ladspa-sink.c | 9 | ||||
-rw-r--r-- | src/modules/module-null-sink.c | 9 | ||||
-rw-r--r-- | src/modules/module-pipe-sink.c | 9 | ||||
-rw-r--r-- | src/modules/module-pipe-source.c | 9 | ||||
-rw-r--r-- | src/modules/module-raop-sink.c | 9 | ||||
-rw-r--r-- | src/modules/module-remap-sink.c | 9 | ||||
-rw-r--r-- | src/modules/module-sine-source.c | 9 | ||||
-rw-r--r-- | src/pulsecore/cli-text.c | 2 | ||||
-rw-r--r-- | src/pulsecore/module.c | 19 | ||||
-rw-r--r-- | src/pulsecore/module.h | 5 | ||||
-rw-r--r-- | src/pulsecore/protocol-native.c | 4 |
17 files changed, 124 insertions, 16 deletions
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c index 3fa0b5db..a3e818dd 100644 --- a/src/modules/module-alsa-sink.c +++ b/src/modules/module-alsa-sink.c @@ -1610,6 +1610,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_sink_linked_by(u->sink); +} + void pa__done(pa_module*m) { struct userdata *u; diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c index 22e9ebfc..901db01f 100644 --- a/src/modules/module-alsa-source.c +++ b/src/modules/module-alsa-source.c @@ -1431,6 +1431,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_source_linked_by(u->source); +} + void pa__done(pa_module*m) { struct userdata *u; diff --git a/src/modules/module-defs.h.m4 b/src/modules/module-defs.h.m4 index 64ce1928..f9924cfa 100644 --- a/src/modules/module-defs.h.m4 +++ b/src/modules/module-defs.h.m4 @@ -18,9 +18,11 @@ gen_symbol(pa__get_description) gen_symbol(pa__get_usage) gen_symbol(pa__get_version) gen_symbol(pa__load_once) +gen_symbol(pa__get_n_used) int pa__init(pa_module*m); void pa__done(pa_module*m); +int pa__get_n_used(pa_module*m); const char* pa__get_author(void); const char* pa__get_description(void); diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c index 14f1810a..7c7f8284 100644 --- a/src/modules/module-esound-sink.c +++ b/src/modules/module-esound-sink.c @@ -621,6 +621,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_sink_linked_by(u->sink); +} + void pa__done(pa_module*m) { struct userdata *u; pa_assert(m); diff --git a/src/modules/module-jack-sink.c b/src/modules/module-jack-sink.c index 555cb825..b448e84e 100644 --- a/src/modules/module-jack-sink.c +++ b/src/modules/module-jack-sink.c @@ -430,6 +430,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_sink_linked_by(u->sink); +} + void pa__done(pa_module*m) { struct userdata *u; diff --git a/src/modules/module-jack-source.c b/src/modules/module-jack-source.c index 9eccbbfa..0c7ee535 100644 --- a/src/modules/module-jack-source.c +++ b/src/modules/module-jack-source.c @@ -398,6 +398,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_source_linked_by(u->source); +} + void pa__done(pa_module*m) { struct userdata *u; pa_assert(m); diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c index 496e9ea5..e746f342 100644 --- a/src/modules/module-ladspa-sink.c +++ b/src/modules/module-ladspa-sink.c @@ -770,6 +770,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_sink_linked_by(u->sink); +} + void pa__done(pa_module*m) { struct userdata *u; unsigned c; diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c index daf9767c..570f8be4 100644 --- a/src/modules/module-null-sink.c +++ b/src/modules/module-null-sink.c @@ -324,6 +324,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_sink_linked_by(u->sink); +} + void pa__done(pa_module*m) { struct userdata *u; diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c index 2b55c823..03e27170 100644 --- a/src/modules/module-pipe-sink.c +++ b/src/modules/module-pipe-sink.c @@ -315,6 +315,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_sink_linked_by(u->sink); +} + void pa__done(pa_module*m) { struct userdata *u; diff --git a/src/modules/module-pipe-source.c b/src/modules/module-pipe-source.c index 77310cab..975090c2 100644 --- a/src/modules/module-pipe-source.c +++ b/src/modules/module-pipe-source.c @@ -302,6 +302,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_source_linked_by(u->source); +} + void pa__done(pa_module*m) { struct userdata *u; diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c index 62f0a73c..c324437e 100644 --- a/src/modules/module-raop-sink.c +++ b/src/modules/module-raop-sink.c @@ -627,6 +627,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_sink_linked_by(u->sink); +} + void pa__done(pa_module*m) { struct userdata *u; pa_assert(m); diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c index aa914066..e17fef03 100644 --- a/src/modules/module-remap-sink.c +++ b/src/modules/module-remap-sink.c @@ -415,6 +415,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_sink_linked_by(u->sink); +} + void pa__done(pa_module*m) { struct userdata *u; diff --git a/src/modules/module-sine-source.c b/src/modules/module-sine-source.c index 79d3b137..5626c2ab 100644 --- a/src/modules/module-sine-source.c +++ b/src/modules/module-sine-source.c @@ -286,6 +286,15 @@ fail: return -1; } +int pa__get_n_used(pa_module *m) { + struct userdata *u; + + pa_assert(m); + pa_assert_se(u = m->userdata); + + return pa_source_linked_by(u->source); +} + void pa__done(pa_module*m) { struct userdata *u; diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c index 27db56e5..0f4a273d 100644 --- a/src/pulsecore/cli-text.c +++ b/src/pulsecore/cli-text.c @@ -62,7 +62,7 @@ char *pa_module_list_to_string(pa_core *c) { m->index, m->name, pa_strempty(m->argument), - m->n_used, + pa_module_get_n_used(m), pa_yes_no(m->load_once)); } diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c index b197ba06..c4dcb478 100644 --- a/src/pulsecore/module.c +++ b/src/pulsecore/module.c @@ -45,8 +45,7 @@ #define PA_SYMBOL_INIT "pa__init" #define PA_SYMBOL_DONE "pa__done" #define PA_SYMBOL_LOAD_ONCE "pa__load_once" - -#define UNLOAD_POLL_TIME 2 +#define PA_SYMBOL_GET_N_USED "pa__get_n_used" pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) { pa_module *m = NULL; @@ -92,9 +91,9 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) { } m->done = (void (*)(pa_module*_m)) pa_load_sym(m->dl, name, PA_SYMBOL_DONE); + m->get_n_used = (int (*)(pa_module*_m)) pa_load_sym(m->dl, name, PA_SYMBOL_GET_N_USED); m->userdata = NULL; m->core = c; - m->n_used = -1; m->unload_requested = FALSE; if (m->init(m) < 0) { @@ -235,17 +234,17 @@ void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, pa_bool_t force pa_module_unload_request(m, force); } -void pa_module_set_used(pa_module*m, int used) { +pa_modinfo *pa_module_get_info(pa_module *m) { pa_assert(m); - if (m->n_used != used) - pa_subscription_post(m->core, PA_SUBSCRIPTION_EVENT_MODULE|PA_SUBSCRIPTION_EVENT_CHANGE, m->index); - - m->n_used = used; + return pa_modinfo_get_by_handle(m->dl, m->name); } -pa_modinfo *pa_module_get_info(pa_module *m) { +int pa_module_get_n_used(pa_module*m) { pa_assert(m); - return pa_modinfo_get_by_handle(m->dl, m->name); + if (!m->get_n_used) + return -1; + + return m->get_n_used(m); } diff --git a/src/pulsecore/module.h b/src/pulsecore/module.h index c54169bf..986f0d22 100644 --- a/src/pulsecore/module.h +++ b/src/pulsecore/module.h @@ -39,11 +39,10 @@ struct pa_module { int (*init)(pa_module*m); void (*done)(pa_module*m); + int (*get_n_used)(pa_module *m); void *userdata; - int n_used; - pa_bool_t load_once:1; pa_bool_t unload_requested:1; }; @@ -58,7 +57,7 @@ void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, pa_bool_t force void pa_module_unload_all(pa_core *c); -void pa_module_set_used(pa_module*m, int used); +int pa_module_get_n_used(pa_module*m); #define PA_MODULE_AUTHOR(s) \ const char *pa__get_author(void) { return s; } \ diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 0a070f47..af013da3 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -2731,8 +2731,8 @@ static void module_fill_tagstruct(pa_tagstruct *t, pa_module *module) { pa_tagstruct_putu32(t, module->index); pa_tagstruct_puts(t, module->name); pa_tagstruct_puts(t, module->argument); - pa_tagstruct_putu32(t, (uint32_t) module->n_used); - pa_tagstruct_put_boolean(t, FALSE); + pa_tagstruct_putu32(t, (uint32_t) pa_module_get_n_used(module)); + pa_tagstruct_put_boolean(t, FALSE); /* autoload is obsolete */ } static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sink_input *s) { |