mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-12 13:30:10 -05:00
rework module usage counter stuff to be pull based
This commit is contained in:
parent
edf88a5150
commit
bae221cca9
17 changed files with 126 additions and 18 deletions
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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_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;
|
||||
}
|
||||
|
||||
pa_modinfo *pa_module_get_info(pa_module *m) {
|
||||
pa_assert(m);
|
||||
|
||||
return pa_modinfo_get_by_handle(m->dl, m->name);
|
||||
}
|
||||
|
||||
int pa_module_get_n_used(pa_module*m) {
|
||||
pa_assert(m);
|
||||
|
||||
if (!m->get_n_used)
|
||||
return -1;
|
||||
|
||||
return m->get_n_used(m);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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; } \
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue