[pulseaudio-commits] 14 commits - src/.gitignore src/Makefile.am src/daemon src/pulsecore src/tests

Peter Meerwald pmeerw at kemper.freedesktop.org
Wed Sep 10 10:40:07 PDT 2014


 src/.gitignore               |    6 
 src/Makefile.am              |   38 +
 src/daemon/main.c            |   13 
 src/pulsecore/cpu.c          |   38 +
 src/pulsecore/cpu.h          |    6 
 src/pulsecore/mix.c          |    8 
 src/pulsecore/remap.c        |   14 
 src/tests/cpu-mix-test.c     |  226 +++++++++++
 src/tests/cpu-remap-test.c   |  436 +++++++++++++++++++++
 src/tests/cpu-sconv-test.c   |  265 ++++++++++++
 src/tests/cpu-test.c         |  877 -------------------------------------------
 src/tests/cpu-volume-test.c  |  249 ++++++++++++
 src/tests/mix-special-test.c |  326 ---------------
 13 files changed, 1273 insertions(+), 1229 deletions(-)

New commits:
commit eed6d95f490d9efd5d593074ed67e61c5426f59b
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Apr 23 17:47:26 2014 +0200

    tests: Remove mix-special-test
    
    code has been moved to cpu-mix-test
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/.gitignore b/src/.gitignore
index a90c7dc..5ca8013 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -55,7 +55,6 @@ mainloop-test-glib
 mcalign-test
 memblockq-test
 memblock-test
-mix-special-test
 mix-test
 once-test
 pacat-simple
diff --git a/src/Makefile.am b/src/Makefile.am
index 2ff4967..8d49af3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -249,8 +249,7 @@ TESTS_default = \
 		cpu-sconv-test \
 		cpu-volume-test \
 		lock-autospawn-test \
-		mult-s16-test \
-		mix-special-test
+		mult-s16-test
 
 TESTS_norun = \
 		ipacl-test \
@@ -538,11 +537,6 @@ mult_s16_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la li
 mult_s16_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
 mult_s16_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
 
-mix_special_test_SOURCES = tests/mix-special-test.c tests/runtime-test-util.h
-mix_special_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
-mix_special_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
-mix_special_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
-
 rtstutter_SOURCES = tests/rtstutter.c
 rtstutter_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
 rtstutter_CFLAGS = $(AM_CFLAGS)
diff --git a/src/tests/mix-special-test.c b/src/tests/mix-special-test.c
deleted file mode 100644
index 08ac812..0000000
--- a/src/tests/mix-special-test.c
+++ /dev/null
@@ -1,326 +0,0 @@
-/***
-  This file is part of PulseAudio.
-
-  PulseAudio is free software; you can redistribute it and/or modify
-  it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2.1 of the License,
-  or (at your option) any later version.
-
-  PulseAudio is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with PulseAudio; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-  USA.
-***/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <check.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include <pulse/rtclock.h>
-#include <pulsecore/random.h>
-#include <pulsecore/macro.h>
-#include <pulsecore/mix.h>
-#include <pulsecore/sample-util.h>
-
-#include "runtime-test-util.h"
-
-static void acquire_mix_streams(pa_mix_info streams[], unsigned nstreams) {
-    unsigned i;
-
-    for (i = 0; i < nstreams; i++)
-        streams[i].ptr = pa_memblock_acquire_chunk(&streams[i].chunk);
-}
-
-static void release_mix_streams(pa_mix_info streams[], unsigned nstreams) {
-    unsigned i;
-
-    for (i = 0; i < nstreams; i++)
-        pa_memblock_release(streams[i].chunk.memblock);
-}
-
-/* special case: mix 2 s16ne streams, 1 channel each */
-static void pa_mix2_ch1_s16ne(pa_mix_info streams[], int16_t *data, unsigned length) {
-    const int16_t *ptr0 = streams[0].ptr;
-    const int16_t *ptr1 = streams[1].ptr;
-
-    const int32_t cv0 = streams[0].linear[0].i;
-    const int32_t cv1 = streams[1].linear[0].i;
-
-    length /= sizeof(int16_t);
-
-    for (; length > 0; length--) {
-        int32_t sum;
-
-        sum = pa_mult_s16_volume(*ptr0++, cv0);
-        sum += pa_mult_s16_volume(*ptr1++, cv1);
-
-        sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
-        *data++ = sum;
-    }
-}
-
-/* special case: mix 2 s16ne streams, 2 channels each */
-static void pa_mix2_ch2_s16ne(pa_mix_info streams[], int16_t *data, unsigned length) {
-    const int16_t *ptr0 = streams[0].ptr;
-    const int16_t *ptr1 = streams[1].ptr;
-
-    length /= sizeof(int16_t) * 2;
-
-    for (; length > 0; length--) {
-        int32_t sum;
-
-        sum = pa_mult_s16_volume(*ptr0++, streams[0].linear[0].i);
-        sum += pa_mult_s16_volume(*ptr1++, streams[1].linear[0].i);
-
-        sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
-        *data++ = sum;
-
-        sum = pa_mult_s16_volume(*ptr0++, streams[0].linear[1].i);
-        sum += pa_mult_s16_volume(*ptr1++, streams[1].linear[1].i);
-
-        sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
-        *data++ = sum;
-    }
-}
-
-/* special case: mix 2 s16ne streams */
-static void pa_mix2_s16ne(pa_mix_info streams[], unsigned channels, int16_t *data, unsigned length) {
-    const int16_t *ptr0 = streams[0].ptr;
-    const int16_t *ptr1 = streams[1].ptr;
-    unsigned channel = 0;
-
-    length /= sizeof(int16_t);
-
-    for (; length > 0; length--) {
-        int32_t sum;
-
-        sum = pa_mult_s16_volume(*ptr0++, streams[0].linear[channel].i);
-        sum += pa_mult_s16_volume(*ptr1++, streams[1].linear[channel].i);
-
-        sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
-        *data++ = sum;
-
-        if (PA_UNLIKELY(++channel >= channels))
-            channel = 0;
-    }
-}
-
-/* special case: mix s16ne streams, 2 channels each */
-static void pa_mix_ch2_s16ne(pa_mix_info streams[], unsigned nstreams, int16_t *data, unsigned length) {
-
-    length /= sizeof(int16_t) * 2;
-
-    for (; length > 0; length--) {
-        int32_t sum0 = 0, sum1 = 0;
-        unsigned i;
-
-        for (i = 0; i < nstreams; i++) {
-            pa_mix_info *m = streams + i;
-            int32_t cv0 = m->linear[0].i;
-            int32_t cv1 = m->linear[1].i;
-
-            sum0 += pa_mult_s16_volume(*((int16_t*) m->ptr), cv0);
-            m->ptr = (uint8_t*) m->ptr + sizeof(int16_t);
-
-            sum1 += pa_mult_s16_volume(*((int16_t*) m->ptr), cv1);
-            m->ptr = (uint8_t*) m->ptr + sizeof(int16_t);
-        }
-
-        *data++ = PA_CLAMP_UNLIKELY(sum0, -0x8000, 0x7FFF);
-        *data++ = PA_CLAMP_UNLIKELY(sum1, -0x8000, 0x7FFF);
-    }
-}
-
-static void pa_mix_generic_s16ne(pa_mix_info streams[], unsigned nstreams, unsigned channels, int16_t *data, unsigned length) {
-    unsigned channel = 0;
-
-    length /= sizeof(int16_t);
-
-    for (; length > 0; length--) {
-        int32_t sum = 0;
-        unsigned i;
-
-        for (i = 0; i < nstreams; i++) {
-            pa_mix_info *m = streams + i;
-            int32_t cv = m->linear[channel].i;
-
-            if (PA_LIKELY(cv > 0))
-                sum += pa_mult_s16_volume(*((int16_t*) m->ptr), cv);
-            m->ptr = (uint8_t*) m->ptr + sizeof(int16_t);
-        }
-
-        sum = PA_CLAMP_UNLIKELY(sum, -0x8000, 0x7FFF);
-        *data++ = sum;
-
-        if (PA_UNLIKELY(++channel >= channels))
-            channel = 0;
-    }
-}
-
-#define SAMPLES 1028
-#define TIMES 1000
-#define TIMES2 100
-
-START_TEST (mix_special_1ch_test) {
-    int16_t samples0[SAMPLES];
-    int16_t samples1[SAMPLES];
-    int16_t out[SAMPLES];
-    int16_t out_ref[SAMPLES];
-    pa_mempool *pool;
-    pa_memchunk c0, c1;
-    pa_mix_info m[2];
-    unsigned nsamples = SAMPLES;
-
-    fail_unless((pool = pa_mempool_new(false, 0)) != NULL, NULL);
-
-    pa_random(samples0, nsamples * sizeof(int16_t));
-    c0.memblock = pa_memblock_new_fixed(pool, samples0, nsamples * sizeof(int16_t), false);
-    c0.length = pa_memblock_get_length(c0.memblock);
-    c0.index = 0;
-
-    pa_random(samples1, nsamples * sizeof(int16_t));
-    c1.memblock = pa_memblock_new_fixed(pool, samples1, nsamples * sizeof(int16_t), false);
-    c1.length = pa_memblock_get_length(c1.memblock);
-    c1.index = 0;
-
-    m[0].chunk = c0;
-    m[0].volume.channels = 1;
-    m[0].volume.values[0] = PA_VOLUME_NORM;
-    m[0].linear[0].i = 0x5555;
-
-    m[1].chunk = c1;
-    m[1].volume.channels = 1;
-    m[1].volume.values[0] = PA_VOLUME_NORM;
-    m[1].linear[0].i = 0x6789;
-
-    PA_RUNTIME_TEST_RUN_START("mix s16 generic 1 channel", TIMES, TIMES2) {
-        acquire_mix_streams(m, 2);
-        pa_mix_generic_s16ne(m, 2, 1, out_ref, nsamples * sizeof(int16_t));
-        release_mix_streams(m, 2);
-    } PA_RUNTIME_TEST_RUN_STOP
-
-    PA_RUNTIME_TEST_RUN_START("mix s16 2 streams 1 channel", TIMES, TIMES2) {
-        acquire_mix_streams(m, 2);
-        pa_mix2_ch1_s16ne(m, out, nsamples * sizeof(int16_t));
-        release_mix_streams(m, 2);
-    } PA_RUNTIME_TEST_RUN_STOP
-
-    fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
-
-    pa_memblock_unref(c0.memblock);
-    pa_memblock_unref(c1.memblock);
-
-    pa_mempool_free(pool);
-}
-END_TEST
-
-START_TEST (mix_special_2ch_test) {
-    int16_t samples0[SAMPLES*2];
-    int16_t samples1[SAMPLES*2];
-    int16_t out[SAMPLES*2];
-    int16_t out_ref[SAMPLES*2];
-    int i;
-    pa_mempool *pool;
-    pa_memchunk c0, c1;
-    pa_mix_info m[2];
-    unsigned nsamples = SAMPLES * 2;
-
-    fail_unless((pool = pa_mempool_new(false, 0)) != NULL, NULL);
-
-    pa_random(samples0, nsamples * sizeof(int16_t));
-    c0.memblock = pa_memblock_new_fixed(pool, samples0, nsamples * sizeof(int16_t), false);
-    c0.length = pa_memblock_get_length(c0.memblock);
-    c0.index = 0;
-
-    pa_random(samples1, nsamples * sizeof(int16_t));
-    c1.memblock = pa_memblock_new_fixed(pool, samples1, nsamples * sizeof(int16_t), false);
-    c1.length = pa_memblock_get_length(c1.memblock);
-    c1.index = 0;
-
-    m[0].chunk = c0;
-    m[0].volume.channels = 2;
-    for (i = 0; i < m[0].volume.channels; i++) {
-        m[0].volume.values[i] = PA_VOLUME_NORM;
-        m[0].linear[i].i = 0x5555;
-    }
-
-    m[1].chunk = c1;
-    m[1].volume.channels = 2;
-    for (i = 0; i < m[1].volume.channels; i++) {
-        m[1].volume.values[i] = PA_VOLUME_NORM;
-        m[1].linear[i].i = 0x6789;
-    }
-
-    PA_RUNTIME_TEST_RUN_START("mix s16 generic 2 channels", TIMES, TIMES2) {
-        acquire_mix_streams(m, 2);
-        pa_mix_generic_s16ne(m, 2, 2, out_ref, nsamples * sizeof(int16_t));
-        release_mix_streams(m, 2);
-    } PA_RUNTIME_TEST_RUN_STOP
-
-    PA_RUNTIME_TEST_RUN_START("mix s16 2 channels", TIMES, TIMES2) {
-        acquire_mix_streams(m, 2);
-        pa_mix_ch2_s16ne(m, 2, out, nsamples * sizeof(int16_t));
-        release_mix_streams(m, 2);
-    } PA_RUNTIME_TEST_RUN_STOP
-
-    fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
-
-    PA_RUNTIME_TEST_RUN_START("mix s16 2 streams", TIMES, TIMES2) {
-        acquire_mix_streams(m, 2);
-        pa_mix2_s16ne(m, 2, out, nsamples * sizeof(int16_t));
-        release_mix_streams(m, 2);
-    } PA_RUNTIME_TEST_RUN_STOP
-
-    fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
-
-    PA_RUNTIME_TEST_RUN_START("mix s16 2 streams 2 channels", TIMES, TIMES2) {
-        acquire_mix_streams(m, 2);
-        pa_mix2_ch2_s16ne(m, out, nsamples * sizeof(int16_t));
-        release_mix_streams(m, 2);
-    } PA_RUNTIME_TEST_RUN_STOP
-
-    fail_unless(memcmp(out, out_ref, nsamples * sizeof(int16_t)) == 0);
-
-    pa_memblock_unref(c0.memblock);
-    pa_memblock_unref(c1.memblock);
-
-    pa_mempool_free(pool);
-}
-END_TEST
-
-int main(int argc, char *argv[]) {
-    int failed = 0;
-    Suite *s;
-    TCase *tc;
-    SRunner *sr;
-
-    if (!getenv("MAKE_CHECK"))
-        pa_log_set_level(PA_LOG_DEBUG);
-
-    s = suite_create("Mix-special");
-    tc = tcase_create("mix-special 1ch");
-    tcase_add_test(tc, mix_special_1ch_test);
-    tcase_set_timeout(tc, 120);
-    suite_add_tcase(s, tc);
-    tc = tcase_create("mix-special 2ch");
-    tcase_add_test(tc, mix_special_2ch_test);
-    tcase_set_timeout(tc, 120);
-    suite_add_tcase(s, tc);
-
-    sr = srunner_create(s);
-    srunner_run_all(sr, CK_NORMAL);
-    failed = srunner_ntests_failed(sr);
-    srunner_free(sr);
-
-    return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}

commit f8fe25e8df583e37401b5c324a693f360d801052
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Wed Apr 23 23:48:17 2014 +0200

    tests: Use float constants in cpu-sconv-test
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/cpu-sconv-test.c b/src/tests/cpu-sconv-test.c
index 4e7848d..428ebe0 100644
--- a/src/tests/cpu-sconv-test.c
+++ b/src/tests/cpu-sconv-test.c
@@ -94,8 +94,8 @@ static void run_conv_test_s16_to_float(
         bool correct,
         bool perf) {
 
-    PA_DECLARE_ALIGNED(8, float, f[SAMPLES]) = { 0 };
-    PA_DECLARE_ALIGNED(8, float, f_ref[SAMPLES]) = { 0 };
+    PA_DECLARE_ALIGNED(8, float, f[SAMPLES]) = { 0.0f };
+    PA_DECLARE_ALIGNED(8, float, f_ref[SAMPLES]) = { 0.0f };
     PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]);
     float *floats, *floats_ref;
     int16_t *samples;
