summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/channelmap-test.c2
-rw-r--r--src/tests/cpulimit-test.c4
-rw-r--r--src/tests/envelope-test.c12
-rw-r--r--src/tests/lock-autospawn-test.c109
-rw-r--r--src/tests/mainloop-test.c2
-rw-r--r--src/tests/mcalign-test.c10
-rw-r--r--src/tests/mix-test.c20
-rw-r--r--src/tests/pacat-simple.c4
-rw-r--r--src/tests/parec-simple.c7
-rw-r--r--src/tests/resampler-test.c20
-rw-r--r--src/tests/rtstutter.c14
-rw-r--r--src/tests/smoother-test.c2
-rw-r--r--src/tests/stripnul.c6
-rw-r--r--src/tests/strlist-test.c2
-rw-r--r--src/tests/sync-playback.c2
-rw-r--r--src/tests/thread-mainloop-test.c2
-rw-r--r--src/tests/voltest.c2
17 files changed, 166 insertions, 54 deletions
diff --git a/src/tests/channelmap-test.c b/src/tests/channelmap-test.c
index 9c234602..12b39f10 100644
--- a/src/tests/channelmap-test.c
+++ b/src/tests/channelmap-test.c
@@ -4,7 +4,7 @@
#include <pulse/channelmap.h>
#include <pulse/gccmacro.h>
-int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
+int main(int argc, char *argv[]) {
char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
pa_channel_map map, map2;
diff --git a/src/tests/cpulimit-test.c b/src/tests/cpulimit-test.c
index b7145e8a..fdc0162e 100644
--- a/src/tests/cpulimit-test.c
+++ b/src/tests/cpulimit-test.c
@@ -42,7 +42,7 @@ static time_t start;
#ifdef TEST2
-static void func(pa_mainloop_api *m, PA_GCC_UNUSED pa_signal_event *e, PA_GCC_UNUSED int sig, PA_GCC_UNUSED void *userdata) {
+static void func(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) {
time_t now;
time(&now);
@@ -55,7 +55,7 @@ static void func(pa_mainloop_api *m, PA_GCC_UNUSED pa_signal_event *e, PA_GCC_UN
#endif
-int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
+int main(int argc, char *argv[]) {
pa_mainloop *m;
m = pa_mainloop_new();
diff --git a/src/tests/envelope-test.c b/src/tests/envelope-test.c
index 9f914553..d71eff1c 100644
--- a/src/tests/envelope-test.c
+++ b/src/tests/envelope-test.c
@@ -40,7 +40,7 @@ const pa_envelope_def ramp_down = {
.n_points = 2,
.points_x = { 100*PA_USEC_PER_MSEC, 300*PA_USEC_PER_MSEC },
.points_y = {
- .f = { 1.0, 0.2 },
+ .f = { 1.0f, 0.2f },
.i = { 0x10000, 0x10000/5 }
}
};
@@ -49,7 +49,7 @@ const pa_envelope_def ramp_up = {
.n_points = 2,
.points_x = { 100*PA_USEC_PER_MSEC, 300*PA_USEC_PER_MSEC },
.points_y = {
- .f = { 0.2, 1.0 },
+ .f = { 0.2f, 1.0f },
.i = { 0x10000/5, 0x10000 }
}
};
@@ -58,7 +58,7 @@ const pa_envelope_def ramp_down2 = {
.n_points = 2,
.points_x = { 50*PA_USEC_PER_MSEC, 900*PA_USEC_PER_MSEC },
.points_y = {
- .f = { 0.8, 0.7 },
+ .f = { 0.8f, 0.7f },
.i = { 0x10000*4/5, 0x10000*7/10 }
}
};
@@ -67,7 +67,7 @@ const pa_envelope_def ramp_up2 = {
.n_points = 2,
.points_x = { 50*PA_USEC_PER_MSEC, 900*PA_USEC_PER_MSEC },
.points_y = {
- .f = { 0.7, 0.9 },
+ .f = { 0.7f, 0.9f },
.i = { 0x10000*7/10, 0x10000*9/10 }
}
};
@@ -140,7 +140,7 @@ static pa_memblock * generate_block(pa_mempool *pool, const pa_sample_spec *ss)
unsigned n_samples;
block = pa_memblock_new(pool, pa_bytes_per_second(ss));
- n_samples = pa_memblock_get_length(block) / pa_sample_size(ss);
+ n_samples = (unsigned) (pa_memblock_get_length(block) / pa_sample_size(ss));
d = pa_memblock_acquire(block);
@@ -171,7 +171,7 @@ static pa_memblock * generate_block(pa_mempool *pool, const pa_sample_spec *ss)
float *f;
for (f = d; n_samples > 0; n_samples--, f++)
- *f = PA_MAYBE_FLOAT32_SWAP(ss->format == PA_SAMPLE_FLOAT32RE, 1.0);
+ *f = PA_MAYBE_FLOAT32_SWAP(ss->format == PA_SAMPLE_FLOAT32RE, 1.0f);
break;
}
diff --git a/src/tests/lock-autospawn-test.c b/src/tests/lock-autospawn-test.c
new file mode 100644
index 00000000..cb3dc87c
--- /dev/null
+++ b/src/tests/lock-autospawn-test.c
@@ -0,0 +1,109 @@
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2008 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 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 <sys/poll.h>
+#include <string.h>
+
+#include <pulsecore/macro.h>
+#include <pulsecore/thread.h>
+#include <pulse/lock-autospawn.h>
+#include <pulse/util.h>
+
+static void thread_func(void*k) {
+ pa_assert_se(pa_autospawn_lock_init() >= 0);
+
+ pa_log("%i, Trying to acquire lock.", PA_PTR_TO_INT(k));
+
+ pa_assert_se(pa_autospawn_lock_acquire(TRUE) > 0);
+
+ pa_log("%i, Got the lock!, Sleeping for 5s", PA_PTR_TO_INT(k));
+
+ pa_msleep(5000);
+
+ pa_log("%i, Releasing", PA_PTR_TO_INT(k));
+
+ pa_autospawn_lock_release();
+
+ pa_autospawn_lock_done(FALSE);
+}
+
+static void thread_func2(void *k) {
+ int fd;
+
+ pa_assert_se((fd = pa_autospawn_lock_init()) >= 0);
+
+ pa_log("%i, Trying to acquire lock.", PA_PTR_TO_INT(k));
+
+ for (;;) {
+ struct pollfd pollfd;
+ int j;
+
+ if ((j = pa_autospawn_lock_acquire(FALSE)) > 0)
+ break;
+
+ pa_assert(j == 0);
+
+ memset(&pollfd, 0, sizeof(pollfd));
+ pollfd.fd = fd;
+ pollfd.events = POLLIN;
+
+ pa_assert_se(poll(&pollfd, 1, -1) == 1);
+
+ pa_log("%i, woke up", PA_PTR_TO_INT(k));
+ }
+
+ pa_log("%i, Got the lock!, Sleeping for 5s", PA_PTR_TO_INT(k));
+
+ pa_msleep(5000);
+
+ pa_log("%i, Releasing", PA_PTR_TO_INT(k));
+
+ pa_autospawn_lock_release();
+
+ pa_autospawn_lock_done(FALSE);
+}
+
+int main(int argc, char**argv) {
+ pa_thread *a, *b, *c, *d;
+
+ pa_assert_se((a = pa_thread_new(thread_func, PA_INT_TO_PTR(1))));
+ pa_assert_se((b = pa_thread_new(thread_func2, PA_INT_TO_PTR(2))));
+ pa_assert_se((c = pa_thread_new(thread_func2, PA_INT_TO_PTR(3))));
+ pa_assert_se((d = pa_thread_new(thread_func, PA_INT_TO_PTR(4))));
+
+ pa_thread_join(a);
+ pa_thread_join(b);
+ pa_thread_join(c);
+ pa_thread_join(d);
+
+ pa_thread_free(a);
+ pa_thread_free(b);
+ pa_thread_free(c);
+ pa_thread_free(d);
+
+ pa_log("End");
+
+ return 0;
+}
diff --git a/src/tests/mainloop-test.c b/src/tests/mainloop-test.c
index 9fa2e466..2580fa72 100644
--- a/src/tests/mainloop-test.c
+++ b/src/tests/mainloop-test.c
@@ -66,7 +66,7 @@ static void tcb(pa_mainloop_api*a, pa_time_event *e, const struct timeval *tv, v
#endif
}
-int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
+int main(int argc, char *argv[]) {
pa_mainloop_api *a;
pa_io_event *ioe;
pa_time_event *te;
diff --git a/src/tests/mcalign-test.c b/src/tests/mcalign-test.c
index 9e358359..c0665822 100644
--- a/src/tests/mcalign-test.c
+++ b/src/tests/mcalign-test.c
@@ -36,7 +36,7 @@
/* A simple program for testing pa_mcalign */
-int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
+int main(int argc, char *argv[]) {
pa_mempool *p;
pa_mcalign *a;
pa_memchunk c;
@@ -47,7 +47,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
pa_memchunk_reset(&c);
- srand(time(NULL));
+ srand((unsigned) time(NULL));
for (;;) {
ssize_t r;
@@ -62,7 +62,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
l = pa_memblock_get_length(c.memblock) - c.index;
- l = l <= 1 ? l : rand() % (l-1) +1 ;
+ l = l <= 1 ? l : (size_t) rand() % (l-1) +1;
p = pa_memblock_acquire(c.memblock);
@@ -74,11 +74,11 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
pa_memblock_release(c.memblock);
- c.length = r;
+ c.length = (size_t) r;
pa_mcalign_push(a, &c);
fprintf(stderr, "Read %ld bytes\n", (long)r);
- c.index += r;
+ c.index += (size_t) r;
if (c.index >= pa_memblock_get_length(c.memblock)) {
pa_memblock_unref(c.memblock);
diff --git a/src/tests/mix-test.c b/src/tests/mix-test.c
index f3f6f829..544121fd 100644
--- a/src/tests/mix-test.c
+++ b/src/tests/mix-test.c
@@ -166,16 +166,16 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) {
case PA_SAMPLE_FLOAT32RE: {
float *u = d;
- u[0] = 0.0;
- u[1] = -1.0;
- u[2] = 1.0;
- u[3] = 4711;
- u[4] = 0.222;
- u[5] = 0.33;
- u[6] = -.3;
- u[7] = 99;
- u[8] = -0.555;
- u[9] = -.123;
+ 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)
for (i = 0; i < 10; i++)
diff --git a/src/tests/pacat-simple.c b/src/tests/pacat-simple.c
index b26e4b68..ffe3176a 100644
--- a/src/tests/pacat-simple.c
+++ b/src/tests/pacat-simple.c
@@ -33,7 +33,7 @@
#define BUFSIZE 1024
-int main(PA_GCC_UNUSED int argc, char*argv[]) {
+int main(int argc, char*argv[]) {
/* The Sample format to use */
static const pa_sample_spec ss = {
@@ -94,7 +94,7 @@ int main(PA_GCC_UNUSED int argc, char*argv[]) {
}
/* ... and play it */
- if (pa_simple_write(s, buf, r, &error) < 0) {
+ if (pa_simple_write(s, buf, (size_t) r, &error) < 0) {
fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", pa_strerror(error));
goto finish;
}
diff --git a/src/tests/parec-simple.c b/src/tests/parec-simple.c
index 6c0d529b..0312005d 100644
--- a/src/tests/parec-simple.c
+++ b/src/tests/parec-simple.c
@@ -47,13 +47,13 @@ static ssize_t loop_write(int fd, const void*data, size_t size) {
ret += r;
data = (const uint8_t*) data + r;
- size -= r;
+ size -= (size_t) r;
}
return ret;
}
-int main(PA_GCC_UNUSED int argc, char*argv[]) {
+int main(int argc, char*argv[]) {
/* The sample type to use */
static const pa_sample_spec ss = {
.format = PA_SAMPLE_S16LE,
@@ -80,6 +80,9 @@ int main(PA_GCC_UNUSED int argc, char*argv[]) {
goto finish;
}
+ if (r == 0)
+ break;
+
/* And write it to STDOUT */
if ((r = loop_write(STDOUT_FILENO, buf, sizeof(buf))) <= 0) {
fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno));
diff --git a/src/tests/resampler-test.c b/src/tests/resampler-test.c
index 1a20be2c..6959127b 100644
--- a/src/tests/resampler-test.c
+++ b/src/tests/resampler-test.c
@@ -166,16 +166,16 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) {
case PA_SAMPLE_FLOAT32RE: {
float *u = d;
- u[0] = 0.0;
- u[1] = -1.0;
- u[2] = 1.0;
- u[3] = 4711;
- u[4] = 0.222;
- u[5] = 0.33;
- u[6] = -.3;
- u[7] = 99;
- u[8] = -0.555;
- u[9] = -.123;
+ 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)
for (i = 0; i < 10; i++)
diff --git a/src/tests/rtstutter.c b/src/tests/rtstutter.c
index 91e85c36..6b0cb8f7 100644
--- a/src/tests/rtstutter.c
+++ b/src/tests/rtstutter.c
@@ -52,7 +52,7 @@ static void* work(void *p) {
pa_assert_se(pthread_setschedparam(pthread_self(), SCHED_FIFO, &param) == 0);
CPU_ZERO(&mask);
- CPU_SET(PA_PTR_TO_INT(p), &mask);
+ CPU_SET((size_t) PA_PTR_TO_INT(p), &mask);
pa_assert_se(pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) == 0);
for (;;) {
@@ -65,17 +65,17 @@ static void* work(void *p) {
pa_assert_se(clock_gettime(CLOCK_REALTIME, &end) == 0);
nsec =
- (uint64_t) ((((double) rand())*(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) +
- (uint64_t) (msec_lower*PA_NSEC_PER_MSEC);
+ (uint64_t) ((((double) rand())*(double)(msec_upper-msec_lower)*PA_NSEC_PER_MSEC)/RAND_MAX) +
+ (uint64_t) ((uint64_t) msec_lower*PA_NSEC_PER_MSEC);
pa_log_notice("CPU%i: Freezing for %ims", PA_PTR_TO_INT(p), (int) (nsec/PA_NSEC_PER_MSEC));
- end.tv_sec += nsec / PA_NSEC_PER_SEC;
- end.tv_nsec += nsec % PA_NSEC_PER_SEC;
+ end.tv_sec += (time_t) (nsec / PA_NSEC_PER_SEC);
+ end.tv_nsec += (long int) (nsec % PA_NSEC_PER_SEC);
while ((pa_usec_t) end.tv_nsec > PA_NSEC_PER_SEC) {
end.tv_sec++;
- end.tv_nsec -= PA_NSEC_PER_SEC;
+ end.tv_nsec -= (long int) PA_NSEC_PER_SEC;
}
do {
@@ -88,7 +88,7 @@ static void* work(void *p) {
int main(int argc, char*argv[]) {
int n;
- srand(time(NULL));
+ srand((unsigned) time(NULL));
if (argc >= 3) {
msec_lower = atoi(argv[1]);
diff --git a/src/tests/smoother-test.c b/src/tests/smoother-test.c
index b78f3c91..15700ec2 100644
--- a/src/tests/smoother-test.c
+++ b/src/tests/smoother-test.c
@@ -64,7 +64,7 @@ int main(int argc, char*argv[]) {
for (x = 0, u = 0; x < PA_USEC_PER_SEC * 10; x += PA_USEC_PER_MSEC) {
while (u < PA_ELEMENTSOF(msec) && (pa_usec_t) msec[u]*PA_USEC_PER_MSEC < x) {
- pa_smoother_put(s, msec[u]*PA_USEC_PER_MSEC, msec[u+1]*PA_USEC_PER_MSEC);
+ 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;
}
diff --git a/src/tests/stripnul.c b/src/tests/stripnul.c
index 0ab06776..2b8aa083 100644
--- a/src/tests/stripnul.c
+++ b/src/tests/stripnul.c
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
uint8_t *zero;
pa_assert_se(argc >= 2);
- pa_assert_se((granularity = atoi(argv[1])) >= 1);
+ pa_assert_se((granularity = (size_t) atoi(argv[1])) >= 1);
pa_assert_se((i = (argc >= 3) ? fopen(argv[2], "r") : stdin));
pa_assert_se((o = (argc >= 4) ? fopen(argv[3], "w") : stdout));
@@ -53,11 +53,11 @@ int main(int argc, char *argv[]) {
if (found)
pa_assert_se(fwrite(buffer, granularity, k, o) == k);
else {
- for (p = buffer; (p-buffer)/granularity < k; p += granularity)
+ for (p = buffer; ((size_t) (p-buffer)/granularity) < k; p += granularity)
if (memcmp(p, zero, granularity)) {
size_t left;
found = TRUE;
- left = k - (p-buffer)/granularity;
+ left = (size_t) (k - (size_t) (p-buffer)/granularity);
pa_assert_se(fwrite(p, granularity, left, o) == left);
break;
}
diff --git a/src/tests/strlist-test.c b/src/tests/strlist-test.c
index 2bd1645c..10f370c2 100644
--- a/src/tests/strlist-test.c
+++ b/src/tests/strlist-test.c
@@ -5,7 +5,7 @@
#include <pulsecore/strlist.h>
-int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char* argv[]) {
+int main(int argc, char* argv[]) {
char *t, *u;
pa_strlist *l = NULL;
diff --git a/src/tests/sync-playback.c b/src/tests/sync-playback.c
index 7e364685..42c479a1 100644
--- a/src/tests/sync-playback.c
+++ b/src/tests/sync-playback.c
@@ -89,7 +89,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
fprintf(stderr, "Writing data to stream %i.\n", i);
- r = pa_stream_write(s, data, sizeof(data), nop_free_cb, sizeof(data) * i, PA_SEEK_ABSOLUTE);
+ r = pa_stream_write(s, data, sizeof(data), nop_free_cb, (int64_t) sizeof(data) * (int64_t) i, PA_SEEK_ABSOLUTE);
assert(r == 0);
/* Be notified when this stream is drained */
diff --git a/src/tests/thread-mainloop-test.c b/src/tests/thread-mainloop-test.c
index 7a62f85a..263cd57d 100644
--- a/src/tests/thread-mainloop-test.c
+++ b/src/tests/thread-mainloop-test.c
@@ -39,7 +39,7 @@ static void tcb(pa_mainloop_api*a, pa_time_event *e, const struct timeval *tv, v
fprintf(stderr, "TIME EVENT END\n");
}
-int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
+int main(int argc, char *argv[]) {
pa_mainloop_api *a;
pa_threaded_mainloop *m;
struct timeval tv;
diff --git a/src/tests/voltest.c b/src/tests/voltest.c
index d2c0ff69..5b26c0f1 100644
--- a/src/tests/voltest.c
+++ b/src/tests/voltest.c
@@ -3,7 +3,7 @@
#include <pulse/volume.h>
#include <pulse/gccmacro.h>
-int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char *argv[]) {
+int main(int argc, char *argv[]) {
pa_volume_t v;
for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 256) {