From d97a9bf44b83edd8b12d382aa3b453edc35538b7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 25 Jun 2026 09:10:47 +0200 Subject: [PATCH] pulse-server: actually print properties of module When inspecting the loaded modules, actually list the properties that were used when loading the module instead of the informational generic ones from the info. Pulsaudio also does not list the Usage properties when listing modules. --- .../module-protocol-pulse/message-handler.c | 24 ++----------- src/modules/module-protocol-pulse/module.c | 36 +++++++++++++++++++ src/modules/module-protocol-pulse/module.h | 1 + .../module-protocol-pulse/pulse-server.c | 2 +- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/modules/module-protocol-pulse/message-handler.c b/src/modules/module-protocol-pulse/message-handler.c index 33f2e3124..de39cd5f8 100644 --- a/src/modules/module-protocol-pulse/message-handler.c +++ b/src/modules/module-protocol-pulse/message-handler.c @@ -293,27 +293,9 @@ static int core_object_message_handler(struct client *client, struct pw_manager_ if ((s = spa_dict_lookup(i->properties, PW_KEY_MODULE_AUTHOR))) fprintf(response, "Author: %s\n", s); if (i->valid_args) { - const struct module_args *a; - fprintf(response, "Usage:"); - for (a = i->valid_args; a->key; a++) { - fprintf(response, " %s=<%s", a->key, a->type); - if (a->def) - fprintf(response, ", default %s", a->def); - fprintf(response, ", %s", a->description); - if (a->vals) { - const char **v; - fprintf(response, " ["); - for (v = a->vals; *v; v++) - fprintf(response, "%s%s", v == a->vals ? "" : "|", *v); - fprintf(response, "]"); - } - if (a->flags & MODULE_ARG_MANDATORY) - fprintf(response, " (mandatory)"); - if (a->flags & MODULE_ARG_ENOTIMPL) - fprintf(response, " (not implemented)"); - fprintf(response, ">"); - } - fprintf(response, "\n"); + char *usage = module_info_usage(i); + fprintf(response, "Usage: %s\n", usage); + free(usage); } fprintf(response, "Load Once: %s\n", i->load_once ? "Yes": "No"); if ((s = spa_dict_lookup(i->properties, PW_KEY_MODULE_DEPRECATED))) diff --git a/src/modules/module-protocol-pulse/module.c b/src/modules/module-protocol-pulse/module.c index a0e980fb8..6dfe80490 100644 --- a/src/modules/module-protocol-pulse/module.c +++ b/src/modules/module-protocol-pulse/module.c @@ -376,6 +376,8 @@ struct module *module_create(struct impl *impl, const char *name, const char *ar errno = -res; goto error_free; } + if (info->properties) + pw_properties_update(module->props, info->properties); if ((res = module->info->prepare(module)) < 0) { errno = -res; @@ -414,3 +416,37 @@ struct module *module_lookup(struct impl *impl, uint32_t index, const char *name } return NULL; } + +char *module_info_usage(const struct module_info *i) +{ + const struct module_args *a; + FILE *f; + size_t size; + char *res; + + f = open_memstream(&res, &size); + if (f == NULL) + return NULL; + + for (a = i->valid_args; a->key; a++) { + fprintf(f, "%s=<%s", a->key, a->type); + if (a->def) + fprintf(f, ", default %s", a->def); + fprintf(f, ", %s", a->description); + if (a->vals) { + const char **v; + fprintf(f, " ["); + for (v = a->vals; *v; v++) + fprintf(f, "%s%s", v == a->vals ? "" : "|", *v); + fprintf(f, "]"); + } + if (a->flags & MODULE_ARG_MANDATORY) + fprintf(f, " (mandatory)"); + if (a->flags & MODULE_ARG_ENOTIMPL) + fprintf(f, " (not implemented)"); + fprintf(f, ">"); + } + fclose(f); + + return res; +} diff --git a/src/modules/module-protocol-pulse/module.h b/src/modules/module-protocol-pulse/module.h index 27aade2a4..bc57a2b58 100644 --- a/src/modules/module-protocol-pulse/module.h +++ b/src/modules/module-protocol-pulse/module.h @@ -86,6 +86,7 @@ struct module { const struct module_info *module_info_next(struct impl *impl, const struct module_info *info); const struct module_info *module_info_find(struct impl *impl, const char *name); +char *module_info_usage(const struct module_info *info); struct module *module_create(struct impl *impl, const char *name, const char *args); void module_free(struct module *module); diff --git a/src/modules/module-protocol-pulse/pulse-server.c b/src/modules/module-protocol-pulse/pulse-server.c index 4874e40f5..564f64ad8 100644 --- a/src/modules/module-protocol-pulse/pulse-server.c +++ b/src/modules/module-protocol-pulse/pulse-server.c @@ -3567,7 +3567,7 @@ static int fill_ext_module_info(struct client *client, struct message *m, } if (client->version >= 15) { message_put(m, - TAG_PROPLIST, module->info->properties, + TAG_PROPLIST, module->props, TAG_INVALID); } return 0;