@@ -114,7 +114,7 @@ static void run_conv_test_s16_to_float(
         func(nsamples, samples, floats);
 
         for (i = 0; i < nsamples; i++) {
-            if (fabsf(floats[i] - floats_ref[i]) > 0.0001) {
+            if (fabsf(floats[i] - floats_ref[i]) > 0.0001f) {
                 pa_log_debug("Correctness test failed: align=%d", align);
                 pa_log_debug("%d: %.24f != %.24f (%d)\n", i, floats[i], floats_ref[i], samples[i]);
                 fail();

commit ce9318fb72a3f5a1fdb81287313fc8cd295ab11b
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Tue Apr 22 19:12:28 2014 +0200

    tests: Add ARM NEON test code to cpu-remap-test
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/cpu-remap-test.c b/src/tests/cpu-remap-test.c
index dccb571..4ee5e00 100644
--- a/src/tests/cpu-remap-test.c
+++ b/src/tests/cpu-remap-test.c
@@ -327,6 +327,75 @@ START_TEST (remap_sse2_test) {
 END_TEST
 #endif /* defined (__i386__) || defined (__amd64__) */
 
+#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
+START_TEST (remap_neon_test) {
+    pa_cpu_arm_flag_t flags = 0;
+    pa_init_remap_func_t init_func, orig_init_func;
+
+    pa_cpu_get_arm_flags(&flags);
+    if (!(flags & PA_CPU_ARM_NEON)) {
+        pa_log_info("NEON not supported. Skipping");
+        return;
+    }
+
+    orig_init_func = pa_get_init_remap_func();
+    pa_remap_func_init_neon(flags);
+    init_func = pa_get_init_remap_func();
+
+    pa_log_debug("Checking NEON remap (float, mono->stereo)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2, false);
+    pa_log_debug("Checking NEON remap (float, mono->4-channel)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 4, false);
+
+    pa_log_debug("Checking NEON remap (s16, mono->stereo)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2, false);
+    pa_log_debug("Checking NEON remap (s16, mono->4-channel)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 4, false);
+
+    pa_log_debug("Checking NEON remap (float, stereo->mono)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 2, 1, false);
+    pa_log_debug("Checking NEON remap (float, 4-channel->mono)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 4, 1, false);
+
+    pa_log_debug("Checking NEON remap (s16, stereo->mono)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 2, 1, false);
+    pa_log_debug("Checking NEON remap (s16, 4-channel->mono)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 4, 1, false);
+
+    pa_log_debug("Checking NEON remap (float, 4-channel->4-channel)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 4, 4, false);
+    pa_log_debug("Checking NEON remap (s16, 4-channel->4-channel)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 4, 4, false);
+}
+END_TEST
+
+START_TEST (rearrange_neon_test) {
+    pa_cpu_arm_flag_t flags = 0;
+    pa_init_remap_func_t init_func, orig_init_func;
+
+    pa_cpu_get_arm_flags(&flags);
+    if (!(flags & PA_CPU_ARM_NEON)) {
+        pa_log_info("NEON not supported. Skipping");
+        return;
+    }
+
+    orig_init_func = pa_get_init_remap_func();
+    pa_remap_func_init_neon(flags);
+    init_func = pa_get_init_remap_func();
+
+    pa_log_debug("Checking NEON remap (float, stereo rearrange)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 2, 2, true);
+    pa_log_debug("Checking NEON remap (s16, stereo rearrange)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 2, 2, true);
+
+    pa_log_debug("Checking NEON remap (float, 4-channel rearrange)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 4, 4, true);
+    pa_log_debug("Checking NEON remap (s16, 4-channel rearrange)");
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 4, 4, true);
+}
+END_TEST
+#endif
+
 int main(int argc, char *argv[]) {
     int failed = 0;
     Suite *s;
@@ -344,11 +413,17 @@ int main(int argc, char *argv[]) {
     tcase_add_test(tc, remap_mmx_test);
     tcase_add_test(tc, remap_sse2_test);
 #endif
+#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
+    tcase_add_test(tc, remap_neon_test);
+#endif
     tcase_set_timeout(tc, 120);
     suite_add_tcase(s, tc);
 
     tc = tcase_create("rearrange");
     tcase_add_test(tc, rearrange_special_test);
+#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
+    tcase_add_test(tc, rearrange_neon_test);
+#endif
     tcase_set_timeout(tc, 120);
     suite_add_tcase(s, tc);
 

commit d8be5cbf8b16363b410d655956ccf6f57ff21529
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Wed Apr 23 16:52:39 2014 +0200

    tests: Add rearrange remapping test cases to cpu-remap-test
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/cpu-remap-test.c b/src/tests/cpu-remap-test.c
index c0a6a64..dccb571 100644
--- a/src/tests/cpu-remap-test.c
+++ b/src/tests/cpu-remap-test.c
@@ -147,7 +147,8 @@ static void setup_remap_channels(
     pa_remap_t *m,
     pa_sample_format_t f,
     unsigned in_channels,
-    unsigned out_channels) {
+    unsigned out_channels,
+    bool rearrange) {
 
     unsigned i, o;
 
@@ -155,10 +156,19 @@ static void setup_remap_channels(
     m->i_ss.channels = in_channels;
     m->o_ss.channels = out_channels;
 
-    for (o = 0; o < out_channels; o++) {
-        for (i = 0; i < in_channels; i++) {
-            m->map_table_f[o][i] = 1.0f / in_channels;
-            m->map_table_i[o][i] = 0x10000 / in_channels;
+    if (rearrange) {
+        for (o = 0; o < out_channels; o++) {
+            for (i = 0; i < in_channels; i++) {
+                m->map_table_f[o][i] = (o == i) ? 1.0f : 0.0f;
+                m->map_table_i[o][i] = (o == i) ? 0x10000 : 0;
+            }
+        }
+    } else {
+        for (o = 0; o < out_channels; o++) {
+            for (i = 0; i < in_channels; i++) {
+                m->map_table_f[o][i] = 1.0f / in_channels;
+                m->map_table_i[o][i] = 0x10000 / in_channels;
+            }
         }
     }
 }
@@ -201,14 +211,15 @@ static void remap_init_test_channels(
         pa_init_remap_func_t orig_init_func,
         pa_sample_format_t f,
         unsigned in_channels,
-        unsigned out_channels) {
+        unsigned out_channels,
+        bool rearrange) {
 
     pa_remap_t remap_orig, remap_func;
 
-    setup_remap_channels(&remap_orig, f, in_channels, out_channels);
+    setup_remap_channels(&remap_orig, f, in_channels, out_channels, rearrange);
     orig_init_func(&remap_orig);
 
-    setup_remap_channels(&remap_func, f, in_channels, out_channels);
+    setup_remap_channels(&remap_func, f, in_channels, out_channels, rearrange);
     init_func(&remap_func);
 
     remap_test_channels(&remap_func, &remap_orig);
@@ -217,19 +228,20 @@ static void remap_init_test_channels(
 static void remap_init2_test_channels(
         pa_sample_format_t f,
         unsigned in_channels,
-        unsigned out_channels) {
+        unsigned out_channels,
+        bool rearrange) {
 
     pa_cpu_info cpu_info = { PA_CPU_UNDEFINED, {}, false };
     pa_remap_t remap_orig, remap_func;
 
     cpu_info.force_generic_code = true;
     pa_remap_func_init(&cpu_info);
-    setup_remap_channels(&remap_orig, f, in_channels, out_channels);
+    setup_remap_channels(&remap_orig, f, in_channels, out_channels, rearrange);
     pa_init_remap_func(&remap_orig);
 
     cpu_info.force_generic_code = false;
     pa_remap_func_init(&cpu_info);
-    setup_remap_channels(&remap_func, f, in_channels, out_channels);
+    setup_remap_channels(&remap_func, f, in_channels, out_channels, rearrange);
     pa_init_remap_func(&remap_func);
 
     remap_test_channels(&remap_func, &remap_orig);
@@ -237,24 +249,37 @@ static void remap_init2_test_channels(
 
 START_TEST (remap_special_test) {
     pa_log_debug("Checking special remap (float, mono->stereo)");
-    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 2);
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 2, false);
     pa_log_debug("Checking special remap (float, mono->4-channel)");
-    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 4);
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 4, false);
 
     pa_log_debug("Checking special remap (s16, mono->stereo)");
-    remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 2);
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 2, false);
     pa_log_debug("Checking special remap (s16, mono->4-channel)");
-    remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 4);
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 4, false);
 
     pa_log_debug("Checking special remap (float, stereo->mono)");
-    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 2, 1);
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 2, 1, false);
     pa_log_debug("Checking special remap (float, 4-channel->mono)");
-    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 4, 1);
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 4, 1, false);
 
     pa_log_debug("Checking special remap (s16, stereo->mono)");
-    remap_init2_test_channels(PA_SAMPLE_S16NE, 2, 1);
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 2, 1, false);
     pa_log_debug("Checking special remap (s16, 4-channel->mono)");
-    remap_init2_test_channels(PA_SAMPLE_S16NE, 4, 1);
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 4, 1, false);
+}
+END_TEST
+
+START_TEST (rearrange_special_test) {
+    pa_log_debug("Checking special remap (s16, stereo rearrange)");
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 2, 2, true);
+    pa_log_debug("Checking special remap (float, stereo rearrange)");
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 2, 2, true);
+
+    pa_log_debug("Checking special remap (s16, 4-channel rearrange)");
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 4, 4, true);
+    pa_log_debug("Checking special remap (float, 4-channel rearrange)");
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 4, 4, true);
 }
 END_TEST
 
@@ -273,10 +298,10 @@ START_TEST (remap_mmx_test) {
     orig_init_func = pa_get_init_remap_func();
     pa_remap_func_init_mmx(flags);
     init_func = pa_get_init_remap_func();
-    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2);
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2, false);
 
     pa_log_debug("Checking MMX remap (s16, mono->stereo)");
-    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2);
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2, false);
 }
 END_TEST
 
@@ -294,10 +319,10 @@ START_TEST (remap_sse2_test) {
     orig_init_func = pa_get_init_remap_func();
     pa_remap_func_init_sse(flags);
     init_func = pa_get_init_remap_func();
-    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2);
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2, false);
 
     pa_log_debug("Checking SSE2 remap (s16, mono->stereo)");
-    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2);
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2, false);
 }
 END_TEST
 #endif /* defined (__i386__) || defined (__amd64__) */
