diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/ipacl-test.c | 6 | ||||
-rw-r--r-- | src/tests/mainloop-test.c | 6 | ||||
-rw-r--r-- | src/tests/mix-test.c | 97 | ||||
-rw-r--r-- | src/tests/rtpoll-test.c | 6 | ||||
-rw-r--r-- | src/tests/rtstutter.c | 4 | ||||
-rw-r--r-- | src/tests/thread-mainloop-test.c | 8 |
6 files changed, 66 insertions, 61 deletions
diff --git a/src/tests/ipacl-test.c b/src/tests/ipacl-test.c index f89665cd..57b70685 100644 --- a/src/tests/ipacl-test.c +++ b/src/tests/ipacl-test.c @@ -91,8 +91,10 @@ int main(int argc, char *argv[]) { close(fd); #ifdef HAVE_IPV6 - fd = socket(PF_INET6, SOCK_STREAM, 0); - assert(fd >= 0); + if ( (fd = socket(PF_INET6, SOCK_STREAM, 0)) < 0 ) { + printf("Unable to open IPv6 socket, IPv6 tests ignored"); + return 0; + } memset(&sa6, 0, sizeof(sa6)); sa6.sin6_family = AF_INET6; diff --git a/src/tests/mainloop-test.c b/src/tests/mainloop-test.c index 4ca63513..3ec6d115 100644 --- a/src/tests/mainloop-test.c +++ b/src/tests/mainloop-test.c @@ -26,10 +26,12 @@ #include <sys/time.h> #include <assert.h> +#include <pulse/rtclock.h> #include <pulse/timeval.h> #include <pulse/gccmacro.h> #include <pulsecore/core-util.h> +#include <pulsecore/core-rtclock.h> #ifdef GLIB_MAIN_LOOP @@ -99,9 +101,7 @@ int main(int argc, char *argv[]) { de = a->defer_new(a, dcb, NULL); assert(de); - pa_gettimeofday(&tv); - tv.tv_sec += 10; - te = a->time_new(a, &tv, tcb, NULL); + te = a->time_new(a, pa_timeval_rtstore(&tv, pa_rtclock_now() + 2 * PA_USEC_PER_SEC, TRUE), tcb, NULL); #if defined(GLIB_MAIN_LOOP) g_main_loop_run(glib_main_loop); diff --git a/src/tests/mix-test.c b/src/tests/mix-test.c index ac4b57b5..3f65cbac 100644 --- a/src/tests/mix-test.c +++ b/src/tests/mix-test.c @@ -79,6 +79,18 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) { break; } + case PA_SAMPLE_S24NE: + case PA_SAMPLE_S24RE: { + uint8_t *u = d; + + for (i = 0; i < chunk->length / pa_frame_size(ss); i++) { + printf("0x%02x%02x%02xx ", *u, *(u+1), *(u+2)); + u += 3; + } + + break; + } + case PA_SAMPLE_FLOAT32NE: case PA_SAMPLE_FLOAT32RE: { float *u = d; @@ -113,73 +125,66 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) { case PA_SAMPLE_U8: case PA_SAMPLE_ULAW: case PA_SAMPLE_ALAW: { - uint8_t *u = d; + static const uint8_t u8_samples[] = + { 0x00, 0xFF, 0x7F, 0x80, 0x9f, + 0x3f, 0x01, 0xF0, 0x20, 0x21 }; - u[0] = 0x00; - u[1] = 0xFF; - u[2] = 0x7F; - u[3] = 0x80; - u[4] = 0x9f; - u[5] = 0x3f; - u[6] = 0x1; - u[7] = 0xF0; - u[8] = 0x20; - u[9] = 0x21; + memcpy(d, &u8_samples[0], sizeof(u8_samples)); break; } case PA_SAMPLE_S16NE: case PA_SAMPLE_S16RE: { - uint16_t *u = d; + static const uint16_t u16_samples[] = + { 0x0000, 0xFFFF, 0x7FFF, 0x8000, 0x9fff, + 0x3fff, 0x0001, 0xF000, 0x0020, 0x0021 }; - u[0] = 0x0000; - u[1] = 0xFFFF; - u[2] = 0x7FFF; - u[3] = 0x8000; - u[4] = 0x9fff; - u[5] = 0x3fff; - u[6] = 0x1; - u[7] = 0xF000; - u[8] = 0x20; - u[9] = 0x21; + memcpy(d, &u16_samples[0], sizeof(u16_samples)); break; } case PA_SAMPLE_S32NE: case PA_SAMPLE_S32RE: { - uint32_t *u = d; + static const uint32_t u32_samples[] = + { 0x00000001, 0xFFFF0002, 0x7FFF0003, 0x80000004, 0x9fff0005, + 0x3fff0006, 0x00010007, 0xF0000008, 0x00200009, 0x0021000A }; + + memcpy(d, &u32_samples[0], sizeof(u32_samples)); + break; + } - u[0] = 0x00000001; - u[1] = 0xFFFF0002; - u[2] = 0x7FFF0003; - u[3] = 0x80000004; - u[4] = 0x9fff0005; - u[5] = 0x3fff0006; - u[6] = 0x10007; - u[7] = 0xF0000008; - u[8] = 0x200009; - u[9] = 0x21000A; + case PA_SAMPLE_S24NE: + case PA_SAMPLE_S24RE: { + /* Need to be on a byte array because they are not aligned */ + static const uint8_t u24_samples[] = + { 0x00, 0x00, 0x01, + 0xFF, 0xFF, 0x02, + 0x7F, 0xFF, 0x03, + 0x80, 0x00, 0x04, + 0x9f, 0xff, 0x05, + 0x3f, 0xff, 0x06, + 0x01, 0x00, 0x07, + 0xF0, 0x00, 0x08, + 0x20, 0x00, 0x09, + 0x21, 0x00, 0x0A }; + + memcpy(d, &u24_samples[0], sizeof(u24_samples)); break; } case PA_SAMPLE_FLOAT32NE: case PA_SAMPLE_FLOAT32RE: { float *u = d; + static const float float_samples[] = + { 0.0f, -1.0f, 1.0f, 4711.0f, 0.222f, + 0.33f, -.3f, 99.0f, -0.555f, -.123f }; - u[0] = 0.0f; - u[1] = -1.0f; - u[2] = 1.0f; - u[3] = 4711.0f; - u[4] = 0.222f; - u[5] = 0.33f; - u[6] = -.3f; - u[7] = 99.0f; - u[8] = -0.555f; - u[9] = -.123f; - - if (ss->format == PA_SAMPLE_FLOAT32RE) + if (ss->format == PA_SAMPLE_FLOAT32RE) { for (i = 0; i < 10; i++) - u[i] = swap_float(u[i]); + u[i] = swap_float(float_samples[i]); + } else { + memcpy(d, &float_samples[0], sizeof(float_samples)); + } break; } diff --git a/src/tests/rtpoll-test.c b/src/tests/rtpoll-test.c index 4ac96446..1706cdfa 100644 --- a/src/tests/rtpoll-test.c +++ b/src/tests/rtpoll-test.c @@ -26,7 +26,6 @@ #include <pulsecore/log.h> #include <pulsecore/rtpoll.h> -#include <pulsecore/rtsig.h> static int before(pa_rtpoll_item *i) { pa_log("before"); @@ -47,10 +46,6 @@ int main(int argc, char *argv[]) { pa_rtpoll_item *i, *w; struct pollfd *pollfd; -#ifdef SIGRTMIN - pa_rtsig_configure(SIGRTMIN+10, SIGRTMAX); -#endif - p = pa_rtpoll_new(); i = pa_rtpoll_item_new(p, PA_RTPOLL_EARLY, 1); @@ -64,7 +59,6 @@ int main(int argc, char *argv[]) { w = pa_rtpoll_item_new(p, PA_RTPOLL_NORMAL, 0); pa_rtpoll_item_set_before_callback(w, worker); - pa_rtpoll_install(p); pa_rtpoll_set_timer_relative(p, 10000000); /* 10 s */ pa_rtpoll_run(p, 1); diff --git a/src/tests/rtstutter.c b/src/tests/rtstutter.c index a4b5d596..c93fee93 100644 --- a/src/tests/rtstutter.c +++ b/src/tests/rtstutter.c @@ -67,7 +67,9 @@ static void* work(void *p) { pa_log_notice("CPU%i: Sleeping for 1s", PA_PTR_TO_UINT(p)); sleep(1); +#ifdef CLOCK_REALTIME pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0); +#endif nsec = (uint64_t) ((((double) rand())*(double)(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) + @@ -84,7 +86,9 @@ static void* work(void *p) { } do { +#ifdef CLOCK_REALTIME pa_assert_se(clock_gettime(CLOCK_REALTIME, &now) == 0); +#endif } while (now.tv_sec < end.tv_sec || (now.tv_sec == end.tv_sec && now.tv_nsec < end.tv_nsec)); } diff --git a/src/tests/thread-mainloop-test.c b/src/tests/thread-mainloop-test.c index ad89414f..4696fb01 100644 --- a/src/tests/thread-mainloop-test.c +++ b/src/tests/thread-mainloop-test.c @@ -25,14 +25,16 @@ #include <unistd.h> #include <stdio.h> +#include <pulse/rtclock.h> #include <pulse/timeval.h> #include <pulse/util.h> #include <pulse/thread-mainloop.h> #include <pulse/gccmacro.h> #include <pulsecore/macro.h> +#include <pulsecore/core-rtclock.h> -static void tcb(pa_mainloop_api*a, pa_time_event *e, const struct timeval *tv, void *userdata) { +static void tcb(pa_mainloop_api *a, pa_time_event *e, const struct timeval *tv, void *userdata) { pa_assert_se(pa_threaded_mainloop_in_thread(userdata)); fprintf(stderr, "TIME EVENT START\n"); pa_threaded_mainloop_signal(userdata, 1); @@ -53,9 +55,7 @@ int main(int argc, char *argv[]) { pa_assert_se(!pa_threaded_mainloop_in_thread(m)); - pa_gettimeofday(&tv); - tv.tv_sec += 5; - a->time_new(a, &tv, tcb, m); + a->time_new(a, pa_timeval_rtstore(&tv, pa_rtclock_now() + 5 * PA_USEC_PER_SEC, TRUE), tcb, m); fprintf(stderr, "waiting 5s (signal)\n"); pa_threaded_mainloop_wait(m); |