mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-11 13:30:02 -05:00
allow setting properties for modules, too
This commit is contained in:
parent
fe703013ad
commit
b43a45d184
9 changed files with 61 additions and 9 deletions
|
|
@ -51,6 +51,7 @@
|
|||
#include <pulsecore/shared.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulsecore/modinfo.h>
|
||||
|
||||
#include "cli-command.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ char *pa_module_list_to_string(pa_core *c) {
|
|||
pa_strbuf_printf(s, "%u module(s) loaded.\n", pa_idxset_size(c->modules));
|
||||
|
||||
for (m = pa_idxset_first(c->modules, &idx); m; m = pa_idxset_next(c->modules, &idx)) {
|
||||
char *t;
|
||||
|
||||
pa_strbuf_printf(s, " index: %u\n"
|
||||
"\tname: <%s>\n"
|
||||
"\targument: <%s>\n"
|
||||
|
|
@ -64,6 +66,10 @@ char *pa_module_list_to_string(pa_core *c) {
|
|||
pa_strempty(m->argument),
|
||||
pa_module_get_n_used(m),
|
||||
pa_yes_no(m->load_once));
|
||||
|
||||
t = pa_proplist_to_string_sep(m->proplist, "\n\t\t");
|
||||
pa_strbuf_printf(s, "\tproperties:\n\t\t%s\n", t);
|
||||
pa_xfree(t);
|
||||
}
|
||||
|
||||
return pa_strbuf_tostring_free(s);
|
||||
|
|
|
|||
|
|
@ -33,12 +33,14 @@
|
|||
|
||||
#include <pulse/timeval.h>
|
||||
#include <pulse/xmalloc.h>
|
||||
#include <pulse/proplist.h>
|
||||
|
||||
#include <pulsecore/core-subscribe.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
#include <pulsecore/macro.h>
|
||||
#include <pulsecore/ltdl-helper.h>
|
||||
#include <pulsecore/modinfo.h>
|
||||
|
||||
#include "module.h"
|
||||
|
||||
|
|
@ -50,6 +52,7 @@
|
|||
pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
|
||||
pa_module *m = NULL;
|
||||
pa_bool_t (*load_once)(void);
|
||||
pa_modinfo *mi;
|
||||
|
||||
pa_assert(c);
|
||||
pa_assert(name);
|
||||
|
|
@ -61,6 +64,7 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
|
|||
m->name = pa_xstrdup(name);
|
||||
m->argument = pa_xstrdup(argument);
|
||||
m->load_once = FALSE;
|
||||
m->proplist = pa_proplist_new();
|
||||
|
||||
if (!(m->dl = lt_dlopenext(name))) {
|
||||
pa_log("Failed to open module \"%s\": %s", name, lt_dlerror());
|
||||
|
|
@ -111,11 +115,28 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
|
|||
|
||||
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_MODULE|PA_SUBSCRIPTION_EVENT_NEW, m->index);
|
||||
|
||||
if ((mi = pa_modinfo_get_by_handle(m->dl, name))) {
|
||||
|
||||
if (mi->author && !pa_proplist_contains(m->proplist, PA_PROP_MODULE_AUTHOR))
|
||||
pa_proplist_sets(m->proplist, PA_PROP_MODULE_AUTHOR, mi->author);
|
||||
|
||||
if (mi->description && !pa_proplist_contains(m->proplist, PA_PROP_MODULE_DESCRIPTION))
|
||||
pa_proplist_sets(m->proplist, PA_PROP_MODULE_DESCRIPTION, mi->description);
|
||||
|
||||
if (mi->version && !pa_proplist_contains(m->proplist, PA_PROP_MODULE_VERSION))
|
||||
pa_proplist_sets(m->proplist, PA_PROP_MODULE_VERSION, mi->version);
|
||||
|
||||
pa_modinfo_free(mi);
|
||||
}
|
||||
|
||||
return m;
|
||||
|
||||
fail:
|
||||
|
||||
if (m) {
|
||||
if (m->proplist)
|
||||
pa_proplist_free(m->proplist);
|
||||
|
||||
pa_xfree(m->argument);
|
||||
pa_xfree(m->name);
|
||||
|
||||
|
|
@ -137,6 +158,9 @@ static void pa_module_free(pa_module *m) {
|
|||
if (m->done)
|
||||
m->done(m);
|
||||
|
||||
if (m->proplist)
|
||||
pa_proplist_free(m->proplist);
|
||||
|
||||
lt_dlclose(m->dl);
|
||||
|
||||
pa_log_info("Unloaded \"%s\" (index: #%u).", m->name, m->index);
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@
|
|||
|
||||
typedef struct pa_module pa_module;
|
||||
|
||||
#include <pulse/proplist.h>
|
||||
|
||||
#include <pulsecore/core.h>
|
||||
#include <pulsecore/modinfo.h>
|
||||
|
||||
struct pa_module {
|
||||
pa_core *core;
|
||||
|
|
@ -45,6 +46,8 @@ struct pa_module {
|
|||
|
||||
pa_bool_t load_once:1;
|
||||
pa_bool_t unload_requested:1;
|
||||
|
||||
pa_proplist *proplist;
|
||||
};
|
||||
|
||||
pa_module* pa_module_load(pa_core *c, const char *name, const char*argument);
|
||||
|
|
|
|||
|
|
@ -2728,10 +2728,9 @@ static void client_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_c
|
|||
|
||||
if (c->version >= 13)
|
||||
pa_tagstruct_put_proplist(t, client->proplist);
|
||||
|
||||
}
|
||||
|
||||
static void module_fill_tagstruct(pa_tagstruct *t, pa_module *module) {
|
||||
static void module_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_module *module) {
|
||||
pa_assert(t);
|
||||
pa_assert(module);
|
||||
|
||||
|
|
@ -2739,7 +2738,12 @@ static void module_fill_tagstruct(pa_tagstruct *t, pa_module *module) {
|
|||
pa_tagstruct_puts(t, module->name);
|
||||
pa_tagstruct_puts(t, module->argument);
|
||||
pa_tagstruct_putu32(t, (uint32_t) pa_module_get_n_used(module));
|
||||
pa_tagstruct_put_boolean(t, FALSE); /* autoload is obsolete */
|
||||
|
||||
if (c->version < 15)
|
||||
pa_tagstruct_put_boolean(t, FALSE); /* autoload is obsolete */
|
||||
|
||||
if (c->version >= 15)
|
||||
pa_tagstruct_put_proplist(t, module->proplist);
|
||||
}
|
||||
|
||||
static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sink_input *s) {
|
||||
|
|
@ -2891,7 +2895,7 @@ static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, p
|
|||
else if (client)
|
||||
client_fill_tagstruct(c, reply, client);
|
||||
else if (module)
|
||||
module_fill_tagstruct(reply, module);
|
||||
module_fill_tagstruct(c, reply, module);
|
||||
else if (si)
|
||||
sink_input_fill_tagstruct(c, reply, si);
|
||||
else if (so)
|
||||
|
|
@ -2946,7 +2950,7 @@ static void command_get_info_list(pa_pdispatch *pd, uint32_t command, uint32_t t
|
|||
else if (command == PA_COMMAND_GET_CLIENT_INFO_LIST)
|
||||
client_fill_tagstruct(c, reply, p);
|
||||
else if (command == PA_COMMAND_GET_MODULE_INFO_LIST)
|
||||
module_fill_tagstruct(reply, p);
|
||||
module_fill_tagstruct(c, reply, p);
|
||||
else if (command == PA_COMMAND_GET_SINK_INPUT_INFO_LIST)
|
||||
sink_input_fill_tagstruct(c, reply, p);
|
||||
else if (command == PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue