[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.12-105-gea82dec

Lennart Poettering gitmailer-noreply at 0pointer.de
Wed Oct 1 17:32:43 PDT 2008


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  08cf9db0d17f8e2cfc68976fd96f0374721cdf22 (commit)

- Log -----------------------------------------------------------------
ea82dec... when we mix into a 16bit accumulator make sure we clamp before we scale with a volume to avoid range faults when multiplying
-----------------------------------------------------------------------

Summary of changes:
 src/pulsecore/sample-util.c |    8 ++++----
 src/tests/mix-test.c        |    6 ++++--
 2 files changed, 8 insertions(+), 6 deletions(-)

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

commit ea82dec294310b83be25b4e0c940fd2cd2c7eeb3
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Oct 2 02:29:56 2008 +0200

    when we mix into a 16bit accumulator make sure we clamp before we scale with a volume to avoid range faults when multiplying

diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index b4234af..25178a8 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -214,8 +214,8 @@ size_t pa_mix(
                     m->ptr = (uint8_t*) m->ptr + sizeof(int16_t);
                 }
 
-                sum = (sum * linear[channel]) / 0x10000;
                 sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
+                sum = (sum * linear[channel]) / 0x10000;
                 *((int16_t*) data) = (int16_t) sum;
 
                 data = (uint8_t*) data + sizeof(int16_t);
@@ -253,8 +253,8 @@ size_t pa_mix(
                     m->ptr = (uint8_t*) m->ptr + sizeof(int16_t);
                 }
 
-                sum = (sum * linear[channel]) / 0x10000;
                 sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
+                sum = (sum * linear[channel]) / 0x10000;
                 *((int16_t*) data) = PA_INT16_SWAP((int16_t) sum);
 
                 data = (uint8_t*) data + sizeof(int16_t);
@@ -411,8 +411,8 @@ size_t pa_mix(
                     m->ptr = (uint8_t*) m->ptr + 1;
                 }
 
-                sum = (sum * linear[channel]) / 0x10000;
                 sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
+                sum = (sum * linear[channel]) / 0x10000;
                 *((uint8_t*) data) = (uint8_t) st_14linear2ulaw((int16_t) sum >> 2);
 
                 data = (uint8_t*) data + 1;
@@ -450,8 +450,8 @@ size_t pa_mix(
                     m->ptr = (uint8_t*) m->ptr + 1;
                 }
 
-                sum = (sum * linear[channel]) / 0x10000;
                 sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
+                sum = (sum * linear[channel]) / 0x10000;
                 *((uint8_t*) data) = (uint8_t) st_13linear2alaw((int16_t) sum >> 3);
 
                 data = (uint8_t*) data + 1;
diff --git a/src/tests/mix-test.c b/src/tests/mix-test.c
index 759d769..cc21ab0 100644
--- a/src/tests/mix-test.c
+++ b/src/tests/mix-test.c
@@ -221,6 +221,8 @@ int main(int argc, char *argv[]) {
         i.length = pa_memblock_get_length(i.memblock);
         i.index = 0;
 
+        dump_block(&a, &i);
+
         /* Make a copy */
         j = i;
         pa_memblock_ref(j.memblock);
@@ -229,6 +231,8 @@ int main(int argc, char *argv[]) {
         /* Adjust volume of the copy */
         pa_volume_memchunk(&j, &a, &v);
 
+        dump_block(&a, &j);
+
         m[0].chunk = i;
         m[0].volume.values[0] = PA_VOLUME_NORM;
         m[0].volume.channels = a.channels;
@@ -244,8 +248,6 @@ int main(int argc, char *argv[]) {
         pa_mix(m, 2, ptr, k.length, &a, NULL, FALSE);
         pa_memblock_release(k.memblock);
 
-        dump_block(&a, &i);
-        dump_block(&a, &j);
         dump_block(&a, &k);
 
         pa_memblock_unref(i.memblock);

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list