[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.16-test6-55-g1200a0b

Lennart Poettering gitmailer-noreply at 0pointer.de
Tue Sep 1 15:54:10 PDT 2009


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  46b9ca7fd5747d1ddbb7f2d18d2b572ddb785dc6 (commit)

- Log -----------------------------------------------------------------
1200a0b sink: simplify pa_sink_render_full() by replacing it by a pa_sink_render() plus a couple of pa_sink_render_full()
a8c0f65 daemon: clean up environment when forking off children
5f92996 core-util: add api for setting env vars and record them so that we can undo them n fork
45513a2 core: fill up memblock with pa_sink_render_into_full() in pa_sink_render_full() instead of doing our own loop
17f609a core: handle suspended state in pa_sink_render_full() similar to the other render functions
ce6dff4 core: add missing sink_unref()
b245b54 ladspa,remap: make description of sink follow moves
-----------------------------------------------------------------------

Summary of changes:
 src/daemon/main.c                |    7 ++-
 src/modules/module-ladspa-sink.c |   25 +++++++++-
 src/modules/module-remap-sink.c  |   24 ++++++++-
 src/pulsecore/core-util.c        |   30 ++++++++++++
 src/pulsecore/core-util.h        |    2 +
 src/pulsecore/sink.c             |   94 ++++++++------------------------------
 src/pulsecore/start-child.c      |    5 ++
 7 files changed, 104 insertions(+), 83 deletions(-)

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

commit b245b547025945aeca3717f987db3dd152559138
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Sep 1 06:06:04 2009 +0200

    ladspa,remap: make description of sink follow moves

diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 933fb18..994c778 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -82,6 +82,8 @@ struct userdata {
     LADSPA_Data control_out;
 
     pa_memblockq *memblockq;
+
+    pa_bool_t auto_desc;
 };
 
 static const char* const valid_modargs[] = {
@@ -423,6 +425,19 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
         pa_sink_update_flags(u->sink, PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY, dest->flags);
     } else
         pa_sink_set_asyncmsgq(u->sink, NULL);
+
+    if (u->auto_desc && dest) {
+        const char *z;
+        pa_proplist *pl;
+
+        pl = pa_proplist_new();
+        z = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION);
+        pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "LADSPA Plugin %s on %s",
+                         pa_proplist_gets(u->sink->proplist, "device.ladspa.name"), z ? z : dest->name);
+
+        pa_sink_update_proplist(u->sink, PA_UPDATE_REPLACE, pl);
+        pa_proplist_free(pl);
+    }
 }
 
 /* Called from main context */
@@ -451,7 +466,6 @@ int pa__init(pa_module*m) {
     pa_channel_map map;
     pa_modargs *ma;
     char *t;
-    const char *z;
     pa_sink *master;
     pa_sink_input_new_data sink_input_data;
     pa_sink_new_data sink_data;
@@ -765,8 +779,6 @@ int pa__init(pa_module*m) {
         sink_data.name = pa_sprintf_malloc("%s.ladspa", master->name);
     pa_sink_new_data_set_sample_spec(&sink_data, &ss);
     pa_sink_new_data_set_channel_map(&sink_data, &map);
-    z = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION);
-    pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "LADSPA Plugin %s on %s", d->Name, z ? z : master->name);
     pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_MASTER_DEVICE, master->name);
     pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_CLASS, "filter");
     pa_proplist_sets(sink_data.proplist, "device.ladspa.module", plugin);
@@ -782,6 +794,13 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) {
+        const char *z;
+
+        z = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION);
+        pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "LADSPA Plugin %s on %s", d->Name, z ? z : master->name);
+    }
+
     u->sink = pa_sink_new(m->core, &sink_data,
                           PA_SINK_HW_MUTE_CTRL|PA_SINK_HW_VOLUME_CTRL|PA_SINK_DECIBEL_VOLUME|
                           (master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY)));
diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c
index 6cfd0d1..43748bd 100644
--- a/src/modules/module-remap-sink.c
+++ b/src/modules/module-remap-sink.c
@@ -58,6 +58,8 @@ struct userdata {
 
     pa_sink *sink;
     pa_sink_input *sink_input;
+
+    pa_bool_t auto_desc;
 };
 
 static const char* const valid_modargs[] = {
@@ -307,6 +309,18 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
         pa_sink_update_flags(u->sink, PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY, dest->flags);
     } else
         pa_sink_set_asyncmsgq(u->sink, NULL);
