summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/alsa-time-test.c2
-rw-r--r--src/tests/gtk-test.c41
-rw-r--r--src/tests/interpol-test.c42
-rw-r--r--src/tests/ipacl-test.c6
-rw-r--r--src/tests/mainloop-test.c8
-rw-r--r--src/tests/memblockq-test.c18
-rw-r--r--src/tests/mix-test.c97
-rw-r--r--src/tests/proplist-test.c14
-rw-r--r--src/tests/resampler-test.c75
-rw-r--r--src/tests/rtpoll-test.c6
-rw-r--r--src/tests/rtstutter.c2
-rw-r--r--src/tests/sigbus-test.c70
-rw-r--r--src/tests/smoother-test.c8
-rw-r--r--src/tests/thread-mainloop-test.c8
-rw-r--r--src/tests/voltest.c3
-rw-r--r--src/tests/volume-ui.py29
16 files changed, 326 insertions, 103 deletions
diff --git a/src/tests/alsa-time-test.c b/src/tests/alsa-time-test.c
index e852c3f7..233bbe64 100644
--- a/src/tests/alsa-time-test.c
+++ b/src/tests/alsa-time-test.c
@@ -23,7 +23,7 @@ int main(int argc, char *argv[]) {
int dir = 1;
struct timespec start, last_timestamp = { 0, 0 };
uint64_t start_us;
- snd_pcm_sframes_t last_avail, last_delay;
+ snd_pcm_sframes_t last_avail = 0, last_delay = 0;
struct pollfd *pollfds;
int n_pollfd;
int64_t sample_count = 0;
diff --git a/src/tests/gtk-test.c b/src/tests/gtk-test.c
index f82aca58..6470e484 100644
--- a/src/tests/gtk-test.c
+++ b/src/tests/gtk-test.c
@@ -29,12 +29,38 @@
#include <pulse/context.h>
#include <pulse/glib-mainloop.h>
+pa_context *ctxt;
+pa_glib_mainloop *m;
+
+static void context_state_callback(pa_context *c, void *userdata);
+
+static void connect(void) {
+ int r;
+
+ ctxt = pa_context_new(pa_glib_mainloop_get_api(m), NULL);
+ g_assert(ctxt);
+
+ r = pa_context_connect(ctxt, NULL, PA_CONTEXT_NOAUTOSPAWN|PA_CONTEXT_NOFAIL, NULL);
+ g_assert(r == 0);
+
+ pa_context_set_state_callback(ctxt, context_state_callback, NULL);
+}
+
+static void context_state_callback(pa_context *c, void *userdata) {
+ switch (pa_context_get_state(c)) {
+ case PA_CONTEXT_FAILED:
+ pa_context_unref(ctxt);
+ ctxt = NULL;
+ connect();
+ break;
+ default:
+ break;
+ }
+}
+
int main(int argc, char *argv[]) {
- pa_context *c;
- pa_glib_mainloop *m;
GtkWidget *window;
- int r;
gtk_init(&argc, &argv);
@@ -49,15 +75,10 @@ int main(int argc, char *argv[]) {
m = pa_glib_mainloop_new(NULL);
g_assert(m);
- c = pa_context_new(pa_glib_mainloop_get_api(m), NULL);
- g_assert(c);
-
- r = pa_context_connect(c, NULL, 0, NULL);
- g_assert(r == 0);
-
+ connect();
gtk_main();
- pa_context_unref(c);
+ pa_context_unref(ctxt);
pa_glib_mainloop_free(m);
return 0;
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 */
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 d8926233..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
@@ -46,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;
- read(fd, &c, sizeof(c));
+ (void) read(fd, &c, sizeof(c));
fprintf(stderr, "IO EVENT: %c\n", c < 32 ? '.' : c);
a->defer_enable(de, 1);
}
@@ -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/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/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/proplist-test.c b/src/tests/proplist-test.c
index 3e723561..27a0d3fe 100644
--- a/src/tests/proplist-test.c
+++ b/src/tests/proplist-test.c
@@ -27,11 +27,14 @@
#include <pulse/xmalloc.h>
#include <pulsecore/macro.h>
#include <pulsecore/core-util.h>
+#include <pulsecore/modargs.h>
int main(int argc, char*argv[]) {
+ pa_modargs *ma;
pa_proplist *a, *b, *c, *d;
char *s, *t, *u, *v;
const char *text;
+ const char *x[] = { "foo", NULL };
a = pa_proplist_new();
pa_assert_se(pa_proplist_sets(a, PA_PROP_MEDIA_TITLE, "Brandenburgische Konzerte") == 0);
@@ -78,5 +81,16 @@ int main(int argc, char*argv[]) {
printf("%s\n", v);
pa_xfree(v);
+ pa_assert_se(ma = pa_modargs_new("foo='foobar=waldo foo2=\"lj\\\\\"dhflh\" foo3=\\'kjlskj\\\\\\'\\''", x));
+ pa_assert_se(a = pa_proplist_new());
+
+ pa_assert_se(pa_modargs_get_proplist(ma, "foo", a, PA_UPDATE_REPLACE) >= 0);
+
+ printf("%s\n", v = pa_proplist_to_string(a));
+ pa_xfree(v);
+
+ pa_proplist_free(a);
+ pa_modargs_free(ma);
+
return 0;
}
diff --git a/src/tests/resampler-test.c b/src/tests/resampler-test.c
index 6b4a64ca..7236265a 100644
--- a/src/tests/resampler-test.c
+++ b/src/tests/resampler-test.c
@@ -34,12 +34,6 @@
#include <liboil/liboil.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;
@@ -54,7 +48,7 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
uint8_t *u = d;
for (i = 0; i < chunk->length / pa_frame_size(ss); i++)
- printf("0x%02x ", *(u++));
+ printf(" 0x%02x ", *(u++));
break;
}
@@ -64,7 +58,7 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
uint16_t *u = d;
for (i = 0; i < chunk->length / pa_frame_size(ss); i++)
- printf("0x%04x ", *(u++));
+ printf(" 0x%04x ", *(u++));
break;
}
@@ -79,18 +73,40 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
break;
}
+ case PA_SAMPLE_S24_32NE:
+ case PA_SAMPLE_S24_32RE: {
+ uint32_t *u = d;
+
+ for (i = 0; i < chunk->length / pa_frame_size(ss); i++)
+ printf("0x%08x ", *(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("%1.3g ", ss->format == PA_SAMPLE_FLOAT32NE ? *u : swap_float(*u));
+ printf("%4.3g ", ss->format == PA_SAMPLE_FLOAT32NE ? *u : PA_FLOAT32_SWAP(*u));
u++;
}
break;
}
+ case PA_SAMPLE_S24LE:
+ case PA_SAMPLE_S24BE: {
+ uint8_t *u = d;
+
+ for (i = 0; i < chunk->length / pa_frame_size(ss); i++) {
+ printf(" 0x%06x ", PA_READ24NE(u));
+ u += pa_frame_size(ss);
+ }
+
+ break;
+ }
+
default:
pa_assert_not_reached();
}
@@ -162,6 +178,23 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) {
break;
}
+ case PA_SAMPLE_S24_32NE:
+ case PA_SAMPLE_S24_32RE: {
+ uint32_t *u = d;
+
+ u[0] = 0x000001;
+ u[1] = 0xFF0002;
+ u[2] = 0x7F0003;
+ u[3] = 0x800004;
+ u[4] = 0x9f0005;
+ u[5] = 0x3f0006;
+ u[6] = 0x107;
+ u[7] = 0xF00008;
+ u[8] = 0x2009;
+ u[9] = 0x210A;
+ break;
+ }
+
case PA_SAMPLE_FLOAT32NE:
case PA_SAMPLE_FLOAT32RE: {
float *u = d;
@@ -179,11 +212,28 @@ 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(u[i]);
+ u[i] = PA_FLOAT32_SWAP(u[i]);
break;
}
+ case PA_SAMPLE_S24NE:
+ case PA_SAMPLE_S24RE: {
+ uint8_t *u = d;
+
+ PA_WRITE24NE(u, 0x000001);
+ PA_WRITE24NE(u+3, 0xFF0002);
+ PA_WRITE24NE(u+6, 0x7F0003);
+ PA_WRITE24NE(u+9, 0x800004);
+ PA_WRITE24NE(u+12, 0x9f0005);
+ PA_WRITE24NE(u+15, 0x3f0006);
+ PA_WRITE24NE(u+18, 0x107);
+ PA_WRITE24NE(u+21, 0xF00008);
+ PA_WRITE24NE(u+24, 0x2009);
+ PA_WRITE24NE(u+27, 0x210A);
+ break;
+ }
+
default:
pa_assert_not_reached();
}
@@ -211,7 +261,6 @@ int main(int argc, char *argv[]) {
for (a.format = 0; a.format < PA_SAMPLE_MAX; a.format ++) {
for (b.format = 0; b.format < PA_SAMPLE_MAX; b.format ++) {
-
pa_resampler *forth, *back;
pa_memchunk i, j, k;
@@ -229,14 +278,18 @@ int main(int argc, char *argv[]) {
pa_resampler_run(forth, &i, &j);
pa_resampler_run(back, &j, &k);
+ printf("before: ");
dump_block(&a, &i);
+ printf("after : ");
dump_block(&b, &j);
+ printf("reverse: ");
dump_block(&a, &k);
pa_memblock_unref(j.memblock);
pa_memblock_unref(k.memblock);
pa_volume_memchunk(&i, &a, &v);
+ printf("volume: ");
dump_block(&a, &i);
pa_memblock_unref(i.memblock);
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 f04d43af..a4b5d596 100644
--- a/src/tests/rtstutter.c
+++ b/src/tests/rtstutter.c
@@ -93,6 +93,8 @@ static void* work(void *p) {
int main(int argc, char*argv[]) {
unsigned n;
+ pa_log_set_level(PA_LOG_DEBUG);
+
srand((unsigned) time(NULL));
if (argc >= 3) {
diff --git a/src/tests/sigbus-test.c b/src/tests/sigbus-test.c
new file mode 100644
index 00000000..4b9ca840
--- /dev/null
+++ b/src/tests/sigbus-test.c
@@ -0,0 +1,70 @@
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2009 Lennart Poettering
+
+ 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 <fcntl.h>
+#include <sys/mman.h>
+
+#include <pulsecore/memtrap.h>
+#include <pulsecore/core-util.h>
+
+int main(int argc, char *argv[]) {
+ void *p;
+ int fd;
+ pa_memtrap *m;
+
+ pa_log_set_level(PA_LOG_DEBUG);
+ pa_memtrap_install();
+
+ /* Create the memory map */
+ pa_assert_se((fd = open("sigbus-test-map", O_RDWR|O_TRUNC|O_CREAT, 0660)) >= 0);
+ pa_assert_se(unlink("sigbus-test-map") == 0);
+ pa_assert_se(ftruncate(fd, PA_PAGE_SIZE) >= 0);
+ pa_assert_se((p = mmap(NULL, PA_PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) != MAP_FAILED);
+
+ /* Register memory map */
+ m = pa_memtrap_add(p, PA_PAGE_SIZE);
+
+ /* Use memory map */
+ pa_snprintf(p, PA_PAGE_SIZE, "This is a test that should work fine.");
+
+ /* Verify memory map */
+ pa_log("Let's see if this worked: %s", (char*) p);
+ pa_log("And memtrap says it is good: %s", pa_yes_no(pa_memtrap_is_good(m)));
+
+ /* Invalidate mapping */
+ pa_assert_se(ftruncate(fd, 0) >= 0);
+
+ /* Use memory map */
+ pa_snprintf(p, PA_PAGE_SIZE, "This is a test that should fail but get caught.");
+
+ /* Verify memory map */
+ pa_log("Let's see if this worked: %s", (char*) p);
+ pa_log("And memtrap says it is good: %s", pa_yes_no(pa_memtrap_is_good(m)));
+
+ pa_memtrap_remove(m);
+ munmap(p, PA_PAGE_SIZE);
+
+ return 0;
+}
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));
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);
diff --git a/src/tests/voltest.c b/src/tests/voltest.c
index 0c6d2ea6..2dcfa53c 100644
--- a/src/tests/voltest.c
+++ b/src/tests/voltest.c
@@ -9,6 +9,9 @@ int main(int argc, char *argv[]) {
float b;
pa_channel_map map;
+ printf("Attenuation of sample 1 against 32767: %g dB\n", 20.0*log10(1.0/32767.0));
+ printf("Smallest possible attenutation > 0 applied to 32767: %li\n", lrint(32767.0*pa_sw_volume_to_linear(1)));
+
for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 256) {
double dB = pa_sw_volume_to_dB(v);
diff --git a/src/tests/volume-ui.py b/src/tests/volume-ui.py
index 6dc1c47d..7909b801 100644
--- a/src/tests/volume-ui.py
+++ b/src/tests/volume-ui.py
@@ -111,6 +111,10 @@ class CVolume(Structure):
_set_fade.restype = c_void_p
_set_fade.argtypes = [c_void_p, c_void_p, c_float]
+ _to_dB = libpulse.pa_sw_volume_to_dB
+ _to_dB.restype = c_double
+ _to_dB.argytpes = [c_uint32]
+
def snprint(this):
s = create_string_buffer(320)
r = this._snprint(s, len(s), byref(this))
@@ -138,6 +142,12 @@ class CVolume(Structure):
def set_fade(this, cm, f):
return this._set_fade(byref(this), byref(cm), f)
+ def to_dB(this, channel = None):
+ if channel is None:
+ return this._to_dB(this.max())
+
+ return this._to_dB(this.values[channel])
+
cm = ChannelMap()
if len(sys.argv) > 1:
@@ -149,7 +159,7 @@ v = CVolume()
v.channels = cm.channels
for i in range(cm.channels):
- v.values[i] = 65536/2
+ v.values[i] = 65536
title = cm.to_pretty_name()
if title is None:
@@ -163,6 +173,7 @@ vbox = gtk.VBox(spacing=6)
channel_labels = {}
channel_scales = {}
+channel_dB_labels = {}
def update_volume(update_channels = True, update_fade = True, update_balance = True, update_scale = True):
if update_channels:
@@ -178,6 +189,11 @@ def update_volume(update_channels = True, update_fade = True, update_balance = T
if update_fade:
fade_scale.set_value(v.get_fade(cm))
+ for i in range(cm.channels):
+ channel_dB_labels[i].set_label("%0.2f dB" % v.to_dB(i))
+
+ value_dB_label.set_label("%0.2f dB" % v.to_dB())
+
def fade_value_changed(fs):
v.set_fade(cm, fade_scale.get_value())
update_volume(update_fade = False)
@@ -200,19 +216,26 @@ for i in range(cm.channels):
vbox.pack_start(channel_labels[i], expand=False, fill=True)
channel_scales[i] = gtk.HScale()
- channel_scales[i].set_range(0, 65536)
+ channel_scales[i].set_range(0, 65536*3/2)
channel_scales[i].set_digits(0)
channel_scales[i].set_value_pos(gtk.POS_RIGHT)
vbox.pack_start(channel_scales[i], expand=False, fill=True)
+ channel_dB_labels[i] = gtk.Label("-xxx dB")
+ channel_dB_labels[i].set_alignment(1, 1)
+ vbox.pack_start(channel_dB_labels[i], expand=False, fill=True)
+
value_label = gtk.Label("Value")
value_label.set_alignment(0, .5)
vbox.pack_start(value_label, expand=False, fill=True)
value_scale = gtk.HScale()
-value_scale.set_range(0, 65536)
+value_scale.set_range(0, 65536*3/2)
value_scale.set_value_pos(gtk.POS_RIGHT)
value_scale.set_digits(0)
vbox.pack_start(value_scale, expand=False, fill=True)
+value_dB_label = gtk.Label("-xxx dB")
+value_dB_label.set_alignment(1, 1)
+vbox.pack_start(value_dB_label, expand=False, fill=True)
balance_label = gtk.Label("Balance")
balance_label.set_alignment(0, .5)