[pulseaudio-discuss] [PATCH v3 06/12] gsettings: rename "module" to "module-group"

Tanu Kaskinen tanuk at iki.fi
Tue Apr 17 06:07:36 UTC 2018


It is confusing if there's a thing named "module" which defines up to 10
modules to load. Calling the thing a "module group" instead should make
it easier to understand.
---
 src/modules/gsettings/gsettings-helper.c           | 34 ++++++++++------------
 .../org.freedesktop.pulseaudio.gschema.xml         | 29 +++++++++++-------
 2 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/src/modules/gsettings/gsettings-helper.c b/src/modules/gsettings/gsettings-helper.c
index e0a00a6ca..51f61b009 100644
--- a/src/modules/gsettings/gsettings-helper.c
+++ b/src/modules/gsettings/gsettings-helper.c
@@ -30,21 +30,19 @@
 
 #include <pulsecore/core-util.h>
 
-#define PA_GSETTINGS_MODULE_SCHEMA "org.freedesktop.pulseaudio.module"
-#define PA_GSETTINGS_MODULES_SCHEMA "org.freedesktop.pulseaudio.modules"
-#define PA_GSETTINGS_MODULES_PATH "/org/freedesktop/pulseaudio/modules/"
+#define PA_GSETTINGS_MODULE_GROUP_SCHEMA "org.freedesktop.pulseaudio.module-group"
+#define PA_GSETTINGS_MODULE_GROUPS_SCHEMA "org.freedesktop.pulseaudio.module-groups"
+#define PA_GSETTINGS_MODULE_GROUPS_PATH "/org/freedesktop/pulseaudio/module-groups/"
 
-static void modules_callback(GSettings *settings, gchar *key, gpointer user_data);
-
-static void handle_module(gchar *name) {
+static void handle_module_group(gchar *name) {
     GSettings *settings;
     gchar p[1024];
     gboolean enabled;
     int i;
 
-    pa_snprintf(p, sizeof(p), PA_GSETTINGS_MODULES_PATH"%s/", name);
+    pa_snprintf(p, sizeof(p), PA_GSETTINGS_MODULE_GROUPS_PATH"%s/", name);
 
-    if (!(settings = g_settings_new_with_path(PA_GSETTINGS_MODULE_SCHEMA,
+    if (!(settings = g_settings_new_with_path(PA_GSETTINGS_MODULE_GROUP_SCHEMA,
                                               p)))
         return;
 
@@ -76,30 +74,30 @@ static void handle_module(gchar *name) {
     g_object_unref(G_OBJECT(settings));
 }
 
-static void modules_callback(GSettings *settings, gchar *key, gpointer user_data) {
-    handle_module(user_data);
+static void module_group_callback(GSettings *settings, gchar *key, gpointer user_data) {
+    handle_module_group(user_data);
 }
 
 int main(int argc, char *argv[]) {
     GMainLoop *g;
     GSettings *settings;
-    gchar **modules, **m;
+    gchar **group_names, **name;
 
 #if !GLIB_CHECK_VERSION(2,36,0)
     g_type_init();
 #endif
 
-    if (!(settings = g_settings_new(PA_GSETTINGS_MODULES_SCHEMA)))
+    if (!(settings = g_settings_new(PA_GSETTINGS_MODULE_GROUPS_SCHEMA)))
         goto fail;
 
-    g_signal_connect(settings, "changed", (GCallback) modules_callback, NULL);
+    g_signal_connect(settings, "changed", (GCallback) module_group_callback, NULL);
 
-    modules = g_settings_list_children (settings);
+    group_names = g_settings_list_children(settings);
 
-    for (m = modules; *m; m++) {
-        g_signal_connect(g_settings_get_child (settings, *m), "changed",
-                         (GCallback) modules_callback, *m);
-        handle_module(*m);
+    for (name = group_names; *name; name++) {
+        g_signal_connect(g_settings_get_child(settings, *name), "changed",
+                         (GCallback) module_group_callback, *name);
+        handle_module_group(*name);
     }
 
     /* Signal the parent that we are now initialized */
diff --git a/src/modules/gsettings/org.freedesktop.pulseaudio.gschema.xml b/src/modules/gsettings/org.freedesktop.pulseaudio.gschema.xml
index 644e77bda..9d06383de 100644
--- a/src/modules/gsettings/org.freedesktop.pulseaudio.gschema.xml
+++ b/src/modules/gsettings/org.freedesktop.pulseaudio.gschema.xml
@@ -1,19 +1,26 @@
 <schemalist gettext-domain="pulseaudio">
-  <schema id="org.freedesktop.pulseaudio.modules" path="/org/freedesktop/pulseaudio/modules/">
-    <child name="combine" schema="org.freedesktop.pulseaudio.module"/>
-    <child name="remote-access" schema="org.freedesktop.pulseaudio.module"/>
-    <child name="zeroconf-discover" schema="org.freedesktop.pulseaudio.module"/>
-    <child name="raop-discover" schema="org.freedesktop.pulseaudio.module"/>
-    <child name="rtp-recv" schema="org.freedesktop.pulseaudio.module"/>
-    <child name="rtp-send" schema="org.freedesktop.pulseaudio.module"/>
-    <child name="upnp-media-server" schema="org.freedesktop.pulseaudio.module"/>
+  <!-- The module-groups object is just an entry point to find the individual
+       module-group objects. -->
+  <schema id="org.freedesktop.pulseaudio.module-groups" path="/org/freedesktop/pulseaudio/module-groups/">
+    <child name="combine" schema="org.freedesktop.pulseaudio.module-group"/>
+    <child name="remote-access" schema="org.freedesktop.pulseaudio.module-group"/>
+    <child name="zeroconf-discover" schema="org.freedesktop.pulseaudio.module-group"/>
+    <child name="raop-discover" schema="org.freedesktop.pulseaudio.module-group"/>
+    <child name="rtp-recv" schema="org.freedesktop.pulseaudio.module-group"/>
+    <child name="rtp-send" schema="org.freedesktop.pulseaudio.module-group"/>
+    <child name="upnp-media-server" schema="org.freedesktop.pulseaudio.module-group"/>
   </schema>
 
-  <schema id="org.freedesktop.pulseaudio.module">
+  <!-- Paprefs puts related modules into groups that are enabled or disabled as
+       a whole. One group can contain up to 10 module instances (either of the
+       same module or different modules). A module-group object defines up to
+       10 modules to load. The name0..name9 keys contain the module names and
+       the args0..args9 keys provide the module arguments. -->
+  <schema id="org.freedesktop.pulseaudio.module-group">
     <key name="name" type="s">
       <default>''</default>
-      <summary>Module name</summary>
-      <description>Name of the pulseaudio module</description>
+      <summary>Module group name</summary>
+      <description>Module group name</description>
     </key>
 
     <key name="enabled" type="b">
-- 
2.16.3



More information about the pulseaudio-discuss mailing list