[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.19-571-gb02abcb

Colin Guthrie gitmailer-noreply at 0pointer.de
Wed Sep 29 14:08:59 PDT 2010


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  f25676c2bb6780fee796f72220e43f89d9eb7dd9 (commit)

- Log -----------------------------------------------------------------
b02abcb device-manager: Ensure that sinks/sources populate the device manager lists in order of their priority.
098e9ea augment-properties: Search for .desktop files in subfolders too.
-----------------------------------------------------------------------

Summary of changes:
 src/modules/module-augment-properties.c |   44 +++++++++++++++++++--
 src/modules/module-device-manager.c     |   64 ++++++++++++++++++++++++++++--
 2 files changed, 98 insertions(+), 10 deletions(-)

-----------------------------------------------------------------------

commit 098e9ea1fb912897b9e9a71a461ec2f6a09a9fcc
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Sun Jan 31 16:35:41 2010 +0000

    augment-properties: Search for .desktop files in subfolders too.

diff --git a/src/modules/module-augment-properties.c b/src/modules/module-augment-properties.c
index 15aa3a1..f80c9ce 100644
--- a/src/modules/module-augment-properties.c
+++ b/src/modules/module-augment-properties.c
@@ -24,6 +24,7 @@
 #endif
 
 #include <sys/stat.h>
+#include <dirent.h>
 
 #include <pulse/xmalloc.h>
 #include <pulse/volume.h>
@@ -168,20 +169,53 @@ static void update_rule(struct rule *r) {
         { NULL,  catch_all, NULL, NULL },
         { NULL, NULL, NULL, NULL },
     };
+    pa_bool_t found = FALSE;
 
     pa_assert(r);
     fn = pa_sprintf_malloc(DESKTOPFILEDIR PA_PATH_SEP "%s.desktop", r->process_name);
 
-    if (stat(fn, &st) < 0) {
+    if (stat(fn, &st) == 0)
+        found = TRUE;
+    else {
+        DIR *desktopfiles_dir;
+        struct dirent *dir;
+
+        /* Let's try a more aggressive search, but only one level */
+        if ((desktopfiles_dir = opendir(DESKTOPFILEDIR))) {
+            while ((dir = readdir(desktopfiles_dir))) {
+                if (dir->d_type != DT_DIR
+                    || strcmp(dir->d_name, ".") == 0
+                    || strcmp(dir->d_name, "..") == 0)
+                    continue;
+
+                pa_xfree(fn);
+                fn = pa_sprintf_malloc(DESKTOPFILEDIR
+                                       PA_PATH_SEP "%s" PA_PATH_SEP "%s.desktop",
+                                       dir->d_name, r->process_name);
+
+                if (stat(fn, &st) == 0) {
+                    found = TRUE;
+                    break;
+                }
+            }
+            closedir(desktopfiles_dir);
+        }
+    }
+    if (!found) {
         r->good = FALSE;
         pa_xfree(fn);
         return;
     }
 
-    if (r->good && st.st_mtime == r->mtime) {
-        pa_xfree(fn);
-        return;
-    }
+    if (r->good)
+        if (st.st_mtime == r->mtime) {
+            /* Theoretically the filename could have changed, but if so
+               having the same mtime is very unlikely so not worth tracking it in r */
+            pa_xfree(fn);
+            return;
+        }
+    else
+        pa_log_debug("Found %s.", fn);
 
     r->good = TRUE;
     r->mtime = st.st_mtime;

commit b02abcb61303a571eeec80f7f1917a256d68290f
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Fri Jun 4 09:36:57 2010 +0100

    device-manager: Ensure that sinks/sources populate the device manager lists in order of their priority.
    
    Currently the order of the sinks is simply that of their position in the idxset which is certainly
    not what the user would want.

diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c
index 8d61ff4..daa7562 100644
--- a/src/modules/module-device-manager.c
+++ b/src/modules/module-device-manager.c
@@ -1389,6 +1389,11 @@ static pa_hook_result_t connection_unlink_hook_cb(pa_native_protocol *p, pa_nati
     return PA_HOOK_OK;
 }
 
+struct prioritised_indexes {
+    uint32_t index;
+    int32_t priority;
+};
+
 int pa__init(pa_module*m) {
     pa_modargs *ma = NULL;
     struct userdata *u;
@@ -1397,6 +1402,7 @@ int pa__init(pa_module*m) {
     pa_source *source;
     uint32_t idx;
     pa_bool_t do_routing = FALSE, on_hotplug = TRUE, on_rescue = TRUE;
+    uint32_t total_devices;
 
     pa_assert(m);
 
@@ -1460,12 +1466,60 @@ int pa__init(pa_module*m) {
     pa_log_info("Sucessfully opened database file '%s'.", fname);
     pa_xfree(fname);
 
-    /* We cycle over all the available sinks so that they are added to our database if they are not in it yet */
-    PA_IDXSET_FOREACH(sink, m->core->sinks, idx)
-        subscribe_callback(m->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_NEW, sink->index, u);
+    /* Attempt to inject the devices into the list in priority order */
+    total_devices = PA_MAX(pa_idxset_size(m->core->sinks), pa_idxset_size(m->core->sources));
+    if (total_devices > 0 && total_devices < 128) {
+        uint32_t i;
+        struct prioritised_indexes p_i[128];
+
+        /* We cycle over all the available sinks so that they are added to our database if they are not in it yet */
+        i = 0;
+        PA_IDXSET_FOREACH(sink, m->core->sinks, idx) {
+            pa_log_debug("Found sink index %u", sink->index);
+            p_i[i  ].index = sink->index;
+            p_i[i++].priority = sink->priority;
+        }
+        /* Bubble sort it (only really useful for first time creation) */
+        if (i > 1)
+          for (uint32_t j = 0; j < i; ++j)
+              for (uint32_t k = 0; k < i; ++k)
+                  if (p_i[j].priority > p_i[k].priority) {
+                      struct prioritised_indexes tmp_pi = p_i[k];
+                      p_i[k] = p_i[j];
+                      p_i[j] = tmp_pi;
+                  }
+        /* Register it */
+        for (uint32_t j = 0; j < i; ++j)
+            subscribe_callback(m->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_NEW, p_i[j].index, u);
+
+
+        /* We cycle over all the available sources so that they are added to our database if they are not in it yet */
+        i = 0;
+        PA_IDXSET_FOREACH(source, m->core->sources, idx) {
+            p_i[i  ].index = source->index;
+            p_i[i++].priority = source->priority;
+        }
+        /* Bubble sort it (only really useful for first time creation) */
+        if (i > 1)
+          for (uint32_t j = 0; j < i; ++j)
+              for (uint32_t k = 0; k < i; ++k)
+                  if (p_i[j].priority > p_i[k].priority) {
+                      struct prioritised_indexes tmp_pi = p_i[k];
+                      p_i[k] = p_i[j];
+                      p_i[j] = tmp_pi;
+                  }
+        /* Register it */
+        for (uint32_t j = 0; j < i; ++j)
+            subscribe_callback(m->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_NEW, p_i[j].index, u);
+    }
+    else if (total_devices > 0) {
+        /* This user has a *lot* of devices... */
+        PA_IDXSET_FOREACH(sink, m->core->sinks, idx)
+            subscribe_callback(m->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_NEW, sink->index, u);
 
-    PA_IDXSET_FOREACH(source, m->core->sources, idx)
-        subscribe_callback(m->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_NEW, source->index, u);
+        PA_IDXSET_FOREACH(source, m->core->sources, idx)
+            subscribe_callback(m->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_NEW, source->index, u);
+    }
 
     /* Perform the routing (if it's enabled) which will update our priority list cache too */
     for (uint32_t i = 0; i < NUM_ROLES; ++i) {

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list