diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/interpol-test.c | 38 | ||||
-rw-r--r-- | src/tests/ipacl-test.c | 3 | ||||
-rw-r--r-- | src/tests/sync-playback.c | 7 | ||||
-rw-r--r-- | src/tests/thread-mainloop-test.c | 2 |
4 files changed, 42 insertions, 8 deletions
diff --git a/src/tests/interpol-test.c b/src/tests/interpol-test.c index 9d930774..d7da660c 100644 --- a/src/tests/interpol-test.c +++ b/src/tests/interpol-test.c @@ -39,10 +39,23 @@ static pa_context *context = NULL; static pa_stream *stream = NULL; static pa_mainloop_api *mainloop_api = NULL; +static pa_bool_t playback = TRUE; static void stream_write_cb(pa_stream *p, size_t nbytes, void *userdata) { /* Just some silence */ - pa_stream_write(p, pa_xmalloc0(nbytes), nbytes, pa_xfree, 0, PA_SEEK_RELATIVE); + pa_assert_se(pa_stream_write(p, pa_xmalloc0(nbytes), nbytes, pa_xfree, 0, PA_SEEK_RELATIVE) == 0); +} + +static void stream_read_cb(pa_stream *p, size_t nbytes, void *userdata) { + /* We don't care, just drop the data */ + + while (pa_stream_readable_size(p) > 0) { + const void *d; + size_t b; + + pa_assert_se(pa_stream_peek(p, &d, &b) == 0); + pa_assert_se(pa_stream_drop(p) == 0); + } } /* This is called whenever the context status changes */ @@ -68,8 +81,13 @@ static void context_state_callback(pa_context *c, void *userdata) { stream = pa_stream_new(c, "interpol-test", &ss, NULL); assert(stream); - pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL); - pa_stream_set_write_callback(stream, stream_write_cb, NULL); + if (playback) { + pa_assert_se(pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL) == 0); + pa_stream_set_write_callback(stream, stream_write_cb, NULL); + } else { + pa_assert_se(pa_stream_connect_record(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE) == 0); + pa_stream_set_read_callback(stream, stream_read_cb, NULL); + } break; } @@ -90,6 +108,8 @@ int main(int argc, char *argv[]) { struct timeval start, last_info = { 0, 0 }; pa_usec_t old_t = 0, old_rtc = 0; + playback = argc <= 1 || !pa_streq(argv[1], "-r"); + /* Set up a new main loop */ m = pa_threaded_mainloop_new(); assert(m); @@ -106,7 +126,8 @@ int main(int argc, char *argv[]) { pa_gettimeofday(&start); - pa_threaded_mainloop_start(m); + r = pa_threaded_mainloop_start(m); + assert(r >= 0); for (k = 0; k < 5000; k++) { pa_bool_t success = FALSE, changed = FALSE; @@ -138,7 +159,14 @@ int main(int argc, char *argv[]) { if (success) { rtc = pa_timeval_diff(&now, &start); - printf("%i\t%llu\t%llu\t%llu\t%llu\t%u\t%u\n", k, (unsigned long long) rtc, (unsigned long long) t, (unsigned long long) (rtc-old_rtc), (unsigned long long) (t-old_t), changed, playing); + printf("%i\t%llu\t%llu\t%llu\t%llu\t%u\t%u\n", k, + (unsigned long long) rtc, + (unsigned long long) t, + (unsigned long long) (rtc-old_rtc), + (unsigned long long) (t-old_t), + changed, + playing); + fflush(stdout); old_t = t; old_rtc = rtc; diff --git a/src/tests/ipacl-test.c b/src/tests/ipacl-test.c index 7b7564a4..f89665cd 100644 --- a/src/tests/ipacl-test.c +++ b/src/tests/ipacl-test.c @@ -25,6 +25,7 @@ #endif #include "../pulsecore/winsock.h" +#include "../pulsecore/macro.h" #include <pulsecore/ipacl.h> @@ -96,7 +97,7 @@ int main(int argc, char *argv[]) { memset(&sa6, 0, sizeof(sa6)); sa6.sin6_family = AF_INET6; sa6.sin6_port = htons(22); - inet_pton(AF_INET6, "::1", &sa6.sin6_addr); + pa_assert_se(inet_pton(AF_INET6, "::1", &sa6.sin6_addr) == 1); r = connect(fd, (struct sockaddr*) &sa6, sizeof(sa6)); assert(r >= 0); diff --git a/src/tests/sync-playback.c b/src/tests/sync-playback.c index 42c479a1..f2a15601 100644 --- a/src/tests/sync-playback.c +++ b/src/tests/sync-playback.c @@ -174,11 +174,16 @@ int main(int argc, char *argv[]) { pa_context_set_state_callback(context, context_state_callback, NULL); - pa_context_connect(context, NULL, 0, NULL); + /* Connect the context */ + if (pa_context_connect(context, NULL, 0, NULL) < 0) { + fprintf(stderr, "pa_context_connect() failed.\n"); + goto quit; + } if (pa_mainloop_run(m, &ret) < 0) fprintf(stderr, "pa_mainloop_run() failed.\n"); +quit: pa_context_unref(context); for (i = 0; i < NSTREAMS; i++) diff --git a/src/tests/thread-mainloop-test.c b/src/tests/thread-mainloop-test.c index 263cd57d..3bcf4f16 100644 --- a/src/tests/thread-mainloop-test.c +++ b/src/tests/thread-mainloop-test.c @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { pa_assert_se(m = pa_threaded_mainloop_new()); pa_assert_se(a = pa_threaded_mainloop_get_api(m)); - pa_threaded_mainloop_start(m); + pa_assert_se(pa_threaded_mainloop_start(m) >= 0); pa_threaded_mainloop_lock(m); |