+
+    if (u->auto_desc && dest) {
+        const char *k;
+        pa_proplist *pl;
+
+        pl = pa_proplist_new();
+        k = pa_proplist_gets(dest->proplist, PA_PROP_DEVICE_DESCRIPTION);
+        pa_proplist_setf(pl, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", k ? k : dest->name);
+
+        pa_sink_update_proplist(u->sink, PA_UPDATE_REPLACE, pl);
+        pa_proplist_free(pl);
+    }
 }
 
 int pa__init(pa_module*m) {
@@ -314,7 +328,6 @@ int pa__init(pa_module*m) {
     pa_sample_spec ss;
     pa_channel_map sink_map, stream_map;
     pa_modargs *ma;
-    const char *k;
     pa_sink *master;
     pa_sink_input_new_data sink_input_data;
     pa_sink_new_data sink_data;
@@ -370,8 +383,6 @@ int pa__init(pa_module*m) {
         sink_data.name = pa_sprintf_malloc("%s.remapped", master->name);
     pa_sink_new_data_set_sample_spec(&sink_data, &ss);
     pa_sink_new_data_set_channel_map(&sink_data, &sink_map);
-    k = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION);
-    pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", k ? k : master->name);
     pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_MASTER_DEVICE, master->name);
     pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_CLASS, "filter");
 
@@ -381,6 +392,13 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    if ((u->auto_desc = !pa_proplist_contains(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION))) {
+        const char *k;
+
+        k = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION);
+        pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", k ? k : master->name);
+    }
+
     u->sink = pa_sink_new(m->core, &sink_data, master->flags & (PA_SINK_LATENCY|PA_SINK_DYNAMIC_LATENCY));
     pa_sink_new_data_done(&sink_data);
 

commit ce6dff4ee0a3fe6e0339eb1f5d605caf8af3f989
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Sep 1 22:18:01 2009 +0200

    core: add missing sink_unref()

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index f5a6fc5..2362db8 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -893,6 +893,8 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
         result->memblock = pa_memblock_ref(s->silence.memblock);
         result->index = s->silence.index;
         result->length = PA_MIN(s->silence.length, length);
+
+        pa_sink_unref(s);
         return;
     }
 
