diff options
author | Matthew Gregan <[email protected]> | 2012-12-04 18:55:34 -0800 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2012-12-04 18:55:34 -0800 |
commit | 91193654a4b8ed2e60cdc3ed6ad05bc55fa847f0 (patch) | |
tree | 42d5a5cff2d3db79e1106480006fbbd314348344 | |
parent | 682231bb0fea0f1f904de823f0aa3aa4851378b4 (diff) | |
download | cubeb-91193654a4b8ed2e60cdc3ed6ad05bc55fa847f0.tar.gz cubeb-91193654a4b8ed2e60cdc3ed6ad05bc55fa847f0.zip |
build fixes for VC++2010. update Makefile.am to build optimized by default.
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | test/test_sanity.c | 40 | ||||
-rw-r--r-- | test/test_tone.c | 20 |
3 files changed, 47 insertions, 15 deletions
diff --git a/Makefile.am b/Makefile.am index 930afc8..04680f4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = foreign 1.10 dist-bzip2 subdir-objects ACLOCAL_AMFLAGS = -I m4 INCLUDES = -I$(top_srcdir)/include -I. -AM_CFLAGS = -ansi -pedantic -std=c99 -Wall -Wextra -Wno-long-long -O0 -g -Wno-unused +AM_CFLAGS = -ansi -pedantic -std=c99 -Wall -Wextra -Wno-long-long -O2 -Wno-unused SUBDIRS = docs diff --git a/test/test_sanity.c b/test/test_sanity.c index f372645..798283c 100644 --- a/test/test_sanity.c +++ b/test/test_sanity.c @@ -9,13 +9,29 @@ #include <assert.h> #include <stdio.h> #include <string.h> +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#else #include <unistd.h> +#endif #define STREAM_LATENCY 100 #define STREAM_RATE 44100 #define STREAM_CHANNELS 1 #define STREAM_FORMAT CUBEB_SAMPLE_S16LE +static void +delay(unsigned int ms) +{ +#ifdef _WIN32 + Sleep(ms); +#else + sleep(ms / 1000); + usleep(ms % 1000 * 1000); +#endif +} + static int dummy; static uint64_t total_frames_written; static int delay_callback; @@ -27,7 +43,7 @@ test_data_callback(cubeb_stream * stm, void * user_ptr, void * p, long nframes) memset(p, 0, nframes * sizeof(short)); total_frames_written += nframes; if (delay_callback) { - usleep(10 * 1000); + delay(10); } return nframes; } @@ -121,7 +137,7 @@ test_init_destroy_multiple_streams(void) } static void -test_init_start_stop_destroy_multiple_streams(int early, int delay) +test_init_start_stop_destroy_multiple_streams(int early, int delay_ms) { int i; int r; @@ -154,8 +170,8 @@ test_init_start_stop_destroy_multiple_streams(int early, int delay) } } - if (delay) { - usleep(delay * 1000); + if (delay_ms) { + delay(delay_ms); } if (!early) { @@ -277,7 +293,7 @@ test_stream_position(void) r = cubeb_stream_get_position(stream, &position); assert(r == 0 && position == 0); - usleep(500000); + delay(500); r = cubeb_stream_get_position(stream, &position); assert(r == 0 && position == 0); @@ -287,7 +303,7 @@ test_stream_position(void) assert(r == 0); /* XXX let start happen */ - usleep(500000); + delay(500); /* stream should have prefilled */ assert(total_frames_written > 0); @@ -296,7 +312,7 @@ test_stream_position(void) assert(r == 0); last_position = position; - usleep(500000); + delay(500); r = cubeb_stream_get_position(stream, &position); assert(r == 0); @@ -310,7 +326,7 @@ test_stream_position(void) assert(position >= last_position); assert(position <= total_frames_written); last_position = position; - usleep(500000); + delay(500); } assert(last_position != 0); @@ -320,13 +336,13 @@ test_stream_position(void) assert(r == 0); /* XXX allow stream to settle */ - usleep(500000); + delay(500); r = cubeb_stream_get_position(stream, &position); assert(r == 0); last_position = position; - usleep(500000); + delay(500); r = cubeb_stream_get_position(stream, &position); assert(r == 0); @@ -388,7 +404,7 @@ test_drain(void) r = cubeb_stream_start(stream); assert(r == 0); - usleep(500000); + delay(500); do_drain = 1; @@ -399,7 +415,7 @@ test_drain(void) if (got_drain) { break; } - usleep(500000); + delay(500); } r = cubeb_stream_get_position(stream, &position); diff --git a/test/test_tone.c b/test/test_tone.c index f51a2dc..7e6020d 100644 --- a/test/test_tone.c +++ b/test/test_tone.c @@ -9,8 +9,13 @@ #define _XOPEN_SOURCE 500 #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <math.h> +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#else +#include <unistd.h> +#endif #include "cubeb/cubeb.h" @@ -20,6 +25,17 @@ #define M_PI 3.14159265358979323846 #endif +static void +delay(unsigned int ms) +{ +#ifdef _WIN32 + Sleep(ms); +#else + sleep(ms / 1000); + usleep(ms % 1000 * 1000); +#endif +} + /* store the phase of the generated waveform */ struct cb_user_data { long position; @@ -103,7 +119,7 @@ int main(int argc, char *argv[]) } cubeb_stream_start(stream); - usleep(500000); + delay(500); cubeb_stream_stop(stream); cubeb_stream_destroy(stream); |