diff --git a/ao-play-async/CMakeLists.txt b/ao-play-async/CMakeLists.txt index b6d31e4..19734e1 100644 --- a/ao-play-async/CMakeLists.txt +++ b/ao-play-async/CMakeLists.txt @@ -10,6 +10,16 @@ add_library(ao-play-async SHARED ao_playasync.h ) +if(WIN32) + include_directories(../../libao/include ../../libao/build-windows) + target_link_directories(ao-play-async PRIVATE ../lib/windows-x86_64) +endif() + +if(WIN32) + target_link_libraries(ao-play-async PRIVATE libao-1.2.2) +else() + target_link_libraries(ao-play-async PRIVATE ao) +endif() -target_link_libraries(ao-play-async PRIVATE ao) target_compile_definitions(ao-play-async PRIVATE AOPLAYASYNC_LIBRARY) + diff --git a/ao-play-async/ao_playasync.c b/ao-play-async/ao_playasync.c index a6168d9..37391cb 100644 --- a/ao-play-async/ao_playasync.c +++ b/ao-play-async/ao_playasync.c @@ -12,6 +12,10 @@ #ifdef USE_WINDOWS_THREADS #define MUTEX_LOCK(m) WaitForSingleObject(m, INFINITE) #define MUTEX_UNLOCK(m) ReleaseMutex(m) + #define SEM_WAIT(sem, ms) (WaitForSingleObject(sem, ms) == WAIT_OBJECT_0) + #define SEM_TRYWAIT(sem) (WaitForSingleObject(sem, 0) == WAIT_OBJECT_0) + #define SEM_POST(sem) ReleaseSemaphore(sem, 1, NULL) + #define YIELD() sleep_ms(5) #endif #ifdef USE_PTHREADS @@ -108,8 +112,10 @@ typedef struct { #ifdef USE_WINDOWS_THREADS HANDLE mutex; HANDLE pause_mutex; + HANDLE clear_mutex; HANDLE thread; DWORD thread_id; + HANDLE queue_sem; #endif #ifdef USE_PTHREADS pthread_mutex_t mutex; @@ -267,7 +273,11 @@ int ao_async_version() #include #endif +#ifdef _WIN32 +static void at_exit_shutdown_ao(void) +#else static void at_exit_shutdown_ao() +#endif { ao_shutdown(); } @@ -328,8 +338,11 @@ void *ao_create_async(int bits, int rate, int channels, int byte_format) handle->pause_mutex = CreateMutex(NULL, // default security attributes FALSE, // initially not owned NULL); + handle->clear_mutex = CreateMutex(NULL, + FALSE, + NULL); + handle->queue_sem = CreateSemaphore(NULL, 0, 1000000, NULL); handle->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) run, handle, 0, &handle->thread_id); - // TODO Windows Semaphores! #endif MUTEX_UNLOCK(handle->pause_mutex); diff --git a/lib/windows-x86_64/ao-play-async.dll b/lib/windows-x86_64/ao-play-async.dll index 1672e9b..2b15d4c 100644 Binary files a/lib/windows-x86_64/ao-play-async.dll and b/lib/windows-x86_64/ao-play-async.dll differ diff --git a/lib/windows-x86_64/libao-1.2.2.dll b/lib/windows-x86_64/libao-1.2.2.dll new file mode 100644 index 0000000..c4510fc Binary files /dev/null and b/lib/windows-x86_64/libao-1.2.2.dll differ diff --git a/lib/windows-x86_64/libao-1.2.2.lib b/lib/windows-x86_64/libao-1.2.2.lib new file mode 100644 index 0000000..e40f10a Binary files /dev/null and b/lib/windows-x86_64/libao-1.2.2.lib differ diff --git a/lib/windows-x86_64/libao-4.dll b/lib/windows-x86_64/libao-4.dll deleted file mode 100644 index 803f1c7..0000000 Binary files a/lib/windows-x86_64/libao-4.dll and /dev/null differ diff --git a/lib/windows-x86_64/libao-static-1.2.2.lib b/lib/windows-x86_64/libao-static-1.2.2.lib new file mode 100644 index 0000000..4015926 Binary files /dev/null and b/lib/windows-x86_64/libao-static-1.2.2.lib differ