@@ -322,6 +347,11 @@ int main(int argc, char *argv[]) {
     tcase_set_timeout(tc, 120);
     suite_add_tcase(s, tc);
 
+    tc = tcase_create("rearrange");
+    tcase_add_test(tc, rearrange_special_test);
+    tcase_set_timeout(tc, 120);
+    suite_add_tcase(s, tc);
+
     sr = srunner_create(s);
     srunner_run_all(sr, CK_NORMAL);
     failed = srunner_ntests_failed(sr);

commit c68c9f3aa2d79e0377710f6c34ef62ec9f8198ca
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Wed Apr 23 22:18:34 2014 +0200

    tests: Add to remapping special case code tests to cpu-remap-test
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/cpu-remap-test.c b/src/tests/cpu-remap-test.c
index fa7633d..c0a6a64 100644
--- a/src/tests/cpu-remap-test.c
+++ b/src/tests/cpu-remap-test.c
@@ -214,6 +214,50 @@ static void remap_init_test_channels(
     remap_test_channels(&remap_func, &remap_orig);
 }
 
+static void remap_init2_test_channels(
+        pa_sample_format_t f,
+        unsigned in_channels,
+        unsigned out_channels) {
+
+    pa_cpu_info cpu_info = { PA_CPU_UNDEFINED, {}, false };
+    pa_remap_t remap_orig, remap_func;
+
+    cpu_info.force_generic_code = true;
+    pa_remap_func_init(&cpu_info);
+    setup_remap_channels(&remap_orig, f, in_channels, out_channels);
+    pa_init_remap_func(&remap_orig);
+
+    cpu_info.force_generic_code = false;
+    pa_remap_func_init(&cpu_info);
+    setup_remap_channels(&remap_func, f, in_channels, out_channels);
+    pa_init_remap_func(&remap_func);
+
+    remap_test_channels(&remap_func, &remap_orig);
+}
+
+START_TEST (remap_special_test) {
+    pa_log_debug("Checking special remap (float, mono->stereo)");
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 2);
+    pa_log_debug("Checking special remap (float, mono->4-channel)");
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 1, 4);
+
+    pa_log_debug("Checking special remap (s16, mono->stereo)");
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 2);
+    pa_log_debug("Checking special remap (s16, mono->4-channel)");
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 1, 4);
+
+    pa_log_debug("Checking special remap (float, stereo->mono)");
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 2, 1);
+    pa_log_debug("Checking special remap (float, 4-channel->mono)");
+    remap_init2_test_channels(PA_SAMPLE_FLOAT32NE, 4, 1);
+
+    pa_log_debug("Checking special remap (s16, stereo->mono)");
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 2, 1);
+    pa_log_debug("Checking special remap (s16, 4-channel->mono)");
+    remap_init2_test_channels(PA_SAMPLE_S16NE, 4, 1);
+}
+END_TEST
+
 #if defined (__i386__) || defined (__amd64__)
 START_TEST (remap_mmx_test) {
     pa_cpu_x86_flag_t flags = 0;
@@ -270,6 +314,7 @@ int main(int argc, char *argv[]) {
     s = suite_create("CPU");
 
     tc = tcase_create("remap");
+    tcase_add_test(tc, remap_special_test);
 #if defined (__i386__) || defined (__amd64__)
     tcase_add_test(tc, remap_mmx_test);
     tcase_add_test(tc, remap_sse2_test);

commit 7ae700941c17724a2308873854782c6093656c75
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Wed Apr 23 22:18:05 2014 +0200

    tests: Reorganize cpu-remap-test program
    
    Make run_remap_test() support up to 8 input and output channels.
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/cpu-remap-test.c b/src/tests/cpu-remap-test.c
index eef5532..fa7633d 100644
--- a/src/tests/cpu-remap-test.c
+++ b/src/tests/cpu-remap-test.c
@@ -24,47 +24,54 @@
 #include <check.h>
 
 #include <pulsecore/cpu-x86.h>
+#include <pulsecore/cpu.h>
 #include <pulsecore/random.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/remap.h>
 
 #include "runtime-test-util.h"
 
-#define SAMPLES 1028
+#define SAMPLES 1027
 #define TIMES 1000
 #define TIMES2 100
 
-static void run_remap_test_mono_stereo_float(
+static void run_remap_test_float(
         pa_remap_t *remap_func,
         pa_remap_t *remap_orig,
         int align,
         bool correct,
         bool perf) {
 
-    PA_DECLARE_ALIGNED(8, float, s_ref[SAMPLES*2]) = { 0 };
-    PA_DECLARE_ALIGNED(8, float, s[SAMPLES*2]) = { 0 };
-    PA_DECLARE_ALIGNED(8, float, m[SAMPLES]);
-    float *stereo, *stereo_ref;
-    float *mono;
-    int i, nsamples;
+    PA_DECLARE_ALIGNED(8, float, out_buf_ref[SAMPLES*8]) = { 0.0f, };
+    PA_DECLARE_ALIGNED(8, float, out_buf[SAMPLES*8]) = { 0.0f, };
+    PA_DECLARE_ALIGNED(8, float, in_buf[SAMPLES*8]);
+    float *out, *out_ref;
+    float *in;
+    unsigned n_ic = remap_func->i_ss.channels;
+    unsigned n_oc = remap_func->o_ss.channels;
+    unsigned i, nsamples;
+
+    pa_assert(n_ic >= 1 && n_ic <= 8);
+    pa_assert(n_oc >= 1 && n_oc <= 8);
 
     /* Force sample alignment as requested */
-    stereo = s + (8 - align);
-    stereo_ref = s_ref + (8 - align);
-    mono = m + (8 - align);
+    out = out_buf + (8 - align);
+    out_ref = out_buf_ref + (8 - align);
+    in = in_buf + (8 - align);
     nsamples = SAMPLES - (8 - align);
 
-    for (i = 0; i < nsamples; i++)
-        mono[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
+    for (i = 0; i < nsamples * n_ic; i++)
+        in[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
 
     if (correct) {
-        remap_orig->do_remap(remap_orig, stereo_ref, mono, nsamples);
-        remap_func->do_remap(remap_func, stereo, mono, nsamples);
+        remap_orig->do_remap(remap_orig, out_ref, in, nsamples);
+        remap_func->do_remap(remap_func, out, in, nsamples);
 
-        for (i = 0; i < nsamples * 2; i++) {
-            if (fabsf(stereo[i] - stereo_ref[i]) > 0.0001f) {
+        for (i = 0; i < nsamples * n_oc; i++) {
+            if (fabsf(out[i] - out_ref[i]) > 0.0001f) {
                 pa_log_debug("Correctness test failed: align=%d", align);
-                pa_log_debug("%d: %.24f != %.24f (%.24f)\n", i, stereo[i], stereo_ref[i], mono[i]);
+                pa_log_debug("%d: %.24f != %.24f\n", i,
+                    out[i], out_ref[i]);
                 fail();
             }
         }
@@ -74,45 +81,50 @@ static void run_remap_test_mono_stereo_float(
         pa_log_debug("Testing remap performance with %d sample alignment", align);
 
         PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            remap_func->do_remap(remap_func, stereo, mono, nsamples);
+            remap_func->do_remap(remap_func, out, in, nsamples);
         } PA_RUNTIME_TEST_RUN_STOP
 
         PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            remap_orig->do_remap(remap_orig, stereo_ref, mono, nsamples);
+            remap_orig->do_remap(remap_orig, out_ref, in, nsamples);
         } PA_RUNTIME_TEST_RUN_STOP
     }
 }
 
-static void run_remap_test_mono_stereo_s16(
+static void run_remap_test_s16(
         pa_remap_t *remap_func,
         pa_remap_t *remap_orig,
         int align,
         bool correct,
         bool perf) {
 
-    PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES*2]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES*2]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, m[SAMPLES]);
-    int16_t *stereo, *stereo_ref;
-    int16_t *mono;
-    int i, nsamples;
+    PA_DECLARE_ALIGNED(8, int16_t, out_buf_ref[SAMPLES*8]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, out_buf[SAMPLES*8]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, in_buf[SAMPLES*8]);
+    int16_t *out, *out_ref;
+    int16_t *in;
+    unsigned n_ic = remap_func->i_ss.channels;
+    unsigned n_oc = remap_func->o_ss.channels;
+    unsigned i, nsamples;
+
+    pa_assert(n_ic >= 1 && n_ic <= 8);
+    pa_assert(n_oc >= 1 && n_oc <= 8);
 
     /* Force sample alignment as requested */
-    stereo = s + (8 - align);
-    stereo_ref = s_ref + (8 - align);
-    mono = m + (8 - align);
+    out = out_buf + (8 - align);
+    out_ref = out_buf_ref + (8 - align);
+    in = in_buf + (8 - align);
     nsamples = SAMPLES - (8 - align);
 
-    pa_random(mono, nsamples * sizeof(int16_t));
+    pa_random(in, nsamples * n_ic * sizeof(int16_t));
 
     if (correct) {
-        remap_orig->do_remap(remap_orig, stereo_ref, mono, nsamples);
-        remap_func->do_remap(remap_func, stereo, mono, nsamples);
+        remap_orig->do_remap(remap_orig, out_ref, in, nsamples);
+        remap_func->do_remap(remap_func, out, in, nsamples);
 
-        for (i = 0; i < nsamples * 2; i++) {
-            if (abs(stereo[i] - stereo_ref[i]) > 1) {
+        for (i = 0; i < nsamples * n_oc; i++) {
+            if (abs(out[i] - out_ref[i]) > 3) {
                 pa_log_debug("Correctness test failed: align=%d", align);
-                pa_log_debug("%d: %d != %d (%d)\n", i, stereo[i], stereo_ref[i], mono[i]);
+                pa_log_debug("%d: %d != %d\n", i, out[i], out_ref[i]);
                 fail();
             }
         }
@@ -122,74 +134,84 @@ static void run_remap_test_mono_stereo_s16(
         pa_log_debug("Testing remap performance with %d sample alignment", align);
 
         PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            remap_func->do_remap(remap_orig, stereo, mono, nsamples);
+            remap_func->do_remap(remap_func, out, in, nsamples);
         } PA_RUNTIME_TEST_RUN_STOP
 
         PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            remap_func->do_remap(remap_func, stereo_ref, mono, nsamples);
+            remap_orig->do_remap(remap_orig, out_ref, in, nsamples);
         } PA_RUNTIME_TEST_RUN_STOP
     }
 }
 
-static void setup_remap_mono_stereo(pa_remap_t *m, pa_sample_format_t f) {
+static void setup_remap_channels(
+    pa_remap_t *m,
+    pa_sample_format_t f,
+    unsigned in_channels,
+    unsigned out_channels) {
+
+    unsigned i, o;
+
     m->format = f;
-    m->i_ss.channels = 1;
-    m->o_ss.channels = 2;
-    m->map_table_f[0][0] = 1.0f;
-    m->map_table_f[1][0] = 1.0f;
-    m->map_table_i[0][0] = 0x10000;
-    m->map_table_i[1][0] = 0x10000;
-}
+    m->i_ss.channels = in_channels;
+    m->o_ss.channels = out_channels;
 
-static void remap_test_mono_stereo_float(
-        pa_init_remap_func_t init_func,
-        pa_init_remap_func_t orig_init_func) {
+    for (o = 0; o < out_channels; o++) {
+        for (i = 0; i < in_channels; i++) {
+            m->map_table_f[o][i] = 1.0f / in_channels;
+            m->map_table_i[o][i] = 0x10000 / in_channels;
+        }
+    }
+}
 
-    pa_remap_t remap_orig, remap_func;
+static void remap_test_channels(
+    pa_remap_t *remap_func, pa_remap_t *remap_orig) {
 
-    setup_remap_mono_stereo(&remap_orig, PA_SAMPLE_FLOAT32NE);
-    orig_init_func(&remap_orig);
-    if (!remap_orig.do_remap) {
+    if (!remap_orig->do_remap) {
         pa_log_warn("No reference remapping function, abort test");
         return;
     }
 
-    setup_remap_mono_stereo(&remap_func, PA_SAMPLE_FLOAT32NE);
-    init_func(&remap_func);
-    if (!remap_func.do_remap || remap_func.do_remap == remap_orig.do_remap) {
+    if (!remap_func->do_remap || remap_func->do_remap == remap_orig->do_remap) {
         pa_log_warn("No remapping function, abort test");
         return;
     }
 
-    run_remap_test_mono_stereo_float(&remap_func, &remap_orig, 0, true, false);
-    run_remap_test_mono_stereo_float(&remap_func, &remap_orig, 1, true, false);
-    run_remap_test_mono_stereo_float(&remap_func, &remap_orig, 2, true, false);
-    run_remap_test_mono_stereo_float(&remap_func, &remap_orig, 3, true, true);
+    pa_assert(remap_func->format == remap_orig->format);
+
+    switch (remap_func->format) {
+    case PA_SAMPLE_FLOAT32NE:
+        run_remap_test_float(remap_func, remap_orig, 0, true, false);
+        run_remap_test_float(remap_func, remap_orig, 1, true, false);
+        run_remap_test_float(remap_func, remap_orig, 2, true, false);
+        run_remap_test_float(remap_func, remap_orig, 3, true, true);
+        break;
+    case PA_SAMPLE_S16NE:
+        run_remap_test_s16(remap_func, remap_orig, 0, true, false);
+        run_remap_test_s16(remap_func, remap_orig, 1, true, false);
+        run_remap_test_s16(remap_func, remap_orig, 2, true, false);
+        run_remap_test_s16(remap_func, remap_orig, 3, true, true);
+        break;
+    default:
+        pa_assert_not_reached();
+    }
 }
 
-static void remap_test_mono_stereo_s16(
+static void remap_init_test_channels(
         pa_init_remap_func_t init_func,
-        pa_init_remap_func_t orig_init_func) {
+        pa_init_remap_func_t orig_init_func,
+        pa_sample_format_t f,
+        unsigned in_channels,
+        unsigned out_channels) {
 
     pa_remap_t remap_orig, remap_func;
 
-    setup_remap_mono_stereo(&remap_orig, PA_SAMPLE_S16NE);
+    setup_remap_channels(&remap_orig, f, in_channels, out_channels);
     orig_init_func(&remap_orig);
-    if (!remap_orig.do_remap) {
-        pa_log_warn("No reference remapping function, abort test");
-        return;
-    }
 
+    setup_remap_channels(&remap_func, f, in_channels, out_channels);
     init_func(&remap_func);
-    if (!remap_func.do_remap || remap_func.do_remap == remap_orig.do_remap) {
-        pa_log_warn("No remapping function, abort test");
-        return;
-    }
 
-    run_remap_test_mono_stereo_s16(&remap_func, &remap_orig, 0, true, false);
-    run_remap_test_mono_stereo_s16(&remap_func, &remap_orig, 1, true, false);
-    run_remap_test_mono_stereo_s16(&remap_func, &remap_orig, 2, true, false);
-    run_remap_test_mono_stereo_s16(&remap_func, &remap_orig, 3, true, true);
+    remap_test_channels(&remap_func, &remap_orig);
 }
 
 #if defined (__i386__) || defined (__amd64__)
@@ -207,10 +229,10 @@ START_TEST (remap_mmx_test) {
     orig_init_func = pa_get_init_remap_func();
     pa_remap_func_init_mmx(flags);
     init_func = pa_get_init_remap_func();
-    remap_test_mono_stereo_float(init_func, orig_init_func);
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2);
 
     pa_log_debug("Checking MMX remap (s16, mono->stereo)");
-    remap_test_mono_stereo_s16(init_func, orig_init_func);
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2);
 }
 END_TEST
 
@@ -228,10 +250,10 @@ START_TEST (remap_sse2_test) {
     orig_init_func = pa_get_init_remap_func();
     pa_remap_func_init_sse(flags);
     init_func = pa_get_init_remap_func();
-    remap_test_mono_stereo_float(init_func, orig_init_func);
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_FLOAT32NE, 1, 2);
 
     pa_log_debug("Checking SSE2 remap (s16, mono->stereo)");
-    remap_test_mono_stereo_s16(init_func, orig_init_func);
+    remap_init_test_channels(init_func, orig_init_func, PA_SAMPLE_S16NE, 1, 2);
 }
 END_TEST
 #endif /* defined (__i386__) || defined (__amd64__) */

commit 8f4897e162415a54ef926774889ba8f99fee9a1c
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Wed Apr 23 23:22:58 2014 +0200

    tests: Use remap function passed in remap struct
    
    Cleanup and add function to setup remap struct
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/cpu-remap-test.c b/src/tests/cpu-remap-test.c
index 4b8ddd7..eef5532 100644
--- a/src/tests/cpu-remap-test.c
+++ b/src/tests/cpu-remap-test.c
@@ -35,9 +35,8 @@
 #define TIMES2 100
 
 static void run_remap_test_mono_stereo_float(
-        pa_remap_t *remap,
-        pa_do_remap_func_t func,
-        pa_do_remap_func_t orig_func,
+        pa_remap_t *remap_func,
+        pa_remap_t *remap_orig,
         int align,
         bool correct,
         bool perf) {
@@ -59,11 +58,11 @@ static void run_remap_test_mono_stereo_float(
         mono[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
 
     if (correct) {
-        orig_func(remap, stereo_ref, mono, nsamples);
-        func(remap, stereo, mono, nsamples);
+        remap_orig->do_remap(remap_orig, stereo_ref, mono, nsamples);
+        remap_func->do_remap(remap_func, stereo, mono, nsamples);
 
         for (i = 0; i < nsamples * 2; i++) {
-            if (fabsf(stereo[i] - stereo_ref[i]) > 0.0001) {
+            if (fabsf(stereo[i] - stereo_ref[i]) > 0.0001f) {
                 pa_log_debug("Correctness test failed: align=%d", align);
                 pa_log_debug("%d: %.24f != %.24f (%.24f)\n", i, stereo[i], stereo_ref[i], mono[i]);
                 fail();
@@ -75,19 +74,18 @@ static void run_remap_test_mono_stereo_float(
         pa_log_debug("Testing remap performance with %d sample alignment", align);
 
         PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            func(remap, stereo, mono, nsamples);
+            remap_func->do_remap(remap_func, stereo, mono, nsamples);
         } PA_RUNTIME_TEST_RUN_STOP
 
         PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            orig_func(remap, stereo_ref, mono, nsamples);
+            remap_orig->do_remap(remap_orig, stereo_ref, mono, nsamples);
         } PA_RUNTIME_TEST_RUN_STOP
     }
 }
 
 static void run_remap_test_mono_stereo_s16(
-        pa_remap_t *remap,
-        pa_do_remap_func_t func,
-        pa_do_remap_func_t orig_func,
+        pa_remap_t *remap_func,
+        pa_remap_t *remap_orig,
         int align,
         bool correct,
         bool perf) {
@@ -108,8 +106,8 @@ static void run_remap_test_mono_stereo_s16(
     pa_random(mono, nsamples * sizeof(int16_t));
 
     if (correct) {
-        orig_func(remap, stereo_ref, mono, nsamples);
-        func(remap, stereo, mono, nsamples);
+        remap_orig->do_remap(remap_orig, stereo_ref, mono, nsamples);
+        remap_func->do_remap(remap_func, stereo, mono, nsamples);
 
         for (i = 0; i < nsamples * 2; i++) {
             if (abs(stereo[i] - stereo_ref[i]) > 1) {
@@ -124,81 +122,74 @@ static void run_remap_test_mono_stereo_s16(
         pa_log_debug("Testing remap performance with %d sample alignment", align);
 
         PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            func(remap, stereo, mono, nsamples);
+            remap_func->do_remap(remap_orig, stereo, mono, nsamples);
         } PA_RUNTIME_TEST_RUN_STOP
 
         PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            orig_func(remap, stereo_ref, mono, nsamples);
+            remap_func->do_remap(remap_func, stereo_ref, mono, nsamples);
         } PA_RUNTIME_TEST_RUN_STOP
     }
 }
 
+static void setup_remap_mono_stereo(pa_remap_t *m, pa_sample_format_t f) {
+    m->format = f;
+    m->i_ss.channels = 1;
+    m->o_ss.channels = 2;
+    m->map_table_f[0][0] = 1.0f;
+    m->map_table_f[1][0] = 1.0f;
+    m->map_table_i[0][0] = 0x10000;
+    m->map_table_i[1][0] = 0x10000;
+}
+
 static void remap_test_mono_stereo_float(
         pa_init_remap_func_t init_func,
         pa_init_remap_func_t orig_init_func) {
 
-    pa_remap_t remap;
-    pa_do_remap_func_t orig_func, func;
-
-    remap.format = PA_SAMPLE_FLOAT32NE;
-    remap.i_ss.channels = 1;
-    remap.o_ss.channels = 2;
-    remap.map_table_f[0][0] = 1.0;
-    remap.map_table_f[1][0] = 1.0;
-    remap.map_table_i[0][0] = 0x10000;
-    remap.map_table_i[1][0] = 0x10000;
-    orig_init_func(&remap);
-    orig_func = remap.do_remap;
-    if (!orig_func) {
+    pa_remap_t remap_orig, remap_func;
+
+    setup_remap_mono_stereo(&remap_orig, PA_SAMPLE_FLOAT32NE);
+    orig_init_func(&remap_orig);
+    if (!remap_orig.do_remap) {
         pa_log_warn("No reference remapping function, abort test");
         return;
     }
 
-    init_func(&remap);
-    func = remap.do_remap;
-    if (!func || func == orig_func) {
+    setup_remap_mono_stereo(&remap_func, PA_SAMPLE_FLOAT32NE);
+    init_func(&remap_func);
+    if (!remap_func.do_remap || remap_func.do_remap == remap_orig.do_remap) {
         pa_log_warn("No remapping function, abort test");
         return;
     }
 
-    run_remap_test_mono_stereo_float(&remap, func, orig_func, 0, true, false);
-    run_remap_test_mono_stereo_float(&remap, func, orig_func, 1, true, false);
-    run_remap_test_mono_stereo_float(&remap, func, orig_func, 2, true, false);
-    run_remap_test_mono_stereo_float(&remap, func, orig_func, 3, true, true);
+    run_remap_test_mono_stereo_float(&remap_func, &remap_orig, 0, true, false);
+    run_remap_test_mono_stereo_float(&remap_func, &remap_orig, 1, true, false);
+    run_remap_test_mono_stereo_float(&remap_func, &remap_orig, 2, true, false);
+    run_remap_test_mono_stereo_float(&remap_func, &remap_orig, 3, true, true);
 }
 
 static void remap_test_mono_stereo_s16(
         pa_init_remap_func_t init_func,
         pa_init_remap_func_t orig_init_func) {
 
-    pa_remap_t remap;
-    pa_do_remap_func_t orig_func, func;
-
-    remap.format = PA_SAMPLE_S16NE;
-    remap.i_ss.channels = 1;
-    remap.o_ss.channels = 2;
-    remap.map_table_f[0][0] = 1.0;
-    remap.map_table_f[1][0] = 1.0;
-    remap.map_table_i[0][0] = 0x10000;
-    remap.map_table_i[1][0] = 0x10000;
-    orig_init_func(&remap);
-    orig_func = remap.do_remap;
-    if (!orig_func) {
+    pa_remap_t remap_orig, remap_func;
+
+    setup_remap_mono_stereo(&remap_orig, PA_SAMPLE_S16NE);
+    orig_init_func(&remap_orig);
+    if (!remap_orig.do_remap) {
         pa_log_warn("No reference remapping function, abort test");
         return;
     }
 
-    init_func(&remap);
-    func = remap.do_remap;
-    if (!func || func == orig_func) {
+    init_func(&remap_func);
+    if (!remap_func.do_remap || remap_func.do_remap == remap_orig.do_remap) {
         pa_log_warn("No remapping function, abort test");
         return;
     }
 
-    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 0, true, false);
-    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 1, true, false);
-    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 2, true, false);
-    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 3, true, true);
+    run_remap_test_mono_stereo_s16(&remap_func, &remap_orig, 0, true, false);
+    run_remap_test_mono_stereo_s16(&remap_func, &remap_orig, 1, true, false);
+    run_remap_test_mono_stereo_s16(&remap_func, &remap_orig, 2, true, false);
+    run_remap_test_mono_stereo_s16(&remap_func, &remap_orig, 3, true, true);
 }
 
 #if defined (__i386__) || defined (__amd64__)

commit 173649e4f740621566aeefce3c9819284efb1812
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Wed Apr 23 22:49:14 2014 +0200

    tests: Add ARM NEON test code to cpu-mix-test
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/cpu-mix-test.c b/src/tests/cpu-mix-test.c
index ab53c6c..181a767 100644
--- a/src/tests/cpu-mix-test.c
+++ b/src/tests/cpu-mix-test.c
@@ -186,8 +186,14 @@ START_TEST (mix_neon_test) {
     pa_mix_func_init_neon(flags);
     neon_func = pa_get_mix_func(PA_SAMPLE_S16NE);
 
-    pa_log_debug("Checking NEON mix");
+    pa_log_debug("Checking NEON mix (s16, stereo)");
     run_mix_test(neon_func, orig_func, 7, 2, true, true);
+
+    pa_log_debug("Checking NEON mix (s16, 4-channel)");
+    run_mix_test(neon_func, orig_func, 7, 4, true, true);
+
+    pa_log_debug("Checking NEON mix (s16, mono)");
+    run_mix_test(neon_func, orig_func, 7, 1, true, true);
 }
 END_TEST
 #endif /* defined (__arm__) && defined (__linux__) && defined (HAVE_NEON) */

commit d58446963fd71a73c9b5b9f62843bc16deaba6ea
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Wed Apr 23 22:48:53 2014 +0200

    tests: Add tests for mix special-case code
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/cpu-mix-test.c b/src/tests/cpu-mix-test.c
index 2facaae..ab53c6c 100644
--- a/src/tests/cpu-mix-test.c
+++ b/src/tests/cpu-mix-test.c
@@ -23,6 +23,7 @@
 
 #include <check.h>
 
+#include <pulsecore/cpu.h>
 #include <pulsecore/cpu-arm.h>
 #include <pulsecore/random.h>
 #include <pulsecore/macro.h>
@@ -30,10 +31,6 @@
 
 #include "runtime-test-util.h"
 
-/* Only ARM NEON has mix tests, so disable the related functions for other
- * architectures for now to avoid compiler warnings about unused functions. */
-#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
-
 #define SAMPLES 1028
 #define TIMES 1000
 #define TIMES2 100
@@ -149,7 +146,29 @@ static void run_mix_test(
 
     pa_mempool_free(pool);
 }
-#endif /* defined (__arm__) && defined (__linux__) && defined (HAVE_NEON) */
+
+START_TEST (mix_special_test) {
+    pa_cpu_info cpu_info = { PA_CPU_UNDEFINED, {}, false };
+    pa_do_mix_func_t orig_func, special_func;
+
+    cpu_info.force_generic_code = true;
+    pa_mix_func_init(&cpu_info);
+    orig_func = pa_get_mix_func(PA_SAMPLE_S16NE);
+
+    cpu_info.force_generic_code = false;
+    pa_mix_func_init(&cpu_info);
+    special_func = pa_get_mix_func(PA_SAMPLE_S16NE);
+
+    pa_log_debug("Checking special mix (s16, stereo)");
+    run_mix_test(special_func, orig_func, 7, 2, true, true);
+
+    pa_log_debug("Checking special mix (s16, 4-channel)");
+    run_mix_test(special_func, orig_func, 7, 4, true, true);
+
+    pa_log_debug("Checking special mix (s16, mono)");
+    run_mix_test(special_func, orig_func, 7, 1, true, true);
+}
+END_TEST
 
 #if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
 START_TEST (mix_neon_test) {
@@ -185,6 +204,7 @@ int main(int argc, char *argv[]) {
     s = suite_create("CPU");
 
     tc = tcase_create("mix");
+    tcase_add_test(tc, mix_special_test);
 #if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
     tcase_add_test(tc, mix_neon_test);
 #endif

commit 9576ba2d9e62625f1dad0151330ad14ccf429dc3
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Tue Apr 22 18:25:48 2014 +0200

    tests: Use single-line #ifdef for ARM NEON code
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/tests/cpu-mix-test.c b/src/tests/cpu-mix-test.c
index 934c33f..2facaae 100644
--- a/src/tests/cpu-mix-test.c
+++ b/src/tests/cpu-mix-test.c
@@ -32,8 +32,7 @@
 
 /* Only ARM NEON has mix tests, so disable the related functions for other
  * architectures for now to avoid compiler warnings about unused functions. */
-#if defined (__arm__) && defined (__linux__)
-#ifdef HAVE_NEON
+#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
 
 #define SAMPLES 1028
 #define TIMES 1000
@@ -150,11 +149,9 @@ static void run_mix_test(
 
     pa_mempool_free(pool);
 }
-#endif /* HAVE_NEON */
-#endif /* defined (__arm__) && defined (__linux__) */
+#endif /* defined (__arm__) && defined (__linux__) && defined (HAVE_NEON) */
 
-#if defined (__arm__) && defined (__linux__)
-#ifdef HAVE_NEON
+#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
 START_TEST (mix_neon_test) {
     pa_do_mix_func_t orig_func, neon_func;
     pa_cpu_arm_flag_t flags = 0;
@@ -174,8 +171,7 @@ START_TEST (mix_neon_test) {
     run_mix_test(neon_func, orig_func, 7, 2, true, true);
 }
 END_TEST
-#endif /* HAVE_NEON */
-#endif /* defined (__arm__) && defined (__linux__) */
+#endif /* defined (__arm__) && defined (__linux__) && defined (HAVE_NEON) */
 
 int main(int argc, char *argv[]) {
     int failed = 0;
@@ -189,11 +185,9 @@ int main(int argc, char *argv[]) {
     s = suite_create("CPU");
 
     tc = tcase_create("mix");
-#if defined (__arm__) && defined (__linux__)
-#if HAVE_NEON
+#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
     tcase_add_test(tc, mix_neon_test);
 #endif
-#endif
     tcase_set_timeout(tc, 120);
     suite_add_tcase(s, tc);
 
diff --git a/src/tests/cpu-sconv-test.c b/src/tests/cpu-sconv-test.c
index f89f593..4e7848d 100644
--- a/src/tests/cpu-sconv-test.c
+++ b/src/tests/cpu-sconv-test.c
@@ -86,8 +86,7 @@ static void run_conv_test_float_to_s16(
 }
 
 /* This test is currently only run under NEON */
-#if defined (__arm__) && defined (__linux__)
-#ifdef HAVE_NEON
+#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
 static void run_conv_test_s16_to_float(
         pa_convert_func_t func,
         pa_convert_func_t orig_func,
@@ -135,8 +134,7 @@ static void run_conv_test_s16_to_float(
         } PA_RUNTIME_TEST_RUN_STOP
     }
 }
-#endif /* HAVE_NEON */
-#endif /* defined (__arm__) && defined (__linux__) */
+#endif /* defined (__arm__) && defined (__linux__) && defined (HAVE_NEON) */
 
 #if defined (__i386__) || defined (__amd64__)
 START_TEST (sconv_sse2_test) {
@@ -194,8 +192,7 @@ START_TEST (sconv_sse_test) {
 END_TEST
 #endif /* defined (__i386__) || defined (__amd64__) */
 
-#if defined (__arm__) && defined (__linux__)
-#ifdef HAVE_NEON
+#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
 START_TEST (sconv_neon_test) {
     pa_cpu_arm_flag_t flags = 0;
     pa_convert_func_t orig_from_func, neon_from_func;
@@ -235,8 +232,7 @@ START_TEST (sconv_neon_test) {
     run_conv_test_s16_to_float(neon_to_func, orig_to_func, 7, true, true);
 }
 END_TEST
-#endif /* HAVE_NEON */
-#endif /* defined (__arm__) && defined (__linux__) */
+#endif /* defined (__arm__) && defined (__linux__) && defined (HAVE_NEON) */
 
 int main(int argc, char *argv[]) {
     int failed = 0;
@@ -254,11 +250,9 @@ int main(int argc, char *argv[]) {
     tcase_add_test(tc, sconv_sse2_test);
     tcase_add_test(tc, sconv_sse_test);
 #endif
-#if defined (__arm__) && defined (__linux__)
-#if HAVE_NEON
+#if defined (__arm__) && defined (__linux__) && defined (HAVE_NEON)
     tcase_add_test(tc, sconv_neon_test);
 #endif
-#endif
     tcase_set_timeout(tc, 120);
     suite_add_tcase(s, tc);
 

commit 4ca3216ee30794ac186f70843a13553407fa5d52
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Tue Apr 22 18:19:05 2014 +0200

    tests: Split cpu tests in separate files
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/.gitignore b/src/.gitignore
index 1490262..a90c7dc 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -36,7 +36,10 @@ close-test
 connect-stress
 cpulimit-test
 cpulimit-test2
-cpu-test
+cpu-sconv-test
+cpu-remap-test
+cpu-mix-test
+cpu-volume-test
 extended-test
 flist-test
 format-test
diff --git a/src/Makefile.am b/src/Makefile.am
index 40d8c04..2ff4967 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -244,7 +244,10 @@ TESTS_default = \
 		volume-test \
 		mix-test \
 		proplist-test \
-		cpu-test \
+		cpu-mix-test \
+		cpu-remap-test \
+		cpu-sconv-test \
+		cpu-volume-test \
 		lock-autospawn-test \
 		mult-s16-test \
 		mix-special-test
@@ -510,10 +513,25 @@ proplist_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la li
 proplist_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
 proplist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
 
-cpu_test_SOURCES = tests/cpu-test.c tests/runtime-test-util.h
-cpu_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
-cpu_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
-cpu_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
+cpu_mix_test_SOURCES = tests/cpu-mix-test.c tests/runtime-test-util.h
+cpu_mix_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
+cpu_mix_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
+cpu_mix_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
+
+cpu_remap_test_SOURCES = tests/cpu-remap-test.c tests/runtime-test-util.h
+cpu_remap_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
+cpu_remap_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
+cpu_remap_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
+
+cpu_sconv_test_SOURCES = tests/cpu-sconv-test.c tests/runtime-test-util.h
+cpu_sconv_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
+cpu_sconv_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
+cpu_sconv_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
+
+cpu_volume_test_SOURCES = tests/cpu-volume-test.c tests/runtime-test-util.h
+cpu_volume_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
+cpu_volume_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
+cpu_volume_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
 
 mult_s16_test_SOURCES = tests/mult-s16-test.c tests/runtime-test-util.h
 mult_s16_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINOR@.la libpulse.la libpulsecommon- at PA_MAJORMINOR@.la
diff --git a/src/tests/cpu-mix-test.c b/src/tests/cpu-mix-test.c
new file mode 100644
index 0000000..934c33f
--- /dev/null
+++ b/src/tests/cpu-mix-test.c
@@ -0,0 +1,206 @@
+/***
+  This file is part of PulseAudio.
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <check.h>
+
+#include <pulsecore/cpu-arm.h>
+#include <pulsecore/random.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/mix.h>
+
+#include "runtime-test-util.h"
+
+/* Only ARM NEON has mix tests, so disable the related functions for other
+ * architectures for now to avoid compiler warnings about unused functions. */
+#if defined (__arm__) && defined (__linux__)
+#ifdef HAVE_NEON
+
+#define SAMPLES 1028
+#define TIMES 1000
+#define TIMES2 100
+
+static void acquire_mix_streams(pa_mix_info streams[], unsigned nstreams) {
+    unsigned i;
+
+    for (i = 0; i < nstreams; i++)
+        streams[i].ptr = pa_memblock_acquire_chunk(&streams[i].chunk);
+}
+
+static void release_mix_streams(pa_mix_info streams[], unsigned nstreams) {
+    unsigned i;
+
+    for (i = 0; i < nstreams; i++)
+        pa_memblock_release(streams[i].chunk.memblock);
+}
+
+static void run_mix_test(
+        pa_do_mix_func_t func,
+        pa_do_mix_func_t orig_func,
+        int align,
+        int channels,
+        bool correct,
+        bool perf) {
+
+    PA_DECLARE_ALIGNED(8, int16_t, in0[SAMPLES * 4]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, in1[SAMPLES * 4]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, out[SAMPLES * 4]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, out_ref[SAMPLES * 4]) = { 0 };
+    int16_t *samples0, *samples1;
+    int16_t *samples, *samples_ref;
+    int nsamples;
+    pa_mempool *pool;
+    pa_memchunk c0, c1;
+    pa_mix_info m[2];
+    int i;
+
+    pa_assert(channels == 1 || channels == 2 || channels == 4);
+
+    /* Force sample alignment as requested */
+    samples0 = in0 + (8 - align);
+    samples1 = in1 + (8 - align);
+    samples = out + (8 - align);
+    samples_ref = out_ref + (8 - align);
+    nsamples = channels * (SAMPLES - (8 - align));
+
+    fail_unless((pool = pa_mempool_new(false, 0)) != NULL, NULL);
+
+    pa_random(samples0, nsamples * sizeof(int16_t));
+    c0.memblock = pa_memblock_new_fixed(pool, samples0, nsamples * sizeof(int16_t), false);
+    c0.length = pa_memblock_get_length(c0.memblock);
+    c0.index = 0;
+
+    pa_random(samples1, nsamples * sizeof(int16_t));
+    c1.memblock = pa_memblock_new_fixed(pool, samples1, nsamples * sizeof(int16_t), false);
+    c1.length = pa_memblock_get_length(c1.memblock);
+    c1.index = 0;
+
+    m[0].chunk = c0;
+    m[0].volume.channels = channels;
+    for (i = 0; i < channels; i++) {
+        m[0].volume.values[i] = PA_VOLUME_NORM;
+        m[0].linear[i].i = 0x5555;
+    }
+
+    m[1].chunk = c1;
+    m[1].volume.channels = channels;
+    for (i = 0; i < channels; i++) {
+        m[1].volume.values[i] = PA_VOLUME_NORM;
+        m[1].linear[i].i = 0x6789;
+    }
+
+    if (correct) {
+        acquire_mix_streams(m, 2);
+        orig_func(m, 2, channels, samples_ref, nsamples * sizeof(int16_t));
+        release_mix_streams(m, 2);
+
+        acquire_mix_streams(m, 2);
+        func(m, 2, channels, samples, nsamples * sizeof(int16_t));
+        release_mix_streams(m, 2);
+
+        for (i = 0; i < nsamples; i++) {
+            if (samples[i] != samples_ref[i]) {
+                pa_log_debug("Correctness test failed: align=%d, channels=%d", align, channels);
+                pa_log_debug("%d: %hd != %04hd (%hd + %hd)\n",
+                    i,
+                    samples[i], samples_ref[i],
+                    samples0[i], samples1[i]);
+                fail();
+            }
+        }
+    }
+
+    if (perf) {
+        pa_log_debug("Testing %d-channel mixing performance with %d sample alignment", channels, align);
+
+        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
+            acquire_mix_streams(m, 2);
+            func(m, 2, channels, samples, nsamples * sizeof(int16_t));
+            release_mix_streams(m, 2);
+        } PA_RUNTIME_TEST_RUN_STOP
+
+        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
+            acquire_mix_streams(m, 2);
+            orig_func(m, 2, channels, samples_ref, nsamples * sizeof(int16_t));
+            release_mix_streams(m, 2);
+        } PA_RUNTIME_TEST_RUN_STOP
+    }
+
+    pa_memblock_unref(c0.memblock);
+    pa_memblock_unref(c1.memblock);
+
+    pa_mempool_free(pool);
+}
+#endif /* HAVE_NEON */
+#endif /* defined (__arm__) && defined (__linux__) */
+
+#if defined (__arm__) && defined (__linux__)
+#ifdef HAVE_NEON
+START_TEST (mix_neon_test) {
+    pa_do_mix_func_t orig_func, neon_func;
+    pa_cpu_arm_flag_t flags = 0;
+
+    pa_cpu_get_arm_flags(&flags);
+
+    if (!(flags & PA_CPU_ARM_NEON)) {
+        pa_log_info("NEON not supported. Skipping");
+        return;
+    }
+
+    orig_func = pa_get_mix_func(PA_SAMPLE_S16NE);
+    pa_mix_func_init_neon(flags);
+    neon_func = pa_get_mix_func(PA_SAMPLE_S16NE);
+
+    pa_log_debug("Checking NEON mix");
+    run_mix_test(neon_func, orig_func, 7, 2, true, true);
+}
+END_TEST
+#endif /* HAVE_NEON */
+#endif /* defined (__arm__) && defined (__linux__) */
+
+int main(int argc, char *argv[]) {
+    int failed = 0;
+    Suite *s;
+    TCase *tc;
+    SRunner *sr;
+
+    if (!getenv("MAKE_CHECK"))
+        pa_log_set_level(PA_LOG_DEBUG);
+
+    s = suite_create("CPU");
+
+    tc = tcase_create("mix");
+#if defined (__arm__) && defined (__linux__)
+#if HAVE_NEON
+    tcase_add_test(tc, mix_neon_test);
+#endif
+#endif
+    tcase_set_timeout(tc, 120);
+    suite_add_tcase(s, tc);
+
+    sr = srunner_create(s);
+    srunner_run_all(sr, CK_NORMAL);
+    failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+
+    return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/src/tests/cpu-remap-test.c b/src/tests/cpu-remap-test.c
new file mode 100644
index 0000000..4b8ddd7
--- /dev/null
+++ b/src/tests/cpu-remap-test.c
@@ -0,0 +1,273 @@
+/***
+  This file is part of PulseAudio.
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <check.h>
+
+#include <pulsecore/cpu-x86.h>
+#include <pulsecore/random.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/remap.h>
+
+#include "runtime-test-util.h"
+
+#define SAMPLES 1028
+#define TIMES 1000
+#define TIMES2 100
+
+static void run_remap_test_mono_stereo_float(
+        pa_remap_t *remap,
+        pa_do_remap_func_t func,
+        pa_do_remap_func_t orig_func,
+        int align,
+        bool correct,
+        bool perf) {
+
+    PA_DECLARE_ALIGNED(8, float, s_ref[SAMPLES*2]) = { 0 };
+    PA_DECLARE_ALIGNED(8, float, s[SAMPLES*2]) = { 0 };
+    PA_DECLARE_ALIGNED(8, float, m[SAMPLES]);
+    float *stereo, *stereo_ref;
+    float *mono;
+    int i, nsamples;
+
+    /* Force sample alignment as requested */
+    stereo = s + (8 - align);
+    stereo_ref = s_ref + (8 - align);
+    mono = m + (8 - align);
+    nsamples = SAMPLES - (8 - align);
+
+    for (i = 0; i < nsamples; i++)
+        mono[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
+
+    if (correct) {
+        orig_func(remap, stereo_ref, mono, nsamples);
+        func(remap, stereo, mono, nsamples);
+
+        for (i = 0; i < nsamples * 2; i++) {
+            if (fabsf(stereo[i] - stereo_ref[i]) > 0.0001) {
+                pa_log_debug("Correctness test failed: align=%d", align);
+                pa_log_debug("%d: %.24f != %.24f (%.24f)\n", i, stereo[i], stereo_ref[i], mono[i]);
+                fail();
+            }
+        }
+    }
+
+    if (perf) {
+        pa_log_debug("Testing remap performance with %d sample alignment", align);
+
+        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
+            func(remap, stereo, mono, nsamples);
+        } PA_RUNTIME_TEST_RUN_STOP
+
+        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
+            orig_func(remap, stereo_ref, mono, nsamples);
+        } PA_RUNTIME_TEST_RUN_STOP
+    }
+}
+
+static void run_remap_test_mono_stereo_s16(
+        pa_remap_t *remap,
+        pa_do_remap_func_t func,
+        pa_do_remap_func_t orig_func,
+        int align,
+        bool correct,
+        bool perf) {
+
+    PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES*2]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES*2]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, m[SAMPLES]);
+    int16_t *stereo, *stereo_ref;
+    int16_t *mono;
+    int i, nsamples;
+
+    /* Force sample alignment as requested */
+    stereo = s + (8 - align);
+    stereo_ref = s_ref + (8 - align);
+    mono = m + (8 - align);
+    nsamples = SAMPLES - (8 - align);
+
+    pa_random(mono, nsamples * sizeof(int16_t));
+
+    if (correct) {
+        orig_func(remap, stereo_ref, mono, nsamples);
+        func(remap, stereo, mono, nsamples);
+
+        for (i = 0; i < nsamples * 2; i++) {
+            if (abs(stereo[i] - stereo_ref[i]) > 1) {
+                pa_log_debug("Correctness test failed: align=%d", align);
+                pa_log_debug("%d: %d != %d (%d)\n", i, stereo[i], stereo_ref[i], mono[i]);
+                fail();
+            }
+        }
+    }
+
+    if (perf) {
+        pa_log_debug("Testing remap performance with %d sample alignment", align);
+
+        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
+            func(remap, stereo, mono, nsamples);
+        } PA_RUNTIME_TEST_RUN_STOP
+
+        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
+            orig_func(remap, stereo_ref, mono, nsamples);
+        } PA_RUNTIME_TEST_RUN_STOP
+    }
+}
+
+static void remap_test_mono_stereo_float(
+        pa_init_remap_func_t init_func,
+        pa_init_remap_func_t orig_init_func) {
+
+    pa_remap_t remap;
+    pa_do_remap_func_t orig_func, func;
+
+    remap.format = PA_SAMPLE_FLOAT32NE;
+    remap.i_ss.channels = 1;
+    remap.o_ss.channels = 2;
+    remap.map_table_f[0][0] = 1.0;
+    remap.map_table_f[1][0] = 1.0;
+    remap.map_table_i[0][0] = 0x10000;
+    remap.map_table_i[1][0] = 0x10000;
+    orig_init_func(&remap);
+    orig_func = remap.do_remap;
+    if (!orig_func) {
+        pa_log_warn("No reference remapping function, abort test");
+        return;
+    }
+
+    init_func(&remap);
+    func = remap.do_remap;
+    if (!func || func == orig_func) {
+        pa_log_warn("No remapping function, abort test");
+        return;
+    }
+
+    run_remap_test_mono_stereo_float(&remap, func, orig_func, 0, true, false);
+    run_remap_test_mono_stereo_float(&remap, func, orig_func, 1, true, false);
+    run_remap_test_mono_stereo_float(&remap, func, orig_func, 2, true, false);
+    run_remap_test_mono_stereo_float(&remap, func, orig_func, 3, true, true);
+}
+
+static void remap_test_mono_stereo_s16(
+        pa_init_remap_func_t init_func,
+        pa_init_remap_func_t orig_init_func) {
+
+    pa_remap_t remap;
+    pa_do_remap_func_t orig_func, func;
+
+    remap.format = PA_SAMPLE_S16NE;
+    remap.i_ss.channels = 1;
+    remap.o_ss.channels = 2;
+    remap.map_table_f[0][0] = 1.0;
+    remap.map_table_f[1][0] = 1.0;
+    remap.map_table_i[0][0] = 0x10000;
+    remap.map_table_i[1][0] = 0x10000;
+    orig_init_func(&remap);
+    orig_func = remap.do_remap;
+    if (!orig_func) {
+        pa_log_warn("No reference remapping function, abort test");
+        return;
+    }
+
+    init_func(&remap);
+    func = remap.do_remap;
+    if (!func || func == orig_func) {
+        pa_log_warn("No remapping function, abort test");
+        return;
+    }
+
+    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 0, true, false);
+    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 1, true, false);
+    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 2, true, false);
+    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 3, true, true);
+}
+
+#if defined (__i386__) || defined (__amd64__)
+START_TEST (remap_mmx_test) {
+    pa_cpu_x86_flag_t flags = 0;
+    pa_init_remap_func_t init_func, orig_init_func;
+
+    pa_cpu_get_x86_flags(&flags);
+    if (!(flags & PA_CPU_X86_MMX)) {
+        pa_log_info("MMX not supported. Skipping");
+        return;
+    }
+
+    pa_log_debug("Checking MMX remap (float, mono->stereo)");
+    orig_init_func = pa_get_init_remap_func();
+    pa_remap_func_init_mmx(flags);
+    init_func = pa_get_init_remap_func();
+    remap_test_mono_stereo_float(init_func, orig_init_func);
+
+    pa_log_debug("Checking MMX remap (s16, mono->stereo)");
+    remap_test_mono_stereo_s16(init_func, orig_init_func);
+}
+END_TEST
+
+START_TEST (remap_sse2_test) {
+    pa_cpu_x86_flag_t flags = 0;
+    pa_init_remap_func_t init_func, orig_init_func;
+
+    pa_cpu_get_x86_flags(&flags);
+    if (!(flags & PA_CPU_X86_SSE2)) {
+        pa_log_info("SSE2 not supported. Skipping");
+        return;
+    }
+
+    pa_log_debug("Checking SSE2 remap (float, mono->stereo)");
+    orig_init_func = pa_get_init_remap_func();
+    pa_remap_func_init_sse(flags);
+    init_func = pa_get_init_remap_func();
+    remap_test_mono_stereo_float(init_func, orig_init_func);
+
+    pa_log_debug("Checking SSE2 remap (s16, mono->stereo)");
+    remap_test_mono_stereo_s16(init_func, orig_init_func);
+}
+END_TEST
+#endif /* defined (__i386__) || defined (__amd64__) */
+
+int main(int argc, char *argv[]) {
+    int failed = 0;
+    Suite *s;
+    TCase *tc;
+    SRunner *sr;
+
+    if (!getenv("MAKE_CHECK"))
+        pa_log_set_level(PA_LOG_DEBUG);
+
+    s = suite_create("CPU");
+
+    tc = tcase_create("remap");
+#if defined (__i386__) || defined (__amd64__)
+    tcase_add_test(tc, remap_mmx_test);
+    tcase_add_test(tc, remap_sse2_test);
+#endif
+    tcase_set_timeout(tc, 120);
+    suite_add_tcase(s, tc);
+
+    sr = srunner_create(s);
+    srunner_run_all(sr, CK_NORMAL);
+    failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+
+    return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/src/tests/cpu-sconv-test.c b/src/tests/cpu-sconv-test.c
new file mode 100644
index 0000000..f89f593
--- /dev/null
+++ b/src/tests/cpu-sconv-test.c
@@ -0,0 +1,271 @@
+/***
+  This file is part of PulseAudio.
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <check.h>
+
+#include <pulsecore/cpu-arm.h>
+#include <pulsecore/cpu-x86.h>
+#include <pulsecore/random.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/sconv.h>
+
+#include "runtime-test-util.h"
+
+#define SAMPLES 1028
+#define TIMES 1000
+#define TIMES2 100
+
+static void run_conv_test_float_to_s16(
+        pa_convert_func_t func,
+        pa_convert_func_t orig_func,
+        int align,
+        bool correct,
+        bool perf) {
+
+    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES]) = { 0 };
+    PA_DECLARE_ALIGNED(8, float, f[SAMPLES]);
+    int16_t *samples, *samples_ref;
+    float *floats;
+    int i, nsamples;
+
+    /* Force sample alignment as requested */
+    samples = s + (8 - align);
+    samples_ref = s_ref + (8 - align);
+    floats = f + (8 - align);
+    nsamples = SAMPLES - (8 - align);
+
+    for (i = 0; i < nsamples; i++) {
+        floats[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
+    }
+
+    if (correct) {
+        orig_func(nsamples, floats, samples_ref);
+        func(nsamples, floats, samples);
+
+        for (i = 0; i < nsamples; i++) {
+            if (abs(samples[i] - samples_ref[i]) > 1) {
+                pa_log_debug("Correctness test failed: align=%d", align);
+                pa_log_debug("%d: %04hx != %04hx (%.24f)\n", i, samples[i], samples_ref[i], floats[i]);
+                fail();
+            }
+        }
+    }
+
+    if (perf) {
+        pa_log_debug("Testing sconv performance with %d sample alignment", align);
+
+        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
+            func(nsamples, floats, samples);
+        } PA_RUNTIME_TEST_RUN_STOP
+
+        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
+            orig_func(nsamples, floats, samples_ref);
+        } PA_RUNTIME_TEST_RUN_STOP
+    }
+}
+
+/* This test is currently only run under NEON */
+#if defined (__arm__) && defined (__linux__)
+#ifdef HAVE_NEON
+static void run_conv_test_s16_to_float(
+        pa_convert_func_t func,
+        pa_convert_func_t orig_func,
+        int align,
+        bool correct,
+        bool perf) {
+
+    PA_DECLARE_ALIGNED(8, float, f[SAMPLES]) = { 0 };
+    PA_DECLARE_ALIGNED(8, float, f_ref[SAMPLES]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]);
+    float *floats, *floats_ref;
+    int16_t *samples;
+    int i, nsamples;
+
+    /* Force sample alignment as requested */
+    floats = f + (8 - align);
+    floats_ref = f_ref + (8 - align);
+    samples = s + (8 - align);
+    nsamples = SAMPLES - (8 - align);
+
+    pa_random(samples, nsamples * sizeof(int16_t));
+
+    if (correct) {
+        orig_func(nsamples, samples, floats_ref);
+        func(nsamples, samples, floats);
+
+        for (i = 0; i < nsamples; i++) {
+            if (fabsf(floats[i] - floats_ref[i]) > 0.0001) {
+                pa_log_debug("Correctness test failed: align=%d", align);
+                pa_log_debug("%d: %.24f != %.24f (%d)\n", i, floats[i], floats_ref[i], samples[i]);
+                fail();
+            }
+        }
+    }
+
+    if (perf) {
+        pa_log_debug("Testing sconv performance with %d sample alignment", align);
+
+        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
+            func(nsamples, samples, floats);
+        } PA_RUNTIME_TEST_RUN_STOP
+
+        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
+            orig_func(nsamples, samples, floats_ref);
+        } PA_RUNTIME_TEST_RUN_STOP
+    }
+}
+#endif /* HAVE_NEON */
+#endif /* defined (__arm__) && defined (__linux__) */
+
+#if defined (__i386__) || defined (__amd64__)
+START_TEST (sconv_sse2_test) {
+    pa_cpu_x86_flag_t flags = 0;
+    pa_convert_func_t orig_func, sse2_func;
+
+    pa_cpu_get_x86_flags(&flags);
+
+    if (!(flags & PA_CPU_X86_SSE2)) {
+        pa_log_info("SSE2 not supported. Skipping");
+        return;
+    }
+
+    orig_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
+    pa_convert_func_init_sse(PA_CPU_X86_SSE2);
+    sse2_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
+
+    pa_log_debug("Checking SSE2 sconv (float -> s16)");
+    run_conv_test_float_to_s16(sse2_func, orig_func, 0, true, false);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 1, true, false);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 2, true, false);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 3, true, false);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 4, true, false);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 5, true, false);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 6, true, false);
+    run_conv_test_float_to_s16(sse2_func, orig_func, 7, true, true);
+}
+END_TEST
+
+START_TEST (sconv_sse_test) {
+    pa_cpu_x86_flag_t flags = 0;
+    pa_convert_func_t orig_func, sse_func;
+
+    pa_cpu_get_x86_flags(&flags);
+
+    if (!(flags & PA_CPU_X86_SSE)) {
+        pa_log_info("SSE not supported. Skipping");
+        return;
+    }
+
+    orig_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
+    pa_convert_func_init_sse(PA_CPU_X86_SSE);
+    sse_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
+
+    pa_log_debug("Checking SSE sconv (float -> s16)");
+    run_conv_test_float_to_s16(sse_func, orig_func, 0, true, false);
+    run_conv_test_float_to_s16(sse_func, orig_func, 1, true, false);
+    run_conv_test_float_to_s16(sse_func, orig_func, 2, true, false);
+    run_conv_test_float_to_s16(sse_func, orig_func, 3, true, false);
+    run_conv_test_float_to_s16(sse_func, orig_func, 4, true, false);
+    run_conv_test_float_to_s16(sse_func, orig_func, 5, true, false);
+    run_conv_test_float_to_s16(sse_func, orig_func, 6, true, false);
+    run_conv_test_float_to_s16(sse_func, orig_func, 7, true, true);
+}
+END_TEST
+#endif /* defined (__i386__) || defined (__amd64__) */
+
+#if defined (__arm__) && defined (__linux__)
+#ifdef HAVE_NEON
+START_TEST (sconv_neon_test) {
+    pa_cpu_arm_flag_t flags = 0;
+    pa_convert_func_t orig_from_func, neon_from_func;
+    pa_convert_func_t orig_to_func, neon_to_func;
+
+    pa_cpu_get_arm_flags(&flags);
+
+    if (!(flags & PA_CPU_ARM_NEON)) {
+        pa_log_info("NEON not supported. Skipping");
+        return;
+    }
+
+    orig_from_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
+    orig_to_func = pa_get_convert_to_float32ne_function(PA_SAMPLE_S16LE);
+    pa_convert_func_init_neon(flags);
+    neon_from_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
+    neon_to_func = pa_get_convert_to_float32ne_function(PA_SAMPLE_S16LE);
+
+    pa_log_debug("Checking NEON sconv (float -> s16)");
+    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 0, true, false);
+    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 1, true, false);
+    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 2, true, false);
+    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 3, true, false);
+    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 4, true, false);
+    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 5, true, false);
+    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 6, true, false);
+    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 7, true, true);
+
+    pa_log_debug("Checking NEON sconv (s16 -> float)");
+    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 0, true, false);
+    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 1, true, false);
+    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 2, true, false);
+    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 3, true, false);
+    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 4, true, false);
+    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 5, true, false);
+    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 6, true, false);
+    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 7, true, true);
+}
+END_TEST
+#endif /* HAVE_NEON */
+#endif /* defined (__arm__) && defined (__linux__) */
+
+int main(int argc, char *argv[]) {
+    int failed = 0;
+    Suite *s;
+    TCase *tc;
+    SRunner *sr;
+
+    if (!getenv("MAKE_CHECK"))
+        pa_log_set_level(PA_LOG_DEBUG);
+
+    s = suite_create("CPU");
+
+    tc = tcase_create("sconv");
+#if defined (__i386__) || defined (__amd64__)
+    tcase_add_test(tc, sconv_sse2_test);
+    tcase_add_test(tc, sconv_sse_test);
+#endif
+#if defined (__arm__) && defined (__linux__)
+#if HAVE_NEON
+    tcase_add_test(tc, sconv_neon_test);
+#endif
+#endif
+    tcase_set_timeout(tc, 120);
+    suite_add_tcase(s, tc);
+
+    sr = srunner_create(s);
+    srunner_run_all(sr, CK_NORMAL);
+    failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+
+    return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
deleted file mode 100644
index 96137c7..0000000
--- a/src/tests/cpu-test.c
+++ /dev/null
@@ -1,877 +0,0 @@
-/***
-  This file is part of PulseAudio.
-
-  PulseAudio is free software; you can redistribute it and/or modify
-  it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2.1 of the License,
-  or (at your option) any later version.
-
-  PulseAudio is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with PulseAudio; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-  USA.
-***/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <check.h>
-#include <unistd.h>
-#include <math.h>
-
-#include <pulse/rtclock.h>
-#include <pulsecore/cpu-x86.h>
-#include <pulsecore/cpu-orc.h>
-#include <pulsecore/random.h>
-#include <pulsecore/macro.h>
-#include <pulsecore/endianmacros.h>
-#include <pulsecore/sconv.h>
-#include <pulsecore/remap.h>
-#include <pulsecore/sample-util.h>
-#include <pulsecore/mix.h>
-
-#include "runtime-test-util.h"
-
-/* Common defines for svolume tests */
-#define SAMPLES 1028
-#define TIMES 1000
-#define TIMES2 100
-#define PADDING 16
-
-static void run_volume_test(
-        pa_do_volume_func_t func,
-        pa_do_volume_func_t orig_func,
-        int align,
-        int channels,
-        bool correct,
-        bool perf) {
-
-    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, s_orig[SAMPLES]) = { 0 };
-    int32_t volumes[channels + PADDING];
-    int16_t *samples, *samples_ref, *samples_orig;
-    int i, padding, nsamples, size;
-
-    /* Force sample alignment as requested */
-    samples = s + (8 - align);
-    samples_ref = s_ref + (8 - align);
-    samples_orig = s_orig + (8 - align);
-    nsamples = SAMPLES - (8 - align);
-    if (nsamples % channels)
-        nsamples -= nsamples % channels;
-    size = nsamples * sizeof(int16_t);
-
-    pa_random(samples, size);
-    memcpy(samples_ref, samples, size);
-    memcpy(samples_orig, samples, size);
-
-    for (i = 0; i < channels; i++)
-        volumes[i] = PA_CLAMP_VOLUME((pa_volume_t)(rand() >> 15));
-    for (padding = 0; padding < PADDING; padding++, i++)
-        volumes[i] = volumes[padding];
-
-    if (correct) {
-        orig_func(samples_ref, volumes, channels, size);
-        func(samples, volumes, channels, size);
-
-        for (i = 0; i < nsamples; i++) {
-            if (samples[i] != samples_ref[i]) {
-                pa_log_debug("Correctness test failed: align=%d, channels=%d", align, channels);
-                pa_log_debug("%d: %04hx != %04hx (%04hx * %08x)\n", i, samples[i], samples_ref[i],
-                        samples_orig[i], volumes[i % channels]);
-                fail();
-            }
-        }
-    }
-
-    if (perf) {
-        pa_log_debug("Testing svolume %dch performance with %d sample alignment", channels, align);
-
-        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            memcpy(samples, samples_orig, size);
-            func(samples, volumes, channels, size);
-        } PA_RUNTIME_TEST_RUN_STOP
-
-        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            memcpy(samples_ref, samples_orig, size);
-            orig_func(samples_ref, volumes, channels, size);
-        } PA_RUNTIME_TEST_RUN_STOP
-
-        fail_unless(memcmp(samples_ref, samples, size) == 0);
-    }
-}
-
-#if defined (__i386__) || defined (__amd64__)
-START_TEST (svolume_mmx_test) {
-    pa_do_volume_func_t orig_func, mmx_func;
-    pa_cpu_x86_flag_t flags = 0;
-    int i, j;
-
-    pa_cpu_get_x86_flags(&flags);
-
-    if (!((flags & PA_CPU_X86_MMX) && (flags & PA_CPU_X86_CMOV))) {
-        pa_log_info("MMX/CMOV not supported. Skipping");
-        return;
-    }
-
-    orig_func = pa_get_volume_func(PA_SAMPLE_S16NE);
-    pa_volume_func_init_mmx(flags);
-    mmx_func = pa_get_volume_func(PA_SAMPLE_S16NE);
-
-    pa_log_debug("Checking MMX svolume");
-    for (i = 1; i <= 3; i++) {
-        for (j = 0; j < 7; j++)
-            run_volume_test(mmx_func, orig_func, j, i, true, false);
-    }
-    run_volume_test(mmx_func, orig_func, 7, 1, true, true);
-    run_volume_test(mmx_func, orig_func, 7, 2, true, true);
-    run_volume_test(mmx_func, orig_func, 7, 3, true, true);
-}
-END_TEST
-
-START_TEST (svolume_sse_test) {
-    pa_do_volume_func_t orig_func, sse_func;
-    pa_cpu_x86_flag_t flags = 0;
-    int i, j;
-
-    pa_cpu_get_x86_flags(&flags);
-
-    if (!(flags & PA_CPU_X86_SSE2)) {
-        pa_log_info("SSE2 not supported. Skipping");
-        return;
-    }
-
-    orig_func = pa_get_volume_func(PA_SAMPLE_S16NE);
-    pa_volume_func_init_sse(flags);
-    sse_func = pa_get_volume_func(PA_SAMPLE_S16NE);
-
-    pa_log_debug("Checking SSE2 svolume");
-    for (i = 1; i <= 3; i++) {
-        for (j = 0; j < 7; j++)
-            run_volume_test(sse_func, orig_func, j, i, true, false);
-    }
-    run_volume_test(sse_func, orig_func, 7, 1, true, true);
-    run_volume_test(sse_func, orig_func, 7, 2, true, true);
-    run_volume_test(sse_func, orig_func, 7, 3, true, true);
-}
-END_TEST
-#endif /* defined (__i386__) || defined (__amd64__) */
-
-#if defined (__arm__) && defined (__linux__)
-START_TEST (svolume_arm_test) {
-    pa_do_volume_func_t orig_func, arm_func;
-    pa_cpu_arm_flag_t flags = 0;
-    int i, j;
-
-    pa_cpu_get_arm_flags(&flags);
-
-    if (!(flags & PA_CPU_ARM_V6)) {
-        pa_log_info("ARMv6 instructions not supported. Skipping");
-        return;
-    }
-
-    orig_func = pa_get_volume_func(PA_SAMPLE_S16NE);
-    pa_volume_func_init_arm(flags);
-    arm_func = pa_get_volume_func(PA_SAMPLE_S16NE);
-
-    pa_log_debug("Checking ARM svolume");
-    for (i = 1; i <= 3; i++) {
-        for (j = 0; j < 7; j++)
-            run_volume_test(arm_func, orig_func, j, i, true, false);
-    }
-    run_volume_test(arm_func, orig_func, 7, 1, true, true);
-    run_volume_test(arm_func, orig_func, 7, 2, true, true);
-    run_volume_test(arm_func, orig_func, 7, 3, true, true);
-}
-END_TEST
-#endif /* defined (__arm__) && defined (__linux__) */
-
-START_TEST (svolume_orc_test) {
-    pa_do_volume_func_t orig_func, orc_func;
-    pa_cpu_info cpu_info;
-    int i, j;
-
-#if defined (__i386__) || defined (__amd64__)
-    pa_zero(cpu_info);
-    cpu_info.cpu_type = PA_CPU_X86;
-    pa_cpu_get_x86_flags(&cpu_info.flags.x86);
-#endif
-
-    orig_func = pa_get_volume_func(PA_SAMPLE_S16NE);
-
-    if (!pa_cpu_init_orc(cpu_info)) {
-        pa_log_info("Orc not supported. Skipping");
-        return;
-    }
-
-    orc_func = pa_get_volume_func(PA_SAMPLE_S16NE);
-
-    pa_log_debug("Checking Orc svolume");
-    for (i = 1; i <= 2; i++) {
-        for (j = 0; j < 7; j++)
-            run_volume_test(orc_func, orig_func, j, i, true, false);
-    }
-    run_volume_test(orc_func, orig_func, 7, 1, true, true);
-    run_volume_test(orc_func, orig_func, 7, 2, true, true);
-}
-END_TEST
-
-#undef SAMPLES
-#undef TIMES
-#undef TIMES2
-#undef PADDING
-/* End svolume tests */
-
-/* Start conversion tests */
-#define SAMPLES 1028
-#define TIMES 1000
-#define TIMES2 100
-
-static void run_conv_test_float_to_s16(
-        pa_convert_func_t func,
-        pa_convert_func_t orig_func,
-        int align,
-        bool correct,
-        bool perf) {
-
-    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES]) = { 0 };
-    PA_DECLARE_ALIGNED(8, float, f[SAMPLES]);
-    int16_t *samples, *samples_ref;
-    float *floats;
-    int i, nsamples;
-
-    /* Force sample alignment as requested */
-    samples = s + (8 - align);
-    samples_ref = s_ref + (8 - align);
-    floats = f + (8 - align);
-    nsamples = SAMPLES - (8 - align);
-
-    for (i = 0; i < nsamples; i++) {
-        floats[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
-    }
-
-    if (correct) {
-        orig_func(nsamples, floats, samples_ref);
-        func(nsamples, floats, samples);
-
-        for (i = 0; i < nsamples; i++) {
-            if (abs(samples[i] - samples_ref[i]) > 1) {
-                pa_log_debug("Correctness test failed: align=%d", align);
-                pa_log_debug("%d: %04hx != %04hx (%.24f)\n", i, samples[i], samples_ref[i], floats[i]);
-                fail();
-            }
-        }
-    }
-
-    if (perf) {
-        pa_log_debug("Testing sconv performance with %d sample alignment", align);
-
-        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            func(nsamples, floats, samples);
-        } PA_RUNTIME_TEST_RUN_STOP
-
-        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            orig_func(nsamples, floats, samples_ref);
-        } PA_RUNTIME_TEST_RUN_STOP
-    }
-}
-
-/* This test is currently only run under NEON */
-#if defined (__arm__) && defined (__linux__)
-#ifdef HAVE_NEON
-static void run_conv_test_s16_to_float(
-        pa_convert_func_t func,
-        pa_convert_func_t orig_func,
-        int align,
-        bool correct,
-        bool perf) {
-
-    PA_DECLARE_ALIGNED(8, float, f[SAMPLES]) = { 0 };
-    PA_DECLARE_ALIGNED(8, float, f_ref[SAMPLES]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]);
-    float *floats, *floats_ref;
-    int16_t *samples;
-    int i, nsamples;
-
-    /* Force sample alignment as requested */
-    floats = f + (8 - align);
-    floats_ref = f_ref + (8 - align);
-    samples = s + (8 - align);
-    nsamples = SAMPLES - (8 - align);
-
-    pa_random(samples, nsamples * sizeof(int16_t));
-
-    if (correct) {
-        orig_func(nsamples, samples, floats_ref);
-        func(nsamples, samples, floats);
-
-        for (i = 0; i < nsamples; i++) {
-            if (fabsf(floats[i] - floats_ref[i]) > 0.0001) {
-                pa_log_debug("Correctness test failed: align=%d", align);
-                pa_log_debug("%d: %.24f != %.24f (%d)\n", i, floats[i], floats_ref[i], samples[i]);
-                fail();
-            }
-        }
-    }
-
-    if (perf) {
-        pa_log_debug("Testing sconv performance with %d sample alignment", align);
-
-        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            func(nsamples, samples, floats);
-        } PA_RUNTIME_TEST_RUN_STOP
-
-        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            orig_func(nsamples, samples, floats_ref);
-        } PA_RUNTIME_TEST_RUN_STOP
-    }
-}
-#endif /* HAVE_NEON */
-#endif /* defined (__arm__) && defined (__linux__) */
-
-#if defined (__i386__) || defined (__amd64__)
-START_TEST (sconv_sse2_test) {
-    pa_cpu_x86_flag_t flags = 0;
-    pa_convert_func_t orig_func, sse2_func;
-
-    pa_cpu_get_x86_flags(&flags);
-
-    if (!(flags & PA_CPU_X86_SSE2)) {
-        pa_log_info("SSE2 not supported. Skipping");
-        return;
-    }
-
-    orig_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
-    pa_convert_func_init_sse(PA_CPU_X86_SSE2);
-    sse2_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
-
-    pa_log_debug("Checking SSE2 sconv (float -> s16)");
-    run_conv_test_float_to_s16(sse2_func, orig_func, 0, true, false);
-    run_conv_test_float_to_s16(sse2_func, orig_func, 1, true, false);
-    run_conv_test_float_to_s16(sse2_func, orig_func, 2, true, false);
-    run_conv_test_float_to_s16(sse2_func, orig_func, 3, true, false);
-    run_conv_test_float_to_s16(sse2_func, orig_func, 4, true, false);
-    run_conv_test_float_to_s16(sse2_func, orig_func, 5, true, false);
-    run_conv_test_float_to_s16(sse2_func, orig_func, 6, true, false);
-    run_conv_test_float_to_s16(sse2_func, orig_func, 7, true, true);
-}
-END_TEST
-
-START_TEST (sconv_sse_test) {
-    pa_cpu_x86_flag_t flags = 0;
-    pa_convert_func_t orig_func, sse_func;
-
-    pa_cpu_get_x86_flags(&flags);
-
-    if (!(flags & PA_CPU_X86_SSE)) {
-        pa_log_info("SSE not supported. Skipping");
-        return;
-    }
-
-    orig_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
-    pa_convert_func_init_sse(PA_CPU_X86_SSE);
-    sse_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
-
-    pa_log_debug("Checking SSE sconv (float -> s16)");
-    run_conv_test_float_to_s16(sse_func, orig_func, 0, true, false);
-    run_conv_test_float_to_s16(sse_func, orig_func, 1, true, false);
-    run_conv_test_float_to_s16(sse_func, orig_func, 2, true, false);
-    run_conv_test_float_to_s16(sse_func, orig_func, 3, true, false);
-    run_conv_test_float_to_s16(sse_func, orig_func, 4, true, false);
-    run_conv_test_float_to_s16(sse_func, orig_func, 5, true, false);
-    run_conv_test_float_to_s16(sse_func, orig_func, 6, true, false);
-    run_conv_test_float_to_s16(sse_func, orig_func, 7, true, true);
-}
-END_TEST
-#endif /* defined (__i386__) || defined (__amd64__) */
-
-#if defined (__arm__) && defined (__linux__)
-#ifdef HAVE_NEON
-START_TEST (sconv_neon_test) {
-    pa_cpu_arm_flag_t flags = 0;
-    pa_convert_func_t orig_from_func, neon_from_func;
-    pa_convert_func_t orig_to_func, neon_to_func;
-
-    pa_cpu_get_arm_flags(&flags);
-
-    if (!(flags & PA_CPU_ARM_NEON)) {
-        pa_log_info("NEON not supported. Skipping");
-        return;
-    }
-
-    orig_from_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
-    orig_to_func = pa_get_convert_to_float32ne_function(PA_SAMPLE_S16LE);
-    pa_convert_func_init_neon(flags);
-    neon_from_func = pa_get_convert_from_float32ne_function(PA_SAMPLE_S16LE);
-    neon_to_func = pa_get_convert_to_float32ne_function(PA_SAMPLE_S16LE);
-
-    pa_log_debug("Checking NEON sconv (float -> s16)");
-    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 0, true, false);
-    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 1, true, false);
-    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 2, true, false);
-    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 3, true, false);
-    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 4, true, false);
-    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 5, true, false);
-    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 6, true, false);
-    run_conv_test_float_to_s16(neon_from_func, orig_from_func, 7, true, true);
-
-    pa_log_debug("Checking NEON sconv (s16 -> float)");
-    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 0, true, false);
-    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 1, true, false);
-    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 2, true, false);
-    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 3, true, false);
-    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 4, true, false);
-    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 5, true, false);
-    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 6, true, false);
-    run_conv_test_s16_to_float(neon_to_func, orig_to_func, 7, true, true);
-}
-END_TEST
-#endif /* HAVE_NEON */
-#endif /* defined (__arm__) && defined (__linux__) */
-
-#undef SAMPLES
-#undef TIMES
-/* End conversion tests */
-
-/* Start remap tests */
-#define SAMPLES 1028
-#define TIMES 1000
-#define TIMES2 100
-
-static void run_remap_test_mono_stereo_float(
-        pa_remap_t *remap,
-        pa_do_remap_func_t func,
-        pa_do_remap_func_t orig_func,
-        int align,
-        bool correct,
-        bool perf) {
-
-    PA_DECLARE_ALIGNED(8, float, s_ref[SAMPLES*2]) = { 0 };
-    PA_DECLARE_ALIGNED(8, float, s[SAMPLES*2]) = { 0 };
-    PA_DECLARE_ALIGNED(8, float, m[SAMPLES]);
-    float *stereo, *stereo_ref;
-    float *mono;
-    int i, nsamples;
-
-    /* Force sample alignment as requested */
-    stereo = s + (8 - align);
-    stereo_ref = s_ref + (8 - align);
-    mono = m + (8 - align);
-    nsamples = SAMPLES - (8 - align);
-
-    for (i = 0; i < nsamples; i++)
-        mono[i] = 2.1f * (rand()/(float) RAND_MAX - 0.5f);
-
-    if (correct) {
-        orig_func(remap, stereo_ref, mono, nsamples);
-        func(remap, stereo, mono, nsamples);
-
-        for (i = 0; i < nsamples * 2; i++) {
-            if (fabsf(stereo[i] - stereo_ref[i]) > 0.0001) {
-                pa_log_debug("Correctness test failed: align=%d", align);
-                pa_log_debug("%d: %.24f != %.24f (%.24f)\n", i, stereo[i], stereo_ref[i], mono[i]);
-                fail();
-            }
-        }
-    }
-
-    if (perf) {
-        pa_log_debug("Testing remap performance with %d sample alignment", align);
-
-        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            func(remap, stereo, mono, nsamples);
-        } PA_RUNTIME_TEST_RUN_STOP
-
-        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            orig_func(remap, stereo_ref, mono, nsamples);
-        } PA_RUNTIME_TEST_RUN_STOP
-    }
-}
-
-static void run_remap_test_mono_stereo_s16(
-        pa_remap_t *remap,
-        pa_do_remap_func_t func,
-        pa_do_remap_func_t orig_func,
-        int align,
-        bool correct,
-        bool perf) {
-
-    PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES*2]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES*2]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, m[SAMPLES]);
-    int16_t *stereo, *stereo_ref;
-    int16_t *mono;
-    int i, nsamples;
-
-    /* Force sample alignment as requested */
-    stereo = s + (8 - align);
-    stereo_ref = s_ref + (8 - align);
-    mono = m + (8 - align);
-    nsamples = SAMPLES - (8 - align);
-
-    pa_random(mono, nsamples * sizeof(int16_t));
-
-    if (correct) {
-        orig_func(remap, stereo_ref, mono, nsamples);
-        func(remap, stereo, mono, nsamples);
-
-        for (i = 0; i < nsamples * 2; i++) {
-            if (abs(stereo[i] - stereo_ref[i]) > 1) {
-                pa_log_debug("Correctness test failed: align=%d", align);
-                pa_log_debug("%d: %d != %d (%d)\n", i, stereo[i], stereo_ref[i], mono[i]);
-                fail();
-            }
-        }
-    }
-
-    if (perf) {
-        pa_log_debug("Testing remap performance with %d sample alignment", align);
-
-        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            func(remap, stereo, mono, nsamples);
-        } PA_RUNTIME_TEST_RUN_STOP
-
-        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            orig_func(remap, stereo_ref, mono, nsamples);
-        } PA_RUNTIME_TEST_RUN_STOP
-    }
-}
-
-static void remap_test_mono_stereo_float(
-        pa_init_remap_func_t init_func,
-        pa_init_remap_func_t orig_init_func) {
-
-    pa_remap_t remap;
-    pa_do_remap_func_t orig_func, func;
-
-    remap.format = PA_SAMPLE_FLOAT32NE;
-    remap.i_ss.channels = 1;
-    remap.o_ss.channels = 2;
-    remap.map_table_f[0][0] = 1.0;
-    remap.map_table_f[1][0] = 1.0;
-    remap.map_table_i[0][0] = 0x10000;
-    remap.map_table_i[1][0] = 0x10000;
-    orig_init_func(&remap);
-    orig_func = remap.do_remap;
-    if (!orig_func) {
-        pa_log_warn("No reference remapping function, abort test");
-        return;
-    }
-
-    init_func(&remap);
-    func = remap.do_remap;
-    if (!func || func == orig_func) {
-        pa_log_warn("No remapping function, abort test");
-        return;
-    }
-
-    run_remap_test_mono_stereo_float(&remap, func, orig_func, 0, true, false);
-    run_remap_test_mono_stereo_float(&remap, func, orig_func, 1, true, false);
-    run_remap_test_mono_stereo_float(&remap, func, orig_func, 2, true, false);
-    run_remap_test_mono_stereo_float(&remap, func, orig_func, 3, true, true);
-}
-
-static void remap_test_mono_stereo_s16(
-        pa_init_remap_func_t init_func,
-        pa_init_remap_func_t orig_init_func) {
-
-    pa_remap_t remap;
-    pa_do_remap_func_t orig_func, func;
-
-    remap.format = PA_SAMPLE_S16NE;
-    remap.i_ss.channels = 1;
-    remap.o_ss.channels = 2;
-    remap.map_table_f[0][0] = 1.0;
-    remap.map_table_f[1][0] = 1.0;
-    remap.map_table_i[0][0] = 0x10000;
-    remap.map_table_i[1][0] = 0x10000;
-    orig_init_func(&remap);
-    orig_func = remap.do_remap;
-    if (!orig_func) {
-        pa_log_warn("No reference remapping function, abort test");
-        return;
-    }
-
-    init_func(&remap);
-    func = remap.do_remap;
-    if (!func || func == orig_func) {
-        pa_log_warn("No remapping function, abort test");
-        return;
-    }
-
-    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 0, true, false);
-    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 1, true, false);
-    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 2, true, false);
-    run_remap_test_mono_stereo_s16(&remap, func, orig_func, 3, true, true);
-}
-
-#if defined (__i386__) || defined (__amd64__)
-START_TEST (remap_mmx_test) {
-    pa_cpu_x86_flag_t flags = 0;
-    pa_init_remap_func_t init_func, orig_init_func;
-
-    pa_cpu_get_x86_flags(&flags);
-    if (!(flags & PA_CPU_X86_MMX)) {
-        pa_log_info("MMX not supported. Skipping");
-        return;
-    }
-
-    pa_log_debug("Checking MMX remap (float, mono->stereo)");
-    orig_init_func = pa_get_init_remap_func();
-    pa_remap_func_init_mmx(flags);
-    init_func = pa_get_init_remap_func();
-    remap_test_mono_stereo_float(init_func, orig_init_func);
-
-    pa_log_debug("Checking MMX remap (s16, mono->stereo)");
-    remap_test_mono_stereo_s16(init_func, orig_init_func);
-}
-END_TEST
-
-START_TEST (remap_sse2_test) {
-    pa_cpu_x86_flag_t flags = 0;
-    pa_init_remap_func_t init_func, orig_init_func;
-
-    pa_cpu_get_x86_flags(&flags);
-    if (!(flags & PA_CPU_X86_SSE2)) {
-        pa_log_info("SSE2 not supported. Skipping");
-        return;
-    }
-
-    pa_log_debug("Checking SSE2 remap (float, mono->stereo)");
-    orig_init_func = pa_get_init_remap_func();
-    pa_remap_func_init_sse(flags);
-    init_func = pa_get_init_remap_func();
-    remap_test_mono_stereo_float(init_func, orig_init_func);
-
-    pa_log_debug("Checking SSE2 remap (s16, mono->stereo)");
-    remap_test_mono_stereo_s16(init_func, orig_init_func);
-}
-END_TEST
-#endif /* defined (__i386__) || defined (__amd64__) */
-
-#undef SAMPLES
-#undef TIMES
-#undef TIMES2
-/* End remap tests */
-
-/* Start mix tests */
-
-/* Only ARM NEON has mix tests, so disable the related functions for other
- * architectures for now to avoid compiler warnings about unused functions. */
-#if defined (__arm__) && defined (__linux__)
-#ifdef HAVE_NEON
-
-#define SAMPLES 1028
-#define TIMES 1000
-#define TIMES2 100
-
-static void acquire_mix_streams(pa_mix_info streams[], unsigned nstreams) {
-    unsigned i;
-
-    for (i = 0; i < nstreams; i++)
-        streams[i].ptr = pa_memblock_acquire_chunk(&streams[i].chunk);
-}
-
-static void release_mix_streams(pa_mix_info streams[], unsigned nstreams) {
-    unsigned i;
-
-    for (i = 0; i < nstreams; i++)
-        pa_memblock_release(streams[i].chunk.memblock);
-}
-
-static void run_mix_test(
-        pa_do_mix_func_t func,
-        pa_do_mix_func_t orig_func,
-        int align,
-        int channels,
-        bool correct,
-        bool perf) {
-
-    PA_DECLARE_ALIGNED(8, int16_t, in0[SAMPLES * 4]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, in1[SAMPLES * 4]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, out[SAMPLES * 4]) = { 0 };
-    PA_DECLARE_ALIGNED(8, int16_t, out_ref[SAMPLES * 4]) = { 0 };
-    int16_t *samples0, *samples1;
-    int16_t *samples, *samples_ref;
-    int nsamples;
-    pa_mempool *pool;
-    pa_memchunk c0, c1;
-    pa_mix_info m[2];
-    int i;
-
-    pa_assert(channels == 1 || channels == 2 || channels == 4);
-
-    /* Force sample alignment as requested */
-    samples0 = in0 + (8 - align);
-    samples1 = in1 + (8 - align);
-    samples = out + (8 - align);
-    samples_ref = out_ref + (8 - align);
-    nsamples = channels * (SAMPLES - (8 - align));
-
-    fail_unless((pool = pa_mempool_new(false, 0)) != NULL, NULL);
-
-    pa_random(samples0, nsamples * sizeof(int16_t));
-    c0.memblock = pa_memblock_new_fixed(pool, samples0, nsamples * sizeof(int16_t), false);
-    c0.length = pa_memblock_get_length(c0.memblock);
-    c0.index = 0;
-
-    pa_random(samples1, nsamples * sizeof(int16_t));
-    c1.memblock = pa_memblock_new_fixed(pool, samples1, nsamples * sizeof(int16_t), false);
-    c1.length = pa_memblock_get_length(c1.memblock);
-    c1.index = 0;
-
-    m[0].chunk = c0;
-    m[0].volume.channels = channels;
-    for (i = 0; i < channels; i++) {
-        m[0].volume.values[i] = PA_VOLUME_NORM;
-        m[0].linear[i].i = 0x5555;
-    }
-
-    m[1].chunk = c1;
-    m[1].volume.channels = channels;
-    for (i = 0; i < channels; i++) {
-        m[1].volume.values[i] = PA_VOLUME_NORM;
-        m[1].linear[i].i = 0x6789;
-    }
-
-    if (correct) {
-        acquire_mix_streams(m, 2);
-        orig_func(m, 2, channels, samples_ref, nsamples * sizeof(int16_t));
-        release_mix_streams(m, 2);
-
-        acquire_mix_streams(m, 2);
-        func(m, 2, channels, samples, nsamples * sizeof(int16_t));
-        release_mix_streams(m, 2);
-
-        for (i = 0; i < nsamples; i++) {
-            if (samples[i] != samples_ref[i]) {
-                pa_log_debug("Correctness test failed: align=%d, channels=%d", align, channels);
-                pa_log_debug("%d: %hd != %04hd (%hd + %hd)\n",
-                    i,
-                    samples[i], samples_ref[i],
-                    samples0[i], samples1[i]);
-                fail();
-            }
-        }
-    }
-
-    if (perf) {
-        pa_log_debug("Testing %d-channel mixing performance with %d sample alignment", channels, align);
-
-        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
-            acquire_mix_streams(m, 2);
-            func(m, 2, channels, samples, nsamples * sizeof(int16_t));
-            release_mix_streams(m, 2);
-        } PA_RUNTIME_TEST_RUN_STOP
-
-        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
-            acquire_mix_streams(m, 2);
-            orig_func(m, 2, channels, samples_ref, nsamples * sizeof(int16_t));
-            release_mix_streams(m, 2);
-        } PA_RUNTIME_TEST_RUN_STOP
-    }
-
-    pa_memblock_unref(c0.memblock);
-    pa_memblock_unref(c1.memblock);
-
-    pa_mempool_free(pool);
-}
-#endif /* HAVE_NEON */
-#endif /* defined (__arm__) && defined (__linux__) */
-
-#if defined (__arm__) && defined (__linux__)
-#ifdef HAVE_NEON
-START_TEST (mix_neon_test) {
-    pa_do_mix_func_t orig_func, neon_func;
-    pa_cpu_arm_flag_t flags = 0;
-
-    pa_cpu_get_arm_flags(&flags);
-
-    if (!(flags & PA_CPU_ARM_NEON)) {
-        pa_log_info("NEON not supported. Skipping");
-        return;
-    }
-
-    orig_func = pa_get_mix_func(PA_SAMPLE_S16NE);
-    pa_mix_func_init_neon(flags);
-    neon_func = pa_get_mix_func(PA_SAMPLE_S16NE);
-
-    pa_log_debug("Checking NEON mix");
-    run_mix_test(neon_func, orig_func, 7, 2, true, true);
-}
-END_TEST
-#endif /* HAVE_NEON */
-#endif /* defined (__arm__) && defined (__linux__) */
-/* End mix tests */
-
-int main(int argc, char *argv[]) {
-    int failed = 0;
-    Suite *s;
-    TCase *tc;
-    SRunner *sr;
-
-    if (!getenv("MAKE_CHECK"))
-        pa_log_set_level(PA_LOG_DEBUG);
-
-    s = suite_create("CPU");
-
-    /* Volume tests */
-    tc = tcase_create("svolume");
-#if defined (__i386__) || defined (__amd64__)
-    tcase_add_test(tc, svolume_mmx_test);
-    tcase_add_test(tc, svolume_sse_test);
-#endif
-#if defined (__arm__) && defined (__linux__)
-    tcase_add_test(tc, svolume_arm_test);
-#endif
-    tcase_add_test(tc, svolume_orc_test);
-    tcase_set_timeout(tc, 120);
-    suite_add_tcase(s, tc);
-
-    /* Conversion tests */
-    tc = tcase_create("sconv");
-#if defined (__i386__) || defined (__amd64__)
-    tcase_add_test(tc, sconv_sse2_test);
-    tcase_add_test(tc, sconv_sse_test);
-#endif
-#if defined (__arm__) && defined (__linux__)
-#if HAVE_NEON
-    tcase_add_test(tc, sconv_neon_test);
-#endif
-#endif
-    tcase_set_timeout(tc, 120);
-    suite_add_tcase(s, tc);
-
-    /* Remap tests */
-    tc = tcase_create("remap");
-#if defined (__i386__) || defined (__amd64__)
-    tcase_add_test(tc, remap_mmx_test);
-    tcase_add_test(tc, remap_sse2_test);
-#endif
-    tcase_set_timeout(tc, 120);
-    suite_add_tcase(s, tc);
-    /* Mix tests */
-    tc = tcase_create("mix");
-#if defined (__arm__) && defined (__linux__)
-#if HAVE_NEON
-    tcase_add_test(tc, mix_neon_test);
-#endif
-#endif
-    tcase_set_timeout(tc, 120);
-    suite_add_tcase(s, tc);
-
-    sr = srunner_create(s);
-    srunner_run_all(sr, CK_NORMAL);
-    failed = srunner_ntests_failed(sr);
-    srunner_free(sr);
-
-    return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
diff --git a/src/tests/cpu-volume-test.c b/src/tests/cpu-volume-test.c
new file mode 100644
index 0000000..659136e
--- /dev/null
+++ b/src/tests/cpu-volume-test.c
@@ -0,0 +1,249 @@
+/***
+  This file is part of PulseAudio.
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <check.h>
+
+#include <pulsecore/cpu-arm.h>
+#include <pulsecore/cpu-x86.h>
+#include <pulsecore/cpu-orc.h>
+#include <pulsecore/random.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/sample-util.h>
+
+#include "runtime-test-util.h"
+
+/* Common defines for svolume tests */
+#define SAMPLES 1028
+#define TIMES 1000
+#define TIMES2 100
+#define PADDING 16
+
+static void run_volume_test(
+        pa_do_volume_func_t func,
+        pa_do_volume_func_t orig_func,
+        int align,
+        int channels,
+        bool correct,
+        bool perf) {
+
+    PA_DECLARE_ALIGNED(8, int16_t, s[SAMPLES]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, s_ref[SAMPLES]) = { 0 };
+    PA_DECLARE_ALIGNED(8, int16_t, s_orig[SAMPLES]) = { 0 };
+    int32_t volumes[channels + PADDING];
+    int16_t *samples, *samples_ref, *samples_orig;
+    int i, padding, nsamples, size;
+
+    /* Force sample alignment as requested */
+    samples = s + (8 - align);
+    samples_ref = s_ref + (8 - align);
+    samples_orig = s_orig + (8 - align);
+    nsamples = SAMPLES - (8 - align);
+    if (nsamples % channels)
+        nsamples -= nsamples % channels;
+    size = nsamples * sizeof(int16_t);
+
+    pa_random(samples, size);
+    memcpy(samples_ref, samples, size);
+    memcpy(samples_orig, samples, size);
+
+    for (i = 0; i < channels; i++)
+        volumes[i] = PA_CLAMP_VOLUME((pa_volume_t)(rand() >> 15));
+    for (padding = 0; padding < PADDING; padding++, i++)
+        volumes[i] = volumes[padding];
+
+    if (correct) {
+        orig_func(samples_ref, volumes, channels, size);
+        func(samples, volumes, channels, size);
+
+        for (i = 0; i < nsamples; i++) {
+            if (samples[i] != samples_ref[i]) {
+                pa_log_debug("Correctness test failed: align=%d, channels=%d", align, channels);
+                pa_log_debug("%d: %04hx != %04hx (%04hx * %08x)\n", i, samples[i], samples_ref[i],
+                        samples_orig[i], volumes[i % channels]);
+                fail();
+            }
+        }
+    }
+
+    if (perf) {
+        pa_log_debug("Testing svolume %dch performance with %d sample alignment", channels, align);
+
+        PA_RUNTIME_TEST_RUN_START("func", TIMES, TIMES2) {
+            memcpy(samples, samples_orig, size);
+            func(samples, volumes, channels, size);
+        } PA_RUNTIME_TEST_RUN_STOP
+
+        PA_RUNTIME_TEST_RUN_START("orig", TIMES, TIMES2) {
+            memcpy(samples_ref, samples_orig, size);
+            orig_func(samples_ref, volumes, channels, size);
+        } PA_RUNTIME_TEST_RUN_STOP
+
+        fail_unless(memcmp(samples_ref, samples, size) == 0);
+    }
+}
+
+#if defined (__i386__) || defined (__amd64__)
+START_TEST (svolume_mmx_test) {
+    pa_do_volume_func_t orig_func, mmx_func;
+    pa_cpu_x86_flag_t flags = 0;
+    int i, j;
+
+    pa_cpu_get_x86_flags(&flags);
+
+    if (!((flags & PA_CPU_X86_MMX) && (flags & PA_CPU_X86_CMOV))) {
+        pa_log_info("MMX/CMOV not supported. Skipping");
+        return;
+    }
+
+    orig_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+    pa_volume_func_init_mmx(flags);
+    mmx_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+
+    pa_log_debug("Checking MMX svolume");
+    for (i = 1; i <= 3; i++) {
+        for (j = 0; j < 7; j++)
+            run_volume_test(mmx_func, orig_func, j, i, true, false);
+    }
+    run_volume_test(mmx_func, orig_func, 7, 1, true, true);
+    run_volume_test(mmx_func, orig_func, 7, 2, true, true);
+    run_volume_test(mmx_func, orig_func, 7, 3, true, true);
+}
+END_TEST
+
+START_TEST (svolume_sse_test) {
+    pa_do_volume_func_t orig_func, sse_func;
+    pa_cpu_x86_flag_t flags = 0;
+    int i, j;
+
+    pa_cpu_get_x86_flags(&flags);
+
+    if (!(flags & PA_CPU_X86_SSE2)) {
+        pa_log_info("SSE2 not supported. Skipping");
+        return;
+    }
+
+    orig_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+    pa_volume_func_init_sse(flags);
+    sse_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+
+    pa_log_debug("Checking SSE2 svolume");
+    for (i = 1; i <= 3; i++) {
+        for (j = 0; j < 7; j++)
+            run_volume_test(sse_func, orig_func, j, i, true, false);
+    }
+    run_volume_test(sse_func, orig_func, 7, 1, true, true);
+    run_volume_test(sse_func, orig_func, 7, 2, true, true);
+    run_volume_test(sse_func, orig_func, 7, 3, true, true);
+}
+END_TEST
+#endif /* defined (__i386__) || defined (__amd64__) */
+
+#if defined (__arm__) && defined (__linux__)
+START_TEST (svolume_arm_test) {
+    pa_do_volume_func_t orig_func, arm_func;
+    pa_cpu_arm_flag_t flags = 0;
+    int i, j;
+
+    pa_cpu_get_arm_flags(&flags);
+
+    if (!(flags & PA_CPU_ARM_V6)) {
+        pa_log_info("ARMv6 instructions not supported. Skipping");
+        return;
+    }
+
+    orig_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+    pa_volume_func_init_arm(flags);
+    arm_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+
+    pa_log_debug("Checking ARM svolume");
+    for (i = 1; i <= 3; i++) {
+        for (j = 0; j < 7; j++)
+            run_volume_test(arm_func, orig_func, j, i, true, false);
+    }
+    run_volume_test(arm_func, orig_func, 7, 1, true, true);
+    run_volume_test(arm_func, orig_func, 7, 2, true, true);
+    run_volume_test(arm_func, orig_func, 7, 3, true, true);
+}
+END_TEST
+#endif /* defined (__arm__) && defined (__linux__) */
+
+START_TEST (svolume_orc_test) {
+    pa_do_volume_func_t orig_func, orc_func;
+    pa_cpu_info cpu_info;
+    int i, j;
+
+#if defined (__i386__) || defined (__amd64__)
+    pa_zero(cpu_info);
+    cpu_info.cpu_type = PA_CPU_X86;
+    pa_cpu_get_x86_flags(&cpu_info.flags.x86);
+#endif
+
+    orig_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+
+    if (!pa_cpu_init_orc(cpu_info)) {
+        pa_log_info("Orc not supported. Skipping");
+        return;
+    }
+
+    orc_func = pa_get_volume_func(PA_SAMPLE_S16NE);
+
+    pa_log_debug("Checking Orc svolume");
+    for (i = 1; i <= 2; i++) {
+        for (j = 0; j < 7; j++)
+            run_volume_test(orc_func, orig_func, j, i, true, false);
+    }
+    run_volume_test(orc_func, orig_func, 7, 1, true, true);
+    run_volume_test(orc_func, orig_func, 7, 2, true, true);
+}
+END_TEST
+
+int main(int argc, char *argv[]) {
+    int failed = 0;
+    Suite *s;
+    TCase *tc;
+    SRunner *sr;
+
+    if (!getenv("MAKE_CHECK"))
+        pa_log_set_level(PA_LOG_DEBUG);
+
+    s = suite_create("CPU");
+
+    tc = tcase_create("svolume");
+#if defined (__i386__) || defined (__amd64__)
+    tcase_add_test(tc, svolume_mmx_test);
+    tcase_add_test(tc, svolume_sse_test);
+#endif
+#if defined (__arm__) && defined (__linux__)
+    tcase_add_test(tc, svolume_arm_test);
+#endif
+    tcase_add_test(tc, svolume_orc_test);
+    tcase_set_timeout(tc, 120);
+    suite_add_tcase(s, tc);
+
+    sr = srunner_create(s);
+    srunner_run_all(sr, CK_NORMAL);
+    failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+
+    return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}

commit f4ab8bd8353073dcebb1e4e9fd340b9999cc7e9a
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Fri Apr 18 09:59:32 2014 +0200

    cpu: Add force_generic_code flag to cpu_info struct
    
    The remapper and channel mixing code have (faster) specialized and (slower)
    generic code certain code path. The flag force_generic_code can be set to
    force the generic code path which is useful for testing. Code duplication
    (such as in mix-special-test) can be avoided, cleanup patches follow.
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/pulsecore/cpu.c b/src/pulsecore/cpu.c
index 814abf6..e0c110e 100644
--- a/src/pulsecore/cpu.c
+++ b/src/pulsecore/cpu.c
@@ -23,6 +23,8 @@
 
 void pa_cpu_init(pa_cpu_info *cpu_info) {
     cpu_info->cpu_type = PA_CPU_UNDEFINED;
+    /* don't force generic code, used for testing only */
+    cpu_info->force_generic_code = false;
     if (!getenv("PULSE_NO_SIMD")) {
         if (pa_cpu_init_x86(&cpu_info->flags.x86))
             cpu_info->cpu_type = PA_CPU_X86;
@@ -30,4 +32,7 @@ void pa_cpu_init(pa_cpu_info *cpu_info) {
             cpu_info->cpu_type = PA_CPU_ARM;
         pa_cpu_init_orc(*cpu_info);
     }
+
+    pa_remap_func_init(cpu_info);
+    pa_mix_func_init(cpu_info);
 }
diff --git a/src/pulsecore/cpu.h b/src/pulsecore/cpu.h
index 23262b5..03507de 100644
--- a/src/pulsecore/cpu.h
+++ b/src/pulsecore/cpu.h
@@ -40,8 +40,12 @@ struct pa_cpu_info {
         pa_cpu_x86_flag_t x86;
         pa_cpu_arm_flag_t arm;
     } flags;
+    bool force_generic_code;
 };
 
 void pa_cpu_init(pa_cpu_info *cpu_info);
 
+void pa_remap_func_init(const pa_cpu_info *cpu_info);
+void pa_mix_func_init(const pa_cpu_info *cpu_info);
+
 #endif /* foocpuhfoo */
diff --git a/src/pulsecore/mix.c b/src/pulsecore/mix.c
index 03c71f0..06b22bd 100644
--- a/src/pulsecore/mix.c
+++ b/src/pulsecore/mix.c
@@ -32,6 +32,7 @@
 #include <pulsecore/g711.h>
 #include <pulsecore/endianmacros.h>
 
+#include "cpu.h"
 #include "mix.h"
 
 #define VOLUME_PADDING 32
@@ -606,6 +607,13 @@ static pa_do_mix_func_t do_mix_table[] = {
     [PA_SAMPLE_S24_32RE]  = (pa_do_mix_func_t) pa_mix_s24_32re_c
 };
 
+void pa_mix_func_init(const pa_cpu_info *cpu_info) {
+    if (cpu_info->force_generic_code)
+        do_mix_table[PA_SAMPLE_S16NE] = (pa_do_mix_func_t) pa_mix_generic_s16ne;
+    else
+        do_mix_table[PA_SAMPLE_S16NE] = (pa_do_mix_func_t) pa_mix_s16ne_c;
+}
+
 size_t pa_mix(
         pa_mix_info streams[],
         unsigned nstreams,
diff --git a/src/pulsecore/remap.c b/src/pulsecore/remap.c
index 09d4837..d9b121e 100644
--- a/src/pulsecore/remap.c
+++ b/src/pulsecore/remap.c
@@ -32,6 +32,7 @@
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
 
+#include "cpu.h"
 #include "remap.h"
 
 static void remap_mono_to_stereo_s16ne_c(pa_remap_t *m, int16_t *dst, const int16_t *src, unsigned n) {
@@ -361,6 +362,8 @@ void pa_set_remap_func(pa_remap_t *m, pa_do_remap_func_t func_s16,
         pa_assert_not_reached();
 }
 
+static bool force_generic_code = false;
+
 /* set the function that will execute the remapping based on the matrices */
 static void init_remap_c(pa_remap_t *m) {
     unsigned n_oc, n_ic;
@@ -370,6 +373,13 @@ static void init_remap_c(pa_remap_t *m) {
     n_ic = m->i_ss.channels;
 
     /* find some common channel remappings, fall back to full matrix operation. */
+    if (force_generic_code) {
+        pa_log_info("Forced to use generic matrix remapping");
+        pa_set_remap_func(m, (pa_do_remap_func_t) remap_channels_matrix_s16ne_c,
+            (pa_do_remap_func_t) remap_channels_matrix_float32ne_c);
+        return;
+    }
+
     if (n_ic == 1 && n_oc == 2 &&
             m->map_table_i[0][0] == 0x10000 && m->map_table_i[1][0] == 0x10000) {
 
@@ -452,3 +462,7 @@ pa_init_remap_func_t pa_get_init_remap_func(void) {
 void pa_set_init_remap_func(pa_init_remap_func_t func) {
     init_remap_func = func;
 }
+
+void pa_remap_func_init(const pa_cpu_info *cpu_info) {
+    force_generic_code = cpu_info->force_generic_code;
+}

commit 61c888dc936ade04b8c57442cc1ed716b4f535bf
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Wed Sep 10 15:53:37 2014 +0200

    cpu: Don't check for both x86 and ARM code
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/pulsecore/cpu.c b/src/pulsecore/cpu.c
index 542e86f..814abf6 100644
--- a/src/pulsecore/cpu.c
+++ b/src/pulsecore/cpu.c
@@ -26,7 +26,7 @@ void pa_cpu_init(pa_cpu_info *cpu_info) {
     if (!getenv("PULSE_NO_SIMD")) {
         if (pa_cpu_init_x86(&cpu_info->flags.x86))
             cpu_info->cpu_type = PA_CPU_X86;
-        if (pa_cpu_init_arm(&cpu_info->flags.arm))
+        else if (pa_cpu_init_arm(&cpu_info->flags.arm))
             cpu_info->cpu_type = PA_CPU_ARM;
         pa_cpu_init_orc(*cpu_info);
     }

commit 380591eb18daaddccc054073438a011df0e8bf20
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Wed Sep 10 15:23:11 2014 +0200

    core: Add pa_cpu_init() / cpu.c
    
    move code dealing with CPU specific code path initialization
    from daemon/main.c to pulsecore/cpu.c
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>

diff --git a/src/Makefile.am b/src/Makefile.am
index 3ceaddc..40d8c04 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -906,7 +906,7 @@ libpulsecore_ at PA_MAJORMINOR@_la_SOURCES = \
 		pulsecore/rtpoll.c pulsecore/rtpoll.h \
 		pulsecore/stream-util.c pulsecore/stream-util.h \
 		pulsecore/mix.c pulsecore/mix.h \
-		pulsecore/cpu.h \
+		pulsecore/cpu.c pulsecore/cpu.h \
 		pulsecore/cpu-arm.c pulsecore/cpu-arm.h \
 		pulsecore/cpu-x86.c pulsecore/cpu-x86.h \
 		pulsecore/cpu-orc.c pulsecore/cpu-orc.h \
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 23fb660..4fd245a 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -86,9 +86,7 @@
 #ifdef HAVE_DBUS
 #include <pulsecore/dbus-shared.h>
 #endif
-#include <pulsecore/cpu-arm.h>
-#include <pulsecore/cpu-x86.h>
-#include <pulsecore/cpu-orc.h>
+#include <pulsecore/cpu.h>
 
 #include "cmdline.h"
 #include "cpulimit.h"
@@ -1022,14 +1020,7 @@ int main(int argc, char *argv[]) {
     c->server_type = conf->local_server_type;
 #endif
 
-    c->cpu_info.cpu_type = PA_CPU_UNDEFINED;
-    if (!getenv("PULSE_NO_SIMD")) {
-        if (pa_cpu_init_x86(&(c->cpu_info.flags.x86)))
-            c->cpu_info.cpu_type = PA_CPU_X86;
-        if (pa_cpu_init_arm(&(c->cpu_info.flags.arm)))
-            c->cpu_info.cpu_type = PA_CPU_ARM;
-        pa_cpu_init_orc(c->cpu_info);
-    }
+    pa_cpu_init(&c->cpu_info);
 
     pa_assert_se(pa_signal_init(pa_mainloop_get_api(mainloop)) == 0);
     pa_signal_new(SIGINT, signal_callback, c);
diff --git a/src/pulsecore/cpu.c b/src/pulsecore/cpu.c
new file mode 100644
index 0000000..542e86f
--- /dev/null
+++ b/src/pulsecore/cpu.c
@@ -0,0 +1,33 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2014 Peter Meerwald <pmeerw at pmeerw.net>
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2.1 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "cpu.h"
+#include "cpu-orc.h"
+
+void pa_cpu_init(pa_cpu_info *cpu_info) {
+    cpu_info->cpu_type = PA_CPU_UNDEFINED;
+    if (!getenv("PULSE_NO_SIMD")) {
+        if (pa_cpu_init_x86(&cpu_info->flags.x86))
+            cpu_info->cpu_type = PA_CPU_X86;
+        if (pa_cpu_init_arm(&cpu_info->flags.arm))
+            cpu_info->cpu_type = PA_CPU_ARM;
+        pa_cpu_init_orc(*cpu_info);
+    }
+}
diff --git a/src/pulsecore/cpu.h b/src/pulsecore/cpu.h
index 7fe6f0b..23262b5 100644
--- a/src/pulsecore/cpu.h
+++ b/src/pulsecore/cpu.h
@@ -42,4 +42,6 @@ struct pa_cpu_info {
     } flags;
 };
 
+void pa_cpu_init(pa_cpu_info *cpu_info);
+
 #endif /* foocpuhfoo */



More information about the pulseaudio-commits mailing list