diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/proplist-test.c | 11 | ||||
-rw-r--r-- | src/tests/rtstutter.c | 19 | ||||
-rw-r--r-- | src/tests/vector-test.c | 83 | ||||
-rw-r--r-- | src/tests/voltest.c | 29 |
4 files changed, 133 insertions, 9 deletions
diff --git a/src/tests/proplist-test.c b/src/tests/proplist-test.c index 20041af6..f69fa686 100644 --- a/src/tests/proplist-test.c +++ b/src/tests/proplist-test.c @@ -29,8 +29,8 @@ #include <pulsecore/core-util.h> int main(int argc, char*argv[]) { - pa_proplist *a, *b; - char *s, *t; + pa_proplist *a, *b, *c; + char *s, *t, *u; a = pa_proplist_new(); pa_assert_se(pa_proplist_sets(a, PA_PROP_MEDIA_TITLE, "Brandenburgische Konzerte") == 0); @@ -50,11 +50,18 @@ int main(int argc, char*argv[]) { s = pa_proplist_to_string(a); t = pa_proplist_to_string(b); printf("---\n%s---\n%s", s, t); + + c = pa_proplist_from_string(s); + u = pa_proplist_to_string(c); + pa_assert_se(pa_streq(s, u)); + pa_xfree(s); pa_xfree(t); + pa_xfree(u); pa_proplist_free(a); pa_proplist_free(b); + pa_proplist_free(c); return 0; } diff --git a/src/tests/rtstutter.c b/src/tests/rtstutter.c index 6b0cb8f7..d8aff342 100644 --- a/src/tests/rtstutter.c +++ b/src/tests/rtstutter.c @@ -36,30 +36,35 @@ #include <pulsecore/log.h> #include <pulsecore/macro.h> +#include <pulsecore/core-util.h> static int msec_lower, msec_upper; static void* work(void *p) PA_GCC_NORETURN; static void* work(void *p) { +#ifdef HAVE_PTHREAD_SETAFFINITY_NP cpu_set_t mask; +#endif struct sched_param param; - pa_log_notice("CPU%i: Created thread.", PA_PTR_TO_INT(p)); + pa_log_notice("CPU%i: Created thread.", PA_PTR_TO_UINT(p)); memset(¶m, 0, sizeof(param)); param.sched_priority = 12; pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) == 0); +#ifdef HAVE_PTHREAD_SETAFFINITY_NP CPU_ZERO(&mask); - CPU_SET((size_t) PA_PTR_TO_INT(p), &mask); + CPU_SET((size_t) PA_PTR_TO_UINT(p), &mask); pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0); +#endif for (;;) { struct timespec now, end; uint64_t nsec; - pa_log_notice("CPU%i: Sleeping for 1s", PA_PTR_TO_INT(p)); + pa_log_notice("CPU%i: Sleeping for 1s", PA_PTR_TO_UINT(p)); sleep(1); pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0); @@ -68,7 +73,7 @@ static void* work(void *p) { (uint64_t) ((((double) rand())*(double)(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) + (uint64_t) ((uint64_t) msec_lower*PA_NSEC_PER_MSEC); - pa_log_notice("CPU%i: Freezing for %ims", PA_PTR_TO_INT(p), (int) (nsec/PA_NSEC_PER_MSEC)); + pa_log_notice("CPU%i: Freezing for %ims", PA_PTR_TO_UINT(p), (int) (nsec/PA_NSEC_PER_MSEC)); end.tv_sec += (time_t) (nsec / PA_NSEC_PER_SEC); end.tv_nsec += (long int) (nsec % PA_NSEC_PER_SEC); @@ -86,7 +91,7 @@ static void* work(void *p) { } int main(int argc, char*argv[]) { - int n; + unsigned n; srand((unsigned) time(NULL)); @@ -106,9 +111,9 @@ int main(int argc, char*argv[]) { pa_log_notice("Creating random latencies in the range of %ims to %ims.", msec_lower, msec_upper); - for (n = 1; n < sysconf(_SC_NPROCESSORS_CONF); n++) { + for (n = 1; n < pa_ncpus(); n++) { pthread_t t; - pa_assert_se(pthread_create(&t, NULL, work, PA_INT_TO_PTR(n)) == 0); + pa_assert_se(pthread_create(&t, NULL, work, PA_UINT_TO_PTR(n)) == 0); } work(PA_INT_TO_PTR(0)); diff --git a/src/tests/vector-test.c b/src/tests/vector-test.c new file mode 100644 index 00000000..f7344172 --- /dev/null +++ b/src/tests/vector-test.c @@ -0,0 +1,83 @@ +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + 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 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 <pulsecore/vector.h> +#include <pulsecore/log.h> + +int main(int argc, char *argv[]) { + +#ifdef __SSE2__ + pa_int16_vector_t input, zero; + pa_int32_vector_t unpacked1, unpacked2; + pa_int32_vector_t volume1, volume2, volume1_hi, volume1_lo, volume2_hi, volume2_lo, reduce, mask; + pa_int16_vector_t output; + + unsigned u; + + zero.v = PA_INT16_VECTOR_MAKE(0); + reduce.v = PA_INT32_VECTOR_MAKE(0x10000); + volume1.v = volume2.v = PA_INT32_VECTOR_MAKE(0x10000*2+7); + mask.v = PA_INT32_VECTOR_MAKE(0xFFFF); + + volume1_lo.m = _mm_and_si128(volume1.m, mask.m); + volume2_lo.m = _mm_and_si128(volume2.m, mask.m); + volume1_hi.m = _mm_srli_epi32(volume1.m, 16); + volume2_hi.m = _mm_srli_epi32(volume2.m, 16); + + input.v = PA_INT16_VECTOR_MAKE(32000); + + for (u = 0; u < PA_INT16_VECTOR_SIZE; u++) + pa_log("input=%i\n", input.i[u]); + + unpacked1.m = _mm_unpackhi_epi16(zero.m, input.m); + unpacked2.m = _mm_unpacklo_epi16(zero.m, input.m); + + for (u = 0; u < PA_INT32_VECTOR_SIZE; u++) + pa_log("unpacked1=%i\n", unpacked1.i[u]); + + unpacked1.v /= reduce.v; + unpacked2.v /= reduce.v; + + for (u = 0; u < PA_INT32_VECTOR_SIZE; u++) + pa_log("unpacked1=%i\n", unpacked1.i[u]); + + for (u = 0; u < PA_INT32_VECTOR_SIZE; u++) + pa_log("volume1=%i\n", volume1.i[u]); + + unpacked1.v = (unpacked1.v * volume1_lo.v) / reduce.v + unpacked1.v * volume1_hi.v; + unpacked2.v = (unpacked2.v * volume2_lo.v) / reduce.v + unpacked2.v * volume2_hi.v; + + for (u = 0; u < PA_INT32_VECTOR_SIZE; u++) + pa_log("unpacked1=%i\n", unpacked1.i[u]); + + output.m = _mm_packs_epi32(unpacked1.m, unpacked2.m); + + for (u = 0; u < PA_INT16_VECTOR_SIZE; u++) + pa_log("output=%i\n", output.i[u]); + +#endif + + return 0; +} diff --git a/src/tests/voltest.c b/src/tests/voltest.c index 5bfc97e0..0c6d2ea6 100644 --- a/src/tests/voltest.c +++ b/src/tests/voltest.c @@ -6,6 +6,8 @@ int main(int argc, char *argv[]) { pa_volume_t v; pa_cvolume cv; + float b; + pa_channel_map map; for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 256) { @@ -28,5 +30,32 @@ int main(int argc, char *argv[]) { } + map.channels = cv.channels = 2; + map.map[0] = PA_CHANNEL_POSITION_LEFT; + map.map[1] = PA_CHANNEL_POSITION_RIGHT; + + for (cv.values[0] = PA_VOLUME_MUTED; cv.values[0] <= PA_VOLUME_NORM*2; cv.values[0] += 4096) + for (cv.values[1] = PA_VOLUME_MUTED; cv.values[1] <= PA_VOLUME_NORM*2; cv.values[1] += 4096) { + char s[PA_CVOLUME_SNPRINT_MAX]; + + printf("Volume: [%s]; balance: %2.1f\n", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map)); + } + + for (cv.values[0] = PA_VOLUME_MUTED+4096; cv.values[0] <= PA_VOLUME_NORM*2; cv.values[0] += 4096) + for (cv.values[1] = PA_VOLUME_MUTED; cv.values[1] <= PA_VOLUME_NORM*2; cv.values[1] += 4096) + for (b = -1.0f; b <= 1.0f; b += 0.2f) { + char s[PA_CVOLUME_SNPRINT_MAX]; + pa_cvolume r; + float k; + + printf("Before: volume: [%s]; balance: %2.1f\n", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map)); + + r = cv; + pa_cvolume_set_balance(&r, &map,b); + + k = pa_cvolume_get_balance(&r, &map); + printf("After: volume: [%s]; balance: %2.1f (intended: %2.1f) %s\n", pa_cvolume_snprint(s, sizeof(s), &r), k, b, k < b-.05 || k > b+.5 ? "MISMATCH" : ""); + } + return 0; } |