]> code.delx.au - pulseaudio/commitdiff
allow setting properties for modules, too
authorLennart Poettering <lennart@poettering.net>
Mon, 19 Jan 2009 21:02:28 +0000 (22:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 19 Jan 2009 21:02:28 +0000 (22:02 +0100)
PROTOCOL
src/pulse/introspect.c
src/pulse/introspect.h
src/pulse/proplist.h
src/pulsecore/cli-command.c
src/pulsecore/cli-text.c
src/pulsecore/module.c
src/pulsecore/module.h
src/pulsecore/protocol-native.c

index 37f289a5fad7831c9e901fdacb3b24b01bdaae75..8c5937b340399407f0e564dcce2fbc8675a985df 100644 (file)
--- a/PROTOCOL
+++ b/PROTOCOL
@@ -154,7 +154,6 @@ PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR at the end:
 
   early_requests (bool)
 
-
 ### v15, implemented by >= 0.9.15
 
 PA_COMMAND_CREATE_PLAYBACK_STREAM
@@ -163,4 +162,9 @@ PA_COMMAND_CREATE_PLAYBACK_STREAM
 
 PA_COMMAND_CREATE_PLAYBACK_STREAM, PA_COMMAND_CREATE_RECORD_STREAM:
 
-  bool dont_inhibit_auto_suspend ate the end
+  bool dont_inhibit_auto_suspend at the end
+
+PA_COMMAND_GET_MODULE_INFO_LIST
+
+  remove bool auto_unload
+  add proplist at the end
index bdc50e29580190b9ddedd39239f8cd18334a1df9..e7fa6d760f16c7d35d6109b2c33bb9ac39f4b431 100644 (file)
@@ -480,13 +480,16 @@ static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command,
         while (!pa_tagstruct_eof(t)) {
             pa_module_info i;
             pa_bool_t auto_unload = FALSE;
+
             memset(&i, 0, sizeof(i));
+            i.proplist = pa_proplist_new();
 
             if (pa_tagstruct_getu32(t, &i.index) < 0 ||
                 pa_tagstruct_gets(t, &i.name) < 0 ||
                 pa_tagstruct_gets(t, &i.argument) < 0 ||
                 pa_tagstruct_getu32(t, &i.n_used) < 0 ||
-                pa_tagstruct_get_boolean(t, &auto_unload) < 0) {
+                (o->context->version < 15 && pa_tagstruct_get_boolean(t, &auto_unload) < 0) ||
+                (o->context->version >= 15 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) {
                 pa_context_fail(o->context, PA_ERR_PROTOCOL);
                 goto finish;
             }
@@ -497,6 +500,8 @@ static void context_get_module_info_callback(pa_pdispatch *pd, uint32_t command,
                 pa_module_info_cb_t cb = (pa_module_info_cb_t) o->callback;
                 cb(o->context, &i, 0, o->userdata);
             }
+
+            pa_proplist_free(i.proplist);
         }
     }
 
index ae9bd5bc7dbbb7fba9ceb1688501647a7218fa72..428826e6428c42ab8278a3c13f028340366621da 100644 (file)
@@ -333,6 +333,7 @@ typedef struct pa_module_info {
 /** \cond fulldocs */
     int auto_unload;                    /**< \deprecated Non-zero if this is an autoloaded module */
 /** \endcond */
+    pa_proplist *proplist;              /**< Property list \since 0.9.15 */
 } pa_module_info;
 
 /** Callback prototype for pa_context_get_module_info() and firends*/
index 8f44df277656b1cd9718405a14e355d1157d53dc..529871f88ba1f1d31e34d94c6f762aa7eacb91ea 100644 (file)
@@ -128,6 +128,10 @@ PA_C_DECL_BEGIN
 #define PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE "device.buffering.fragment_size"
 #define PA_PROP_DEVICE_PROFILE_NAME            "device.profile.name"
 #define PA_PROP_DEVICE_PROFILE_DESCRIPTION     "device.profile.description"
+#define PA_PROP_MODULE_AUTHOR                  "module.author"
+#define PA_PROP_MODULE_DESCRIPTION             "module.description"
+#define PA_PROP_MODULE_USAGE                   "module.usage"
+#define PA_PROP_MODULE_VERSION                 "module.version"
 
 /** A property list object. Basically a dictionary with UTF-8 strings
  * as keys and arbitrary data as values. \since 0.9.11 */
index 8f5d9bddf543c2c7adaa5c90b6d7d0f33a45069a..f810579ed70af75b4ac099a658fe2a2838f6351c 100644 (file)
@@ -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"
 
index 5c3d3af6e668b5d4a61ea4508a09e78fcf65c9fc..cbd36e2a77e9ac723a82ded826d54f851ffdf7da 100644 (file)
@@ -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);
index 0a8c8f576d90b771057952e7e19260ce8b948804..d470bb0bbff669d749bfa4df1982225f12a224cd 100644 (file)
 
 #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);
index 5c49bd2db21b10529de2aec1024bbdc30b75fae1..6ab43dcfd19f2a5abfd39e822e70933135789750 100644 (file)
@@ -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);
index 5412267991fd6b69afecb16249294f24e19d0e1e..eb555050af0412a7eb03765742d81fc1fe916b98 100644 (file)
@@ -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)