summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/interpol-test.c27
-rw-r--r--src/tests/memblockq-test.c18
-rw-r--r--src/tests/smoother-test.c8
3 files changed, 39 insertions, 14 deletions
diff --git a/src/tests/interpol-test.c b/src/tests/interpol-test.c
index dd24e829..c103a493 100644
--- a/src/tests/interpol-test.c
+++ b/src/tests/interpol-test.c
@@ -36,6 +36,8 @@
#include <pulsecore/thread.h>
+#define INTERPOLATE
+
static pa_context *context = NULL;
static pa_stream *stream = NULL;
static pa_mainloop_api *mainloop_api = NULL;
@@ -58,6 +60,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 +80,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 +88,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;
}
@@ -109,6 +127,8 @@ int main(int argc, char *argv[]) {
pa_usec_t old_t = 0, old_rtc = 0;
pa_bool_t corked = FALSE;
+ pa_log_set_level(PA_LOG_DEBUG);
+
playback = argc <= 1 || !pa_streq(argv[1], "-r");
/* Set up a new main loop */
@@ -162,11 +182,12 @@ int main(int argc, char *argv[]) {
pa_bool_t cork_now;
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);
diff --git a/src/tests/memblockq-test.c b/src/tests/memblockq-test.c
index 127fb197..ec3f5426 100644
--- a/src/tests/memblockq-test.c
+++ b/src/tests/memblockq-test.c
@@ -105,45 +105,45 @@ int main(int argc, char *argv[]) {
ret = pa_memblockq_push(bq, &chunk4);
assert(ret == 0);
- pa_memblockq_seek(bq, -6, 0);
+ pa_memblockq_seek(bq, -6, 0, TRUE);
ret = pa_memblockq_push(bq, &chunk3);
assert(ret == 0);
- pa_memblockq_seek(bq, -2, 0);
+ pa_memblockq_seek(bq, -2, 0, TRUE);
ret = pa_memblockq_push(bq, &chunk1);
assert(ret == 0);
- pa_memblockq_seek(bq, -10, 0);
+ pa_memblockq_seek(bq, -10, 0, TRUE);
ret = pa_memblockq_push(bq, &chunk4);
assert(ret == 0);
- pa_memblockq_seek(bq, 10, 0);
+ pa_memblockq_seek(bq, 10, 0, TRUE);
ret = pa_memblockq_push(bq, &chunk1);
assert(ret == 0);
- pa_memblockq_seek(bq, -6, 0);
+ pa_memblockq_seek(bq, -6, 0, TRUE);
ret = pa_memblockq_push(bq, &chunk2);
assert(ret == 0);
/* Test splitting */
- pa_memblockq_seek(bq, -12, 0);
+ pa_memblockq_seek(bq, -12, 0, TRUE);
ret = pa_memblockq_push(bq, &chunk1);
assert(ret == 0);
- pa_memblockq_seek(bq, 20, 0);
+ pa_memblockq_seek(bq, 20, 0, TRUE);
/* Test merging */
ret = pa_memblockq_push(bq, &chunk3);
assert(ret == 0);
- pa_memblockq_seek(bq, -2, 0);
+ pa_memblockq_seek(bq, -2, 0, TRUE);
chunk3.index += 2;
chunk3.length -= 2;
ret = pa_memblockq_push(bq, &chunk3);
assert(ret == 0);
- pa_memblockq_seek(bq, 30, PA_SEEK_RELATIVE);
+ pa_memblockq_seek(bq, 30, PA_SEEK_RELATIVE, TRUE);
dump(bq);
diff --git a/src/tests/smoother-test.c b/src/tests/smoother-test.c
index 798dfed5..2cc9f58b 100644
--- a/src/tests/smoother-test.c
+++ b/src/tests/smoother-test.c
@@ -45,10 +45,12 @@ int main(int argc, char*argv[]) {
srand(0);
+ pa_log_set_level(PA_LOG_DEBUG);
+
for (m = 0, u = 0; u < PA_ELEMENTSOF(msec); u+= 2) {
msec[u] = m+1 + (rand() % 100) - 50;
- msec[u+1] = m + (rand() % 2000) - 1000;
+ msec[u+1] = m + (rand() % 2000) - 1000 + 5000;
m += rand() % 100;
@@ -59,7 +61,7 @@ int main(int argc, char*argv[]) {
msec[u+1] = 0;
}
- s = pa_smoother_new(700*PA_USEC_PER_MSEC, 2000*PA_USEC_PER_MSEC, TRUE, 6);
+ s = pa_smoother_new(700*PA_USEC_PER_MSEC, 2000*PA_USEC_PER_MSEC, FALSE, TRUE, 6, 0, TRUE);
for (x = 0, u = 0; x < PA_USEC_PER_SEC * 10; x += PA_USEC_PER_MSEC) {
@@ -67,6 +69,8 @@ int main(int argc, char*argv[]) {
pa_smoother_put(s, (pa_usec_t) msec[u] * PA_USEC_PER_MSEC, (pa_usec_t) msec[u+1] * PA_USEC_PER_MSEC);
printf("%i\t\t%i\n", msec[u], msec[u+1]);
u += 2;
+
+ pa_smoother_resume(s, (pa_usec_t) msec[u] * PA_USEC_PER_MSEC, TRUE);
}
printf("%llu\t%llu\n", (unsigned long long) (x/PA_USEC_PER_MSEC), (unsigned long long) (pa_smoother_get(s, x)/PA_USEC_PER_MSEC));