[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, stable-queue, updated. v0.9.21-95-ga21b832

Colin Guthrie gitmailer-noreply at 0pointer.de
Wed Sep 29 14:10:30 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 stable-queue branch has been updated
      from  9729966ac35fee8d8a4638296b892475a9b8e88d (commit)

- Log -----------------------------------------------------------------
a21b832 device-manager: Ensure that sinks/sources populate the device manager lists in order of their priority.
858abe6 augment-properties: Search for .desktop files in subfolders too.
a7a6f44 stream-restore: Clear the save_sink/save_source flags on apply_entry.
-----------------------------------------------------------------------

Summary of changes:
 src/modules/module-augment-properties.c |   44 +++++++++++++++++++--
 src/modules/module-device-manager.c     |   64 ++++++++++++++++++++++++++++--
 src/modules/module-stream-restore.c     |   48 +++++++++++++++++------
 3 files changed, 134 insertions(+), 22 deletions(-)

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

commit a7a6f4427d77e60d62abae120791c3300e477c24
Author: Colin Guthrie <cguthrie at mandriva.org>
Date:   Fri Feb 5 00:15:38 2010 +0000

    stream-restore: Clear the save_sink/save_source flags on apply_entry.
    
    If the user specifically removes the device element from the stream
    restore rule, we have to clear the save_sink/save_source flag of the
    stream. This means that other stream routing systems
    (e.g. module-device-manager) can take over routing for this
    stream. In order to facilitate the reapplication of other routing
    rules, we fire a stream change event. Arguably the stream itself
    has not changed, but the rules governing its routing have, so
    I feel this is justified.

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 00ce5ab..24d1c51 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -742,12 +742,24 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) {
             pa_sink_input_set_mute(si, e->muted, TRUE);
         }
 
-        if (u->restore_device &&
-            e->device_valid &&
-            (s = pa_namereg_get(u->core, e->device, PA_NAMEREG_SINK))) {
-
-            pa_log_info("Restoring device for stream %s.", name);
-            pa_sink_input_move_to(si, s, TRUE);
+        if (u->restore_device) {
+            if (!e->device_valid) {
+                if (si->save_sink) {
+                    pa_log_info("Ensuring device is not saved for stream %s.", name);
+                    /* If the device is not valid we should make sure the
+                       save flag is cleared as the user may have specifically
+                       removed the sink element from the rule. */
+                    si->save_sink = FALSE;
+                    /* This is cheating a bit. The sink input itself has not changed
+                       but the rules governing it's routing have, so we fire this event
+                       such that other routing modules (e.g. module-device-manager)
+                       will pick up the change and reapply their routing */
+                    pa_subscription_post(si->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, si->index);
+                }
+            } else if ((s = pa_namereg_get(u->core, e->device, PA_NAMEREG_SINK))) {
+                pa_log_info("Restoring device for stream %s.", name);
+                pa_sink_input_move_to(si, s, TRUE);
+            }
         }
     }
 
@@ -764,12 +776,24 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) {
         }
         pa_xfree(n);
 
-        if (u->restore_device &&
-            e->device_valid &&
-            (s = pa_namereg_get(u->core, e->device, PA_NAMEREG_SOURCE))) {
-
-            pa_log_info("Restoring device for stream %s.", name);
-            pa_source_output_move_to(so, s, TRUE);
+        if (u->restore_device) {
+            if (!e->device_valid) {
+                if (so->save_source) {
+                    pa_log_info("Ensuring device is not saved for stream %s.", name);
+                    /* If the device is not valid we should make sure the
+                       save flag is cleared as the user may have specifically
+                       removed the source element from the rule. */
+                    so->save_source = FALSE;
+                    /* This is cheating a bit. The source output itself has not changed
+                       but the rules governing it's routing have, so we fire this event
+                       such that other routing modules (e.g. module-device-manager)
+                       will pick up the change and reapply their routing */
+                    pa_subscription_post(so->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_CHANGE, so->index);
+                }
+            } else if ((s = pa_namereg_get(u->core, e->device, PA_NAMEREG_SOURCE))) {
+                pa_log_info("Restoring device for stream %s.", name);
+                pa_source_output_move_to(so, s, TRUE);
+            }
         }
     }
 }

commit 858abe6cb977de4474d5243d53ff245ef0e0fb49
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 a21b8328aab906f9128f4c5597115608fa4045bc
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 3991043..53bb7e2 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