[pulseaudio-commits] 2 commits - src/modules

Tanu Kaskinen tanuk at kemper.freedesktop.org
Wed Jan 15 04:18:44 PST 2014


 src/modules/module-ladspa-sink.c |   25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

New commits:
commit e96785c1c34706e902f28c25844f31d8201db2b2
Author: Ben Brewer <ben.brewer at codethink.co.uk>
Date:   Wed Jan 15 11:19:46 2014 +0000

    ladspa-sink: Set a silence memchunk for the memblockq
    
    A crash was observed that was caused by pa_memblockq_peek() returning
    a NULL memblock in sink_input_pop_cb(). The scenario where this was
    happening was
    
    1. Delete 2 rtp-recv's connected to a ladspa-sink
    2. Delete ladspa-sink
    3. Delete alsa-sink
    4. Create alsa-sink
    5. Create ladspa-sink
    6. Create 2 rtp-recv's connected to the ladspa-sink
    
    The crash was probably caused by a rewind that made the read index go
    negative while the write index was at least zero, causing there to be
    a gap in the memblockq. The problematic rewind might have been caused
    by adding the rtp-recv stream to the ladspa-sink. That has not been
    proven, but this looks very similar to the bug that was fixed in
    module-virtual-sink in commit 6bd34156b130c07b130de10111a12ef6dab18b52.

diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 8e35b1b..46ce9e4 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -966,6 +966,7 @@ int pa__init(pa_module*m) {
     const char *e, *cdata;
     const LADSPA_Descriptor *d;
     unsigned long p, h, j, n_control, c;
+    pa_memchunk silence;
 
     pa_assert(m);
 
@@ -1010,7 +1011,6 @@ int pa__init(pa_module*m) {
     u = pa_xnew0(struct userdata, 1);
     u->module = m;
     m->userdata = u;
-    u->memblockq = pa_memblockq_new("module-ladspa-sink memblockq", 0, MEMBLOCKQ_MAXLENGTH, 0, &ss, 1, 1, 0, NULL);
     u->max_ladspaport_count = 1; /*to avoid division by zero etc. in pa__done when failing before this value has been set*/
     u->channels = 0;
     u->input = NULL;
@@ -1293,6 +1293,10 @@ int pa__init(pa_module*m) {
 
     u->sink->input_to_master = u->sink_input;
 
+    pa_sink_input_get_silence(u->sink_input, &silence);
+    u->memblockq = pa_memblockq_new("module-ladspa-sink memblockq", 0, MEMBLOCKQ_MAXLENGTH, 0, &ss, 1, 1, 0, &silence);
+    pa_memblock_unref(silence.memblock);
+
     pa_sink_put(u->sink);
     pa_sink_input_put(u->sink_input);
 

commit dbe66b0b5e6b6e24df45bda8bf656836f18e7f4b
Author: Ben Brewer <ben.brewer at codethink.co.uk>
Date:   Wed Jan 15 10:30:36 2014 +0000

    ladspa-sink: Handle empty chunks in sink_input_pop_cb

diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 7c4c274..8e35b1b 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -474,21 +474,28 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
 
     pa_memblockq_drop(u->memblockq, chunk->length);
 
-    src = pa_memblock_acquire_chunk(&tchunk);
+    src = (tchunk.memblock ? pa_memblock_acquire_chunk(&tchunk) : NULL);
     dst = pa_memblock_acquire(chunk->memblock);
 
     for (h = 0; h < (u->channels / u->max_ladspaport_count); h++) {
-        for (c = 0; c < u->input_count; c++)
-            pa_sample_clamp(PA_SAMPLE_FLOAT32NE, u->input[c], sizeof(float), src+ h*u->max_ladspaport_count + c, u->channels*sizeof(float), n);
+        if (src) {
+            for (c = 0; c < u->input_count; c++)
+                pa_sample_clamp(PA_SAMPLE_FLOAT32NE, u->input[c], sizeof(float), src+ h*u->max_ladspaport_count + c, u->channels*sizeof(float), n);
+        } else {
+            for (c = 0; c < u->input_count; c++)
+                memset(u->input[c], 0, (n * sizeof(float)));
+        }
         u->descriptor->run(u->handle[h], n);
         for (c = 0; c < u->output_count; c++)
             pa_sample_clamp(PA_SAMPLE_FLOAT32NE, dst + h*u->max_ladspaport_count + c, u->channels*sizeof(float), u->output[c], sizeof(float), n);
     }
 
-    pa_memblock_release(tchunk.memblock);
-    pa_memblock_release(chunk->memblock);
+    if (tchunk.memblock) {
+        pa_memblock_release(tchunk.memblock);
+        pa_memblock_unref(tchunk.memblock);
+    }
 
-    pa_memblock_unref(tchunk.memblock);
+    pa_memblock_release(chunk->memblock);
 
     return 0;
 }



More information about the pulseaudio-commits mailing list