Compiled libao locally

This commit is contained in:
2026-04-16 08:29:32 +02:00
parent a9151fdb86
commit f95e4769b8
7 changed files with 25 additions and 2 deletions

View File

@@ -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)

View File

@@ -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 <dlfcn.h>
#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);