diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/cpulimit-test.c | 4 | ||||
-rw-r--r-- | src/tests/envelope-test.c | 243 | ||||
-rw-r--r-- | src/tests/mainloop-test.c | 2 | ||||
-rw-r--r-- | src/tests/memblockq-test.c | 2 | ||||
-rw-r--r-- | src/tests/mix-test.c | 10 | ||||
-rw-r--r-- | src/tests/rtstutter.c | 2 | ||||
-rw-r--r-- | src/tests/usergroup-test.c | 18 |
7 files changed, 13 insertions, 268 deletions
diff --git a/src/tests/cpulimit-test.c b/src/tests/cpulimit-test.c index 9d0f4eef..5b11bc44 100644 --- a/src/tests/cpulimit-test.c +++ b/src/tests/cpulimit-test.c @@ -22,7 +22,7 @@ #endif #include <assert.h> -#include <sys/time.h> +#include <time.h> #include <stdlib.h> #include <stdio.h> #include <signal.h> @@ -34,7 +34,7 @@ #include <pulse/mainloop-signal.h> #endif -#include "../daemon/cpulimit.h" +#include <daemon/cpulimit.h> /* A simple example for testing the cpulimit subsystem */ diff --git a/src/tests/envelope-test.c b/src/tests/envelope-test.c deleted file mode 100644 index 9382040b..00000000 --- a/src/tests/envelope-test.c +++ /dev/null @@ -1,243 +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 <stdio.h> -#include <stdlib.h> - -#include <pulse/sample.h> -#include <pulse/volume.h> -#include <pulse/timeval.h> - -#include <pulsecore/envelope.h> -#include <pulsecore/macro.h> -#include <pulsecore/endianmacros.h> -#include <pulsecore/memblock.h> -#include <pulsecore/sample-util.h> - -const pa_envelope_def ramp_down = { - .n_points = 2, - .points_x = { 100*PA_USEC_PER_MSEC, 300*PA_USEC_PER_MSEC }, - .points_y = { - .f = { 1.0f, 0.2f }, - .i = { 0x10000, 0x10000/5 } - } -}; - -const pa_envelope_def ramp_up = { - .n_points = 2, - .points_x = { 100*PA_USEC_PER_MSEC, 300*PA_USEC_PER_MSEC }, - .points_y = { - .f = { 0.2f, 1.0f }, - .i = { 0x10000/5, 0x10000 } - } -}; - -const pa_envelope_def ramp_down2 = { - .n_points = 2, - .points_x = { 50*PA_USEC_PER_MSEC, 900*PA_USEC_PER_MSEC }, - .points_y = { - .f = { 0.8f, 0.7f }, - .i = { 0x10000*4/5, 0x10000*7/10 } - } -}; - -const pa_envelope_def ramp_up2 = { - .n_points = 2, - .points_x = { 50*PA_USEC_PER_MSEC, 900*PA_USEC_PER_MSEC }, - .points_y = { - .f = { 0.7f, 0.9f }, - .i = { 0x10000*7/10, 0x10000*9/10 } - } -}; - -static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) { - void *d; - unsigned i; - - static unsigned j = 0; - - d = pa_memblock_acquire(chunk->memblock); - - switch (ss->format) { - - case PA_SAMPLE_U8: - case PA_SAMPLE_ULAW: - case PA_SAMPLE_ALAW: { - uint8_t *u = d; - - for (i = 0; i < chunk->length / pa_frame_size(ss); i++) - printf("0x%02x ", *(u++)); - - break; - } - - case PA_SAMPLE_S16NE: - case PA_SAMPLE_S16RE: { - int16_t *u = d; - - for (i = 0; i < chunk->length / pa_frame_size(ss); i++) - printf("%i\t%i\n", j++, *(u++)); - - break; - } - - case PA_SAMPLE_S32NE: - case PA_SAMPLE_S32RE: { - int32_t *u = d; - - for (i = 0; i < chunk->length / pa_frame_size(ss); i++) - printf("%i\t%i\n", j++, *(u++)); - - break; - } - - case PA_SAMPLE_FLOAT32NE: - case PA_SAMPLE_FLOAT32RE: { - float *u = d; - - for (i = 0; i < chunk->length / pa_frame_size(ss); i++) { - printf("%i\t%1.3g\n", j++, PA_MAYBE_FLOAT32_SWAP(ss->format == PA_SAMPLE_FLOAT32RE, *u)); - u++; - } - - break; - } - - default: - pa_assert_not_reached(); - } - - printf("\n"); - - pa_memblock_release(chunk->memblock); -} - -static pa_memblock * generate_block(pa_mempool *pool, const pa_sample_spec *ss) { - pa_memblock *block; - void *d; - unsigned n_samples; - - block = pa_memblock_new(pool, pa_bytes_per_second(ss)); - n_samples = (unsigned) (pa_memblock_get_length(block) / pa_sample_size(ss)); - - d = pa_memblock_acquire(block); - - switch (ss->format) { - - case PA_SAMPLE_S16NE: - case PA_SAMPLE_S16RE: { - int16_t *i; - - for (i = d; n_samples > 0; n_samples--, i++) - *i = 0x7FFF; - - break; - } - - case PA_SAMPLE_S32NE: - case PA_SAMPLE_S32RE: { - int32_t *i; - - for (i = d; n_samples > 0; n_samples--, i++) - *i = 0x7FFFFFFF; - - break; - } - - case PA_SAMPLE_FLOAT32RE: - case PA_SAMPLE_FLOAT32NE: { - float *f; - - for (f = d; n_samples > 0; n_samples--, f++) - *f = PA_MAYBE_FLOAT32_SWAP(ss->format == PA_SAMPLE_FLOAT32RE, 1.0f); - - break; - } - - default: - pa_assert_not_reached(); - } - - pa_memblock_release(block); - return block; -} - -int main(int argc, char *argv[]) { - pa_mempool *pool; - pa_memblock *block; - pa_memchunk chunk; - pa_envelope *envelope; - pa_envelope_item *item1, *item2; - - const pa_sample_spec ss = { - .format = PA_SAMPLE_S16NE, - .channels = 1, - .rate = 200 - }; - - const pa_cvolume v = { - .channels = 1, - .values = { PA_VOLUME_NORM, PA_VOLUME_NORM/2 } - }; - - pa_log_set_level(PA_LOG_DEBUG); - - pa_assert_se(pool = pa_mempool_new(FALSE, 0)); - pa_assert_se(envelope = pa_envelope_new(&ss)); - - block = generate_block(pool, &ss); - - chunk.memblock = pa_memblock_ref(block); - chunk.length = pa_memblock_get_length(block); - chunk.index = 0; - - pa_volume_memchunk(&chunk, &ss, &v); - - item1 = pa_envelope_add(envelope, &ramp_down); - item2 = pa_envelope_add(envelope, &ramp_down2); - pa_envelope_apply(envelope, &chunk); - dump_block(&ss, &chunk); - - pa_memblock_unref(chunk.memblock); - - chunk.memblock = pa_memblock_ref(block); - chunk.length = pa_memblock_get_length(block); - chunk.index = 0; - - item1 = pa_envelope_replace(envelope, item1, &ramp_up); - item2 = pa_envelope_replace(envelope, item2, &ramp_up2); - pa_envelope_apply(envelope, &chunk); - dump_block(&ss, &chunk); - - pa_memblock_unref(chunk.memblock); - - pa_envelope_remove(envelope, item1); - pa_envelope_remove(envelope, item2); - pa_envelope_free(envelope); - - pa_memblock_unref(block); - - pa_mempool_free(pool); - - return 0; -} diff --git a/src/tests/mainloop-test.c b/src/tests/mainloop-test.c index 3ec6d115..cd54bcfe 100644 --- a/src/tests/mainloop-test.c +++ b/src/tests/mainloop-test.c @@ -48,7 +48,7 @@ static pa_defer_event *de; static void iocb(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags_t f, void *userdata) { unsigned char c; - (void) read(fd, &c, sizeof(c)); + pa_assert_se(read(fd, &c, sizeof(c)) >= 0); fprintf(stderr, "IO EVENT: %c\n", c < 32 ? '.' : c); a->defer_enable(de, 1); } diff --git a/src/tests/memblockq-test.c b/src/tests/memblockq-test.c index e401bb62..b6c60039 100644 --- a/src/tests/memblockq-test.c +++ b/src/tests/memblockq-test.c @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) { p = pa_mempool_new(FALSE, 0); - silence.memblock = pa_memblock_new_fixed(p, (char*) "__", 2, 1); + silence.memblock = pa_memblock_new_fixed(p, (char*) "__", 2, 1); assert(silence.memblock); silence.index = 0; silence.length = pa_memblock_get_length(silence.memblock); diff --git a/src/tests/mix-test.c b/src/tests/mix-test.c index 457c4acd..55844e7f 100644 --- a/src/tests/mix-test.c +++ b/src/tests/mix-test.c @@ -32,12 +32,6 @@ #include <pulsecore/memblock.h> #include <pulsecore/sample-util.h> -static float swap_float(float a) { - uint32_t *b = (uint32_t*) &a; - *b = PA_UINT32_SWAP(*b); - return a; -} - static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) { void *d; unsigned i; @@ -96,7 +90,7 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) { float *u = d; for (i = 0; i < chunk->length / pa_frame_size(ss); i++) { - printf("%1.5f ", ss->format == PA_SAMPLE_FLOAT32NE ? *u : swap_float(*u)); + printf("%1.5f ", ss->format == PA_SAMPLE_FLOAT32NE ? *u : PA_FLOAT32_SWAP(*u)); u++; } @@ -188,7 +182,7 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) { if (ss->format == PA_SAMPLE_FLOAT32RE) { for (i = 0; i < 10; i++) - u[i] = swap_float(float_samples[i]); + u[i] = PA_FLOAT32_SWAP(float_samples[i]); } else memcpy(d, float_samples, sizeof(float_samples)); diff --git a/src/tests/rtstutter.c b/src/tests/rtstutter.c index 9ef835c3..402a8c09 100644 --- a/src/tests/rtstutter.c +++ b/src/tests/rtstutter.c @@ -106,7 +106,7 @@ int main(int argc, char*argv[]) { pa_assert(msec_upper > 0); pa_assert(msec_upper >= msec_lower); - pa_log_notice("Creating random latencies in the range of %ims to %ims.", msec_lower, msec_upper); + pa_log_notice("Creating random latencies in the range of %ims to %ims.", msec_lower, msec_upper); for (n = 1; n < pa_ncpus(); n++) { pa_assert_se(pa_thread_new("rtstutter", work, PA_UINT_TO_PTR(n))); diff --git a/src/tests/usergroup-test.c b/src/tests/usergroup-test.c index a48b016d..3948e0f8 100644 --- a/src/tests/usergroup-test.c +++ b/src/tests/usergroup-test.c @@ -47,28 +47,24 @@ static int compare_group(const struct group *a, const struct group *b) { char **amem, **bmem; if (strcmp(a->gr_name, b->gr_name)) { - fprintf(stderr, "Group name mismatch: [%s] [%s]\n", - a->gr_name, b->gr_name); + fprintf(stderr, "Group name mismatch: [%s] [%s]\n", a->gr_name, b->gr_name); return 1; } if (strcmp(a->gr_passwd, b->gr_passwd)) { - fprintf(stderr, "Group password mismatch: [%s] [%s]\n", - a->gr_passwd, b->gr_passwd); + fprintf(stderr, "Group password mismatch: [%s] [%s]\n", a->gr_passwd, b->gr_passwd); return 1; } if (a->gr_gid != b->gr_gid) { - fprintf(stderr, "Gid mismatch: [%lu] [%lu]\n", - (unsigned long) a->gr_gid, (unsigned long) b->gr_gid); + fprintf(stderr, "Gid mismatch: [%lu] [%lu]\n", (unsigned long) a->gr_gid, (unsigned long) b->gr_gid); return 1; } /* XXX: Assuming the group ordering is identical. */ for (amem = a->gr_mem, bmem = b->gr_mem; *amem && *bmem; ++amem, ++bmem) { if (strcmp(*amem, *bmem)) { - fprintf(stderr, "Group member mismatch: [%s] [%s]\n", - *amem, *bmem); + fprintf(stderr, "Group member mismatch: [%s] [%s]\n", *amem, *bmem); return 1; } } @@ -93,14 +89,12 @@ static int compare_passwd(const struct passwd *a, const struct passwd *b) { } if (a->pw_uid != b->pw_uid) { - fprintf(stderr, "pw_uid mismatch: [%lu] [%lu]\n", - (unsigned long) a->pw_uid, (unsigned long) b->pw_uid); + fprintf(stderr, "pw_uid mismatch: [%lu] [%lu]\n", (unsigned long) a->pw_uid, (unsigned long) b->pw_uid); return 1; } if (a->pw_gid != b->pw_gid) { - fprintf(stderr, "pw_gid mismatch: [%lu] [%lu]\n", - (unsigned long) a->pw_gid, (unsigned long) b->pw_gid); + fprintf(stderr, "pw_gid mismatch: [%lu] [%lu]\n", (unsigned long) a->pw_gid, (unsigned long) b->pw_gid); return 1; } |