@@ -980,6 +982,7 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) {
 
     if (s->thread_info.state == PA_SINK_SUSPENDED) {
         pa_silence_memchunk(target, &s->sample_spec);
+        pa_sink_unref(s);
         return;
     }
 

commit 17f609ac830a4a6be9658c7220292a038b2c59ac
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Sep 1 22:18:55 2009 +0200

    core: handle suspended state in pa_sink_render_full() similar to the other render functions

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 2362db8..e1ab96d 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1099,7 +1099,16 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
     pa_assert(!s->thread_info.rewind_requested);
     pa_assert(s->thread_info.rewind_nbytes == 0);
 
-    pa_assert(length > 0);
+    if (s->thread_info.state == PA_SINK_SUSPENDED) {
+        pa_silence_memchunk_get(&s->core->silence_cache,
+                                s->core->mempool,
+                                result,
+                                &s->sample_spec,
+                                length1st);
+
+        pa_sink_unref(s);
+        return;
+    }
 
     n = fill_mix_info(s, &length1st, info, MAX_MIX_CHANNELS);
 

commit 45513a2077719850353a9eb34f32ac4548c0dbea
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Sep 1 22:19:30 2009 +0200

    core: fill up memblock with pa_sink_render_into_full() in pa_sink_render_full() instead of doing our own loop

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index e1ab96d..9388d30 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1163,21 +1163,15 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
 
     if (result->length < length) {
         pa_memchunk chunk;
-        size_t l, d;
+
         pa_memchunk_make_writable(result, length);
 
-        l = length - result->length;
-        d = result->index + result->length;
-        while (l > 0) {
-            chunk = *result;
-            chunk.index = d;
-            chunk.length = l;
+        chunk.memblock = result->memblock;
+        chunk.index = result->index + result->length;
+        chunk.length = length - result->length;
 
-            pa_sink_render_into(s, &chunk);
+        pa_sink_render_into_full(s, &chunk);
 
-            d += chunk.length;
-            l -= chunk.length;
-        }
         result->length = length;
     }
 

commit 5f929963d12c70193a923d620177125d8608f18a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 2 00:34:27 2009 +0200

    core-util: add api for setting env vars and record them so that we can undo them n fork

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 6782301..9034dc3 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -116,6 +116,7 @@
 #include <pulsecore/thread.h>
 #include <pulsecore/strbuf.h>
 #include <pulsecore/usergroup.h>
+#include <pulsecore/strlist.h>
 
 #include "core-util.h"
 
@@ -124,6 +125,8 @@
 #define MSG_NOSIGNAL 0
 #endif
 
+static pa_strlist *recorded_env = NULL;
+
 #ifdef OS_IS_WIN32
 
 #define PULSE_ROOTENV "PULSE_ROOT"
@@ -2451,9 +2454,36 @@ void pa_set_env(const char *key, const char *value) {
     pa_assert(key);
     pa_assert(value);
 
+    /* This is not thread-safe */
+
     putenv(pa_sprintf_malloc("%s=%s", key, value));
 }
 
+void pa_set_env_and_record(const char *key, const char *value) {
+    pa_assert(key);
+    pa_assert(value);
+
+    /* This is not thread-safe */
+
+    pa_set_env(key, value);
+    recorded_env = pa_strlist_prepend(recorded_env, key);
+}
+
+void pa_unset_env_recorded(void) {
+
+    /* This is not thread-safe */
+
+    for (;;) {
+        char *s = NULL;
+
+        if (!(recorded_env = pa_strlist_pop(recorded_env, &s)))
+            break;
+
+        unsetenv(s);
+        pa_xfree(s);
+    }
+}
+
 pa_bool_t pa_in_system_mode(void) {
     const char *e;
 
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 2551f79..ccc9a38 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -195,6 +195,8 @@ int pa_reset_sigs(int except, ...);
 int pa_reset_sigsv(const int except[]);
 
 void pa_set_env(const char *key, const char *value);
+void pa_set_env_and_record(const char *key, const char *value);
+void pa_unset_env_recorded(void);
 
 pa_bool_t pa_in_system_mode(void);
 

commit a8c0f65faecd7058de3bd704ed90985ae2c842f0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 2 00:42:54 2009 +0200

    daemon: clean up environment when forking off children

diff --git a/src/daemon/main.c b/src/daemon/main.c
index e44892d..e22e465 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -706,7 +706,7 @@ int main(int argc, char *argv[]) {
 #endif
     }
 
-    pa_set_env("PULSE_INTERNAL", "1");
+    pa_set_env_and_record("PULSE_INTERNAL", "1");
     pa_assert_se(chdir("/") == 0);
     umask(0022);
 
@@ -721,7 +721,7 @@ int main(int argc, char *argv[]) {
         if (change_user() < 0)
             goto finish;
 
-    pa_set_env("PULSE_SYSTEM", conf->system_instance ? "1" : "0");
+    pa_set_env_and_record("PULSE_SYSTEM", conf->system_instance ? "1" : "0");
 
     pa_log_info(_("This is PulseAudio %s"), PACKAGE_VERSION);
     pa_log_debug(_("Compilation host: %s"), CANONICAL_HOST);
@@ -968,6 +968,9 @@ finish:
     if (valid_pid_file)
         pa_pid_file_remove();
 
+    /* This has no real purpose except making things valgrind-clean */
+    pa_unset_env_recorded();
+
 #ifdef OS_IS_WIN32
     WSACleanup();
 #endif
diff --git a/src/pulsecore/start-child.c b/src/pulsecore/start-child.c
index b3bce13..4a70aea 100644
--- a/src/pulsecore/start-child.c
+++ b/src/pulsecore/start-child.c
@@ -86,6 +86,11 @@ int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid) {
         pa_reset_sigs(-1);
         pa_unblock_sigs(-1);
         pa_reset_priority();
+        pa_unset_env_recorded();
+
+        /* Make sure our children are not influenced by the
+         * LD_BIND_NOW we set for ourselves. */
+        unsetenv("LD_BIND_NOW");
 
 #ifdef PR_SET_PDEATHSIG
         /* On Linux we can use PR_SET_PDEATHSIG to have the helper

commit 1200a0b143c370c1a9351add5f72ecabfd8630cf
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 2 00:54:22 2009 +0200

    sink: simplify pa_sink_render_full() by replacing it by a pa_sink_render() plus a couple of pa_sink_render_full()

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 9388d30..b4ecdfc 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -790,7 +790,7 @@ static void inputs_drop(pa_sink *s, pa_mix_info *info, unsigned n, pa_memchunk *
 
     /* We optimize for the case where the order of the inputs has not changed */
 
-    while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL))) {
+    PA_HASHMAP_FOREACH(i, s->thread_info.inputs, state) {
         unsigned j;
         pa_mix_info* m = NULL;
 
@@ -884,8 +884,6 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
     pa_assert(pa_frame_aligned(length, &s->sample_spec));
     pa_assert(result);
 
-    pa_sink_ref(s);
-
     pa_assert(!s->thread_info.rewind_requested);
     pa_assert(s->thread_info.rewind_nbytes == 0);
 
@@ -893,11 +891,11 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
         result->memblock = pa_memblock_ref(s->silence.memblock);
         result->index = s->silence.index;
         result->length = PA_MIN(s->silence.length, length);
-
-        pa_sink_unref(s);
         return;
     }
 
+    pa_sink_ref(s);
+
     if (length <= 0)
         length = pa_frame_align(MIX_BUFFER_LENGTH, &s->sample_spec);
 
@@ -975,17 +973,16 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) {
     pa_assert(target->length > 0);
     pa_assert(pa_frame_aligned(target->length, &s->sample_spec));
 
-    pa_sink_ref(s);
-
     pa_assert(!s->thread_info.rewind_requested);
     pa_assert(s->thread_info.rewind_nbytes == 0);
 
     if (s->thread_info.state == PA_SINK_SUSPENDED) {
         pa_silence_memchunk(target, &s->sample_spec);
-        pa_sink_unref(s);
         return;
     }
 
+    pa_sink_ref(s);
+
     length = target->length;
     block_size_max = pa_mempool_block_size_max(s->core->mempool);
     if (length > block_size_max)
@@ -1060,11 +1057,16 @@ void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target) {
     pa_assert(target->length > 0);
     pa_assert(pa_frame_aligned(target->length, &s->sample_spec));
 
-    pa_sink_ref(s);
-
     pa_assert(!s->thread_info.rewind_requested);
     pa_assert(s->thread_info.rewind_nbytes == 0);
 
+    if (s->thread_info.state == PA_SINK_SUSPENDED) {
+        pa_silence_memchunk(target, &s->sample_spec);
+        return;
+    }
+
+    pa_sink_ref(s);
+
     l = target->length;
     d = 0;
     while (l > 0) {
@@ -1083,10 +1085,6 @@ void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target) {
 
 /* Called from IO thread context */
 void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
-    pa_mix_info info[MAX_MIX_CHANNELS];
-    size_t length1st = length;
-    unsigned n;
-
     pa_sink_assert_ref(s);
     pa_sink_assert_io_context(s);
     pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
@@ -1094,72 +1092,12 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
     pa_assert(pa_frame_aligned(length, &s->sample_spec));
     pa_assert(result);
 
-    pa_sink_ref(s);
-
     pa_assert(!s->thread_info.rewind_requested);
     pa_assert(s->thread_info.rewind_nbytes == 0);
 
-    if (s->thread_info.state == PA_SINK_SUSPENDED) {
-        pa_silence_memchunk_get(&s->core->silence_cache,
-                                s->core->mempool,
-                                result,
-                                &s->sample_spec,
-                                length1st);
-
-        pa_sink_unref(s);
-        return;
-    }
-
-    n = fill_mix_info(s, &length1st, info, MAX_MIX_CHANNELS);
-
-    if (n == 0) {
-        pa_silence_memchunk_get(&s->core->silence_cache,
-                                s->core->mempool,
-                                result,
-                                &s->sample_spec,
-                                length1st);
-    } else if (n == 1) {
-        pa_cvolume volume;
-
-        *result = info[0].chunk;
-        pa_memblock_ref(result->memblock);
-
-        if (result->length > length)
-            result->length = length;
-
-        pa_sw_cvolume_multiply(&volume, &s->thread_info.soft_volume, &info[0].volume);
-
-        if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&volume)) {
-            if (s->thread_info.soft_muted || pa_cvolume_is_muted(&volume)) {
-                pa_memblock_unref(result->memblock);
-                pa_silence_memchunk_get(&s->core->silence_cache,
-                                        s->core->mempool,
-                                        result,
-                                        &s->sample_spec,
-                                        result->length);
-            } else {
-                pa_memchunk_make_writable(result, length);
-                pa_volume_memchunk(result, &s->sample_spec, &volume);
-            }
-        }
-    } else {
-        void *ptr;
-
-        result->index = 0;
-        result->memblock = pa_memblock_new(s->core->mempool, length);
-
-        ptr = pa_memblock_acquire(result->memblock);
-
-        result->length = pa_mix(info, n,
-                                (uint8_t*) ptr + result->index, length1st,
-                                &s->sample_spec,
-                                &s->thread_info.soft_volume,
-                                s->thread_info.soft_muted);
-
-        pa_memblock_release(result->memblock);
-    }
+    pa_sink_ref(s);
 
-    inputs_drop(s, info, n, result);
+    pa_sink_render(s, length, result);
 
     if (result->length < length) {
         pa_memchunk chunk;

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list