[pulseaudio-commits] 2 commits - src/pulsecore

Arun Raghavan arun at kemper.freedesktop.org
Fri Feb 10 01:53:25 PST 2012


 src/pulsecore/sample-util.c   |  169 +++++++++++++++++++-----------------------
 src/pulsecore/sink-input.c    |    4 
 src/pulsecore/source-output.c |    4 
 3 files changed, 84 insertions(+), 93 deletions(-)

New commits:
commit 2ce7d38005a82c56cbc1ad2af70afabe9def9e0d
Author: David Henningsson <david.henningsson at canonical.com>
Date:   Thu Feb 9 15:59:20 2012 +0100

    sample-util: Fix "Darth Vader" panning bug
    
    For muted channels, we forgot to increment a pointer, so if one
    channel was muted but not the other, sound became distorted in a
    Darth Vader like way. To test the difference, start two input
    streams and pan one of them hard left (or right).
    
    And hey, if you didn't think it sounded like Darth Vader, it's
    your imagination that's broken, not mine! ;-)
    
    BugLink: https://bugs.launchpad.net/bugs/928757
    Signed-off-by: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index df1d79e..f2017aa 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -225,22 +225,21 @@ size_t pa_mix(
                     pa_mix_info *m = streams + i;
                     int32_t v, lo, hi, cv = m->linear[channel].i;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
+                    if (PA_LIKELY(cv > 0)) {
 
-                    /* Multiplying the 32bit volume factor with the
-                     * 16bit sample might result in an 48bit value. We
-                     * want to do without 64 bit integers and hence do
-                     * the multiplication independently for the HI and
-                     * LO part of the volume. */
+                        /* Multiplying the 32bit volume factor with the
+                         * 16bit sample might result in an 48bit value. We
+                         * want to do without 64 bit integers and hence do
+                         * the multiplication independently for the HI and
+                         * LO part of the volume. */
 
-                    hi = cv >> 16;
-                    lo = cv & 0xFFFF;
-
-                    v = *((int16_t*) m->ptr);
-                    v = ((v * lo) >> 16) + (v * hi);
-                    sum += v;
+                        hi = cv >> 16;
+                        lo = cv & 0xFFFF;
 
+                        v = *((int16_t*) m->ptr);
+                        v = ((v * lo) >> 16) + (v * hi);
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + sizeof(int16_t);
                 }
 
@@ -269,16 +268,15 @@ size_t pa_mix(
                     pa_mix_info *m = streams + i;
                     int32_t v, lo, hi, cv = m->linear[channel].i;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    hi = cv >> 16;
-                    lo = cv & 0xFFFF;
+                    if (PA_LIKELY(cv > 0)) {
 
-                    v = PA_INT16_SWAP(*((int16_t*) m->ptr));
-                    v = ((v * lo) >> 16) + (v * hi);
-                    sum += v;
+                        hi = cv >> 16;
+                        lo = cv & 0xFFFF;
 
+                        v = PA_INT16_SWAP(*((int16_t*) m->ptr));
+                        v = ((v * lo) >> 16) + (v * hi);
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + sizeof(int16_t);
                 }
 
@@ -308,13 +306,12 @@ size_t pa_mix(
                     int32_t cv = m->linear[channel].i;
                     int64_t v;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    v = *((int32_t*) m->ptr);
-                    v = (v * cv) >> 16;
-                    sum += v;
+                    if (PA_LIKELY(cv > 0)) {
 
+                        v = *((int32_t*) m->ptr);
+                        v = (v * cv) >> 16;
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + sizeof(int32_t);
                 }
 
@@ -344,13 +341,12 @@ size_t pa_mix(
                     int32_t cv = m->linear[channel].i;
                     int64_t v;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    v = PA_INT32_SWAP(*((int32_t*) m->ptr));
-                    v = (v * cv) >> 16;
-                    sum += v;
+                    if (PA_LIKELY(cv > 0)) {
 
+                        v = PA_INT32_SWAP(*((int32_t*) m->ptr));
+                        v = (v * cv) >> 16;
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + sizeof(int32_t);
                 }
 
@@ -380,13 +376,12 @@ size_t pa_mix(
                     int32_t cv = m->linear[channel].i;
                     int64_t v;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    v = (int32_t) (PA_READ24NE(m->ptr) << 8);
-                    v = (v * cv) >> 16;
-                    sum += v;
+                    if (PA_LIKELY(cv > 0)) {
 
+                        v = (int32_t) (PA_READ24NE(m->ptr) << 8);
+                        v = (v * cv) >> 16;
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + 3;
                 }
 
@@ -416,13 +411,12 @@ size_t pa_mix(
                     int32_t cv = m->linear[channel].i;
                     int64_t v;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    v = (int32_t) (PA_READ24RE(m->ptr) << 8);
-                    v = (v * cv) >> 16;
-                    sum += v;
+                    if (PA_LIKELY(cv > 0)) {
 
+                        v = (int32_t) (PA_READ24RE(m->ptr) << 8);
+                        v = (v * cv) >> 16;
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + 3;
                 }
 
@@ -452,13 +446,12 @@ size_t pa_mix(
                     int32_t cv = m->linear[channel].i;
                     int64_t v;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    v = (int32_t) (*((uint32_t*)m->ptr) << 8);
-                    v = (v * cv) >> 16;
-                    sum += v;
+                    if (PA_LIKELY(cv > 0)) {
 
+                        v = (int32_t) (*((uint32_t*)m->ptr) << 8);
+                        v = (v * cv) >> 16;
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + sizeof(int32_t);
                 }
 
@@ -488,13 +481,12 @@ size_t pa_mix(
                     int32_t cv = m->linear[channel].i;
                     int64_t v;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    v = (int32_t) (PA_UINT32_SWAP(*((uint32_t*) m->ptr)) << 8);
-                    v = (v * cv) >> 16;
-                    sum += v;
+                    if (PA_LIKELY(cv > 0)) {
 
+                        v = (int32_t) (PA_UINT32_SWAP(*((uint32_t*) m->ptr)) << 8);
+                        v = (v * cv) >> 16;
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + 3;
                 }
 
@@ -523,13 +515,12 @@ size_t pa_mix(
                     pa_mix_info *m = streams + i;
                     int32_t v, cv = m->linear[channel].i;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    v = (int32_t) *((uint8_t*) m->ptr) - 0x80;
-                    v = (v * cv) >> 16;
-                    sum += v;
+                    if (PA_LIKELY(cv > 0)) {
 
+                        v = (int32_t) *((uint8_t*) m->ptr) - 0x80;
+                        v = (v * cv) >> 16;
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + 1;
                 }
 
@@ -558,16 +549,15 @@ size_t pa_mix(
                     pa_mix_info *m = streams + i;
                     int32_t v, hi, lo, cv = m->linear[channel].i;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    hi = cv >> 16;
-                    lo = cv & 0xFFFF;
+                    if (PA_LIKELY(cv > 0)) {
 
-                    v = (int32_t) st_ulaw2linear16(*((uint8_t*) m->ptr));
-                    v = ((v * lo) >> 16) + (v * hi);
-                    sum += v;
+                        hi = cv >> 16;
+                        lo = cv & 0xFFFF;
 
+                        v = (int32_t) st_ulaw2linear16(*((uint8_t*) m->ptr));
+                        v = ((v * lo) >> 16) + (v * hi);
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + 1;
                 }
 
@@ -596,16 +586,15 @@ size_t pa_mix(
                     pa_mix_info *m = streams + i;
                     int32_t v, hi, lo, cv = m->linear[channel].i;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
+                    if (PA_LIKELY(cv > 0)) {
 
-                    hi = cv >> 16;
-                    lo = cv & 0xFFFF;
-
-                    v = (int32_t) st_alaw2linear16(*((uint8_t*) m->ptr));
-                    v = ((v * lo) >> 16) + (v * hi);
-                    sum += v;
+                        hi = cv >> 16;
+                        lo = cv & 0xFFFF;
 
+                        v = (int32_t) st_alaw2linear16(*((uint8_t*) m->ptr));
+                        v = ((v * lo) >> 16) + (v * hi);
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + 1;
                 }
 
@@ -634,13 +623,12 @@ size_t pa_mix(
                     pa_mix_info *m = streams + i;
                     float v, cv = m->linear[channel].f;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    v = *((float*) m->ptr);
-                    v *= cv;
-                    sum += v;
+                    if (PA_LIKELY(cv > 0)) {
 
+                        v = *((float*) m->ptr);
+                        v *= cv;
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + sizeof(float);
                 }
 
@@ -668,13 +656,12 @@ size_t pa_mix(
                     pa_mix_info *m = streams + i;
                     float v, cv = m->linear[channel].f;
 
-                    if (PA_UNLIKELY(cv <= 0))
-                        continue;
-
-                    v = PA_FLOAT32_SWAP(*(float*) m->ptr);
-                    v *= cv;
-                    sum += v;
+                    if (PA_LIKELY(cv > 0)) {
 
+                        v = PA_FLOAT32_SWAP(*(float*) m->ptr);
+                        v *= cv;
+                        sum += v;
+                    }
                     m->ptr = (uint8_t*) m->ptr + sizeof(float);
                 }
 

commit 0521db6cf75cf61162c35505ee7baf9e5f21789d
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Thu Feb 9 16:50:31 2012 +0530

    sink-input,source-output: Handle devices going away in unlink hooks
    
    If a *_UNLINK_POST hook causes a sink-input/source-output's sink/source
    to go away, the subsequent attempt to update the sink/source status will
    cause an assert. We deal with this by checking the sink/source status
    before trying to update it.

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 93caa8f..7f824fa 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -657,7 +657,9 @@ void pa_sink_input_unlink(pa_sink_input *i) {
     }
 
     if (i->sink) {
-        pa_sink_update_status(i->sink);
+        if (PA_SINK_IS_LINKED(pa_sink_get_state(i->sink)))
+            pa_sink_update_status(i->sink);
+
         i->sink = NULL;
     }
 
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 8a35ab0..2f38af5 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -587,7 +587,9 @@ void pa_source_output_unlink(pa_source_output*o) {
     }
 
     if (o->source) {
-        pa_source_update_status(o->source);
+        if (PA_SOURCE_IS_LINKED(pa_source_get_state(o->source)))
+            pa_source_update_status(o->source);
+
         o->source = NULL;
     }
 



More information about the pulseaudio-commits mailing list