diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-07-20 17:34:17 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-07-20 17:34:17 +0200 |
commit | 18e975fc5ef68a89875c77974570884b9214a009 (patch) | |
tree | e0346c369315e71f386190c19ad4a1c06d5b526e /src/tests/interpol-test.c | |
parent | 3a09a88fd1f3dfe365dc1f3e455c097010d00964 (diff) |
mergedrtpoll
Diffstat (limited to 'src/tests/interpol-test.c')
-rw-r--r-- | src/tests/interpol-test.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/tests/interpol-test.c b/src/tests/interpol-test.c index dd24e829..0c906d3e 100644 --- a/src/tests/interpol-test.c +++ b/src/tests/interpol-test.c @@ -36,6 +36,9 @@ #include <pulsecore/thread.h> +#define INTERPOLATE +//#define CORK + static pa_context *context = NULL; static pa_stream *stream = NULL; static pa_mainloop_api *mainloop_api = NULL; @@ -58,6 +61,15 @@ static void stream_read_cb(pa_stream *p, size_t nbytes, void *userdata) { } } +static void stream_latency_cb(pa_stream *p, void *userdata) { +#ifndef INTERPOLATE + pa_operation *o; + + o = pa_stream_update_timing_info(p, NULL, NULL); + pa_operation_unref(o); +#endif +} + /* This is called whenever the context status changes */ static void context_state_callback(pa_context *c, void *userdata) { assert(c); @@ -69,6 +81,7 @@ static void context_state_callback(pa_context *c, void *userdata) { break; case PA_CONTEXT_READY: { + pa_stream_flags_t flags = PA_STREAM_AUTO_TIMING_UPDATE; static const pa_sample_spec ss = { .format = PA_SAMPLE_S16LE, @@ -76,19 +89,25 @@ static void context_state_callback(pa_context *c, void *userdata) { .channels = 2 }; +#ifdef INTERPOLATE + flags |= PA_STREAM_INTERPOLATE_TIMING; +#endif + fprintf(stderr, "Connection established.\n"); stream = pa_stream_new(c, "interpol-test", &ss, NULL); assert(stream); 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_assert_se(pa_stream_connect_playback(stream, NULL, NULL, flags, 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_assert_se(pa_stream_connect_record(stream, NULL, NULL, flags) == 0); pa_stream_set_read_callback(stream, stream_read_cb, NULL); } + pa_stream_set_latency_update_callback(stream, stream_latency_cb, NULL); + break; } @@ -107,7 +126,11 @@ int main(int argc, char *argv[]) { int k, r; struct timeval start, last_info = { 0, 0 }; pa_usec_t old_t = 0, old_rtc = 0; +#ifdef CORK pa_bool_t corked = FALSE; +#endif + + pa_log_set_level(PA_LOG_DEBUG); playback = argc <= 1 || !pa_streq(argv[1], "-r"); @@ -130,7 +153,12 @@ int main(int argc, char *argv[]) { r = pa_threaded_mainloop_start(m); assert(r >= 0); - for (k = 0; k < 20000; k++) { +/* #ifdef CORK */ + for (k = 0; k < 20000; k++) +/* #else */ +/* for (k = 0; k < 2000; k++) */ +/* #endif */ + { pa_bool_t success = FALSE, changed = FALSE; pa_usec_t t, rtc; struct timeval now, tv; @@ -159,14 +187,16 @@ int main(int argc, char *argv[]) { pa_gettimeofday(&now); if (success) { +#ifdef CORK pa_bool_t cork_now; - +#endif rtc = pa_timeval_diff(&now, &start); - printf("%i\t%llu\t%llu\t%llu\t%llu\t%u\t%u\n", k, + printf("%i\t%llu\t%llu\t%llu\t%llu\t%lli\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), + (signed long long) rtc - (signed long long) t, changed, playing); @@ -174,6 +204,7 @@ int main(int argc, char *argv[]) { old_t = t; old_rtc = rtc; +#ifdef CORK cork_now = (rtc / (2*PA_USEC_PER_SEC)) % 2 == 1; if (corked != cork_now) { @@ -185,6 +216,7 @@ int main(int argc, char *argv[]) { corked = cork_now; } +#endif } /* Spin loop, ugly but normal usleep() is just too badly grained */ |