aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Gregan <[email protected]>2012-12-01 12:18:30 +1300
committerMatthew Gregan <[email protected]>2012-12-01 12:18:30 +1300
commitd2c45250a59c20a16427be0f1eb592b5176f43df (patch)
treeceed26993fc5eed2d40fd4c79df6fa0089cb4038
parent98769a7861b067125a76c97ddb51c5db8f528b75 (diff)
downloadcubeb-d2c45250a59c20a16427be0f1eb592b5176f43df.tar.gz
cubeb-d2c45250a59c20a16427be0f1eb592b5176f43df.zip
changes to support building with MinGW. fixes #10.
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac1
-rw-r--r--src/cubeb_winmm.c13
-rw-r--r--test/test_sanity.c16
-rw-r--r--test/test_tone.c4
6 files changed, 27 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index 4a91773..1f51808 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,5 +37,7 @@ src/.dirstamp
src/libcubeb.la
stamp-h1
test/test_sanity
+test/test_sanity.exe
test/test_tone
+test/test_tone.exe
include/cubeb/cubeb-stdint.h
diff --git a/Makefile.am b/Makefile.am
index 7ac907f..86da66f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,15 +49,15 @@ EXTRA_src_libcubeb_la_SOURCES = \
cubeb_sndio.c cubeb_directsound.c \
cubeb_winmm.c cubeb_opensl.c
-src_libcubeb_la_LDFLAGS = -pthread -export-symbols-regex '^cubeb_' $(platform_lib)
+src_libcubeb_la_LDFLAGS = -pthread -export-symbols-regex '^cubeb_' $(platform_lib) -no-undefined
noinst_PROGRAMS = test/test_sanity test/test_tone
test_test_sanity_SOURCES = test/test_sanity.c
-test_test_sanity_LDADD = -lm src/libcubeb.la
+test_test_sanity_LDADD = -lm src/libcubeb.la $(platform_lib)
test_test_tone_SOURCES = test/test_tone.c
-test_test_tone_LDADD = -lm src/libcubeb.la
+test_test_tone_LDADD = -lm src/libcubeb.la $(platform_lib)
TESTS = test/test_sanity
diff --git a/configure.ac b/configure.ac
index d86a29e..530bb6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,7 @@ elif test "x$ac_cv_header_windows_h" = "xyes"; then
# platform_api="dsound"
# else
platform_api="wave"
+ platform_lib="-lwinmm"
# fi
fi
AM_CONDITIONAL([PULSE], [test ${platform_api} = "pulse"])
diff --git a/src/cubeb_winmm.c b/src/cubeb_winmm.c
index 0f7a37c..9615ef7 100644
--- a/src/cubeb_winmm.c
+++ b/src/cubeb_winmm.c
@@ -5,6 +5,10 @@
* accompanying file LICENSE for details.
*/
#undef NDEBUG
+#define __MSVCRT_VERSION__ 0x0700
+#define WINVER 0x0501
+#define WIN32_LEAN_AND_MEAN
+#include <malloc.h>
#include <assert.h>
#include <windows.h>
#include <mmreg.h>
@@ -13,6 +17,11 @@
#include <stdlib.h>
#include "cubeb/cubeb.h"
+/* This is missing from the MinGW headers. Use a safe fallback. */
+#ifndef MEMORY_ALLOCATION_ALIGNMENT
+#define MEMORY_ALLOCATION_ALIGNMENT 16
+#endif
+
#define CUBEB_STREAM_MAX 32
#define NBUFS 4
@@ -33,7 +42,7 @@ struct cubeb {
PSLIST_HEADER work;
CRITICAL_SECTION lock;
unsigned int active_streams;
- int minimum_latency;
+ unsigned int minimum_latency;
};
struct cubeb_stream {
@@ -191,7 +200,7 @@ cubeb_buffer_callback(HWAVEOUT waveout, UINT msg, DWORD_PTR user_ptr, DWORD_PTR
SetEvent(stm->context->event);
}
-static int
+static unsigned int
calculate_minimum_latency(void)
{
OSVERSIONINFOEX osvi;
diff --git a/test/test_sanity.c b/test/test_sanity.c
index 1f22efd..f372645 100644
--- a/test/test_sanity.c
+++ b/test/test_sanity.c
@@ -277,7 +277,7 @@ test_stream_position(void)
r = cubeb_stream_get_position(stream, &position);
assert(r == 0 && position == 0);
- sleep(1);
+ usleep(500000);
r = cubeb_stream_get_position(stream, &position);
assert(r == 0 && position == 0);
@@ -287,7 +287,7 @@ test_stream_position(void)
assert(r == 0);
/* XXX let start happen */
- sleep(1);
+ usleep(500000);
/* stream should have prefilled */
assert(total_frames_written > 0);
@@ -296,7 +296,7 @@ test_stream_position(void)
assert(r == 0);
last_position = position;
- sleep(1);
+ usleep(500000);
r = cubeb_stream_get_position(stream, &position);
assert(r == 0);
@@ -310,7 +310,7 @@ test_stream_position(void)
assert(position >= last_position);
assert(position <= total_frames_written);
last_position = position;
- sleep(1);
+ usleep(500000);
}
assert(last_position != 0);
@@ -320,13 +320,13 @@ test_stream_position(void)
assert(r == 0);
/* XXX allow stream to settle */
- sleep(1);
+ usleep(500000);
r = cubeb_stream_get_position(stream, &position);
assert(r == 0);
last_position = position;
- sleep(1);
+ usleep(500000);
r = cubeb_stream_get_position(stream, &position);
assert(r == 0);
@@ -388,7 +388,7 @@ test_drain(void)
r = cubeb_stream_start(stream);
assert(r == 0);
- sleep(1);
+ usleep(500000);
do_drain = 1;
@@ -399,7 +399,7 @@ test_drain(void)
if (got_drain) {
break;
}
- sleep(1);
+ usleep(500000);
}
r = cubeb_stream_get_position(stream, &position);
diff --git a/test/test_tone.c b/test/test_tone.c
index 296253c..f51a2dc 100644
--- a/test/test_tone.c
+++ b/test/test_tone.c
@@ -6,7 +6,7 @@
*/
/* libcubeb api/function test. Plays a simple tone. */
-
+#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
}
cubeb_stream_start(stream);
- sleep(1);
+ usleep(500000);
cubeb_stream_stop(stream);
cubeb_stream_destroy(stream);