Compare commits
4 Commits
a9151fdb86
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ab859cdee1 | |||
| c1d1f7ae7c | |||
| 6bba1712ab | |||
| f95e4769b8 |
@@ -10,6 +10,17 @@ add_library(ao-play-async SHARED
|
||||
ao_playasync.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
#include_directories(../../libao/include ../../libao/build-windows)
|
||||
include_directories(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 winmm.lib ksuser.lib)
|
||||
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)
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
151
ao-play-async/windows/ao/ao.h
Normal file
151
ao-play-async/windows/ao/ao.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
*
|
||||
* ao.h
|
||||
*
|
||||
* Original Copyright (C) Aaron Holtzman - May 1999
|
||||
* Modifications Copyright (C) Stan Seibert - July 2000, July 2001
|
||||
* More Modifications Copyright (C) Jack Moffitt - October 2000
|
||||
*
|
||||
* This file is part of libao, a cross-platform audio outputlibrary. See
|
||||
* README for a history of this source code.
|
||||
*
|
||||
* libao is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* libao 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 General Public License
|
||||
* along with GNU Make; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
#ifndef __AO_H__
|
||||
#define __AO_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include "os_types.h"
|
||||
|
||||
/* --- Exporting functions ---*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef AO_BUILDING_LIBAO
|
||||
#define AO_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define AO_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define AO_EXPORT
|
||||
#endif
|
||||
|
||||
/* --- Constants ---*/
|
||||
|
||||
#define AO_TYPE_LIVE 1
|
||||
#define AO_TYPE_FILE 2
|
||||
|
||||
|
||||
#define AO_ENODRIVER 1
|
||||
#define AO_ENOTFILE 2
|
||||
#define AO_ENOTLIVE 3
|
||||
#define AO_EBADOPTION 4
|
||||
#define AO_EOPENDEVICE 5
|
||||
#define AO_EOPENFILE 6
|
||||
#define AO_EFILEEXISTS 7
|
||||
#define AO_EBADFORMAT 8
|
||||
|
||||
#define AO_EFAIL 100
|
||||
|
||||
|
||||
#define AO_FMT_LITTLE 1
|
||||
#define AO_FMT_BIG 2
|
||||
#define AO_FMT_NATIVE 4
|
||||
|
||||
/* --- Structures --- */
|
||||
|
||||
typedef struct ao_info {
|
||||
int type; /* live output or file output? */
|
||||
char *name; /* full name of driver */
|
||||
char *short_name; /* short name of driver */
|
||||
char *author; /* driver author */
|
||||
char *comment; /* driver comment */
|
||||
int preferred_byte_format;
|
||||
int priority;
|
||||
char **options;
|
||||
int option_count;
|
||||
} ao_info;
|
||||
|
||||
typedef struct ao_functions ao_functions;
|
||||
typedef struct ao_device ao_device;
|
||||
|
||||
typedef struct ao_sample_format {
|
||||
int bits; /* bits per sample */
|
||||
int rate; /* samples per second (in a single channel) */
|
||||
int channels; /* number of audio channels */
|
||||
int byte_format; /* Byte ordering in sample, see constants below */
|
||||
char *matrix; /* input channel location/ordering */
|
||||
} ao_sample_format;
|
||||
|
||||
typedef struct ao_option {
|
||||
char *key;
|
||||
char *value;
|
||||
struct ao_option *next;
|
||||
} ao_option;
|
||||
|
||||
#if defined(AO_BUILDING_LIBAO)
|
||||
#include "ao_private.h"
|
||||
#endif
|
||||
|
||||
/* --- Functions --- */
|
||||
|
||||
/* library setup/teardown */
|
||||
AO_EXPORT void ao_initialize(void);
|
||||
AO_EXPORT void ao_shutdown(void);
|
||||
|
||||
/* device setup/playback/teardown */
|
||||
AO_EXPORT int ao_append_global_option(const char *key,
|
||||
const char *value);
|
||||
AO_EXPORT int ao_append_option(ao_option **options,
|
||||
const char *key,
|
||||
const char *value);
|
||||
AO_EXPORT void ao_free_options(ao_option *options);
|
||||
AO_EXPORT ao_device* ao_open_live(int driver_id,
|
||||
ao_sample_format *format,
|
||||
ao_option *option);
|
||||
AO_EXPORT ao_device* ao_open_file(int driver_id,
|
||||
const char *filename,
|
||||
int overwrite,
|
||||
ao_sample_format *format,
|
||||
ao_option *option);
|
||||
|
||||
AO_EXPORT int ao_play(ao_device *device,
|
||||
char *output_samples,
|
||||
uint_32 num_bytes);
|
||||
AO_EXPORT int ao_close(ao_device *device);
|
||||
|
||||
/* driver information */
|
||||
AO_EXPORT int ao_driver_id(const char *short_name);
|
||||
AO_EXPORT int ao_default_driver_id(void);
|
||||
AO_EXPORT ao_info *ao_driver_info(int driver_id);
|
||||
AO_EXPORT ao_info **ao_driver_info_list(int *driver_count);
|
||||
AO_EXPORT const char *ao_file_extension(int driver_id);
|
||||
|
||||
/* miscellaneous */
|
||||
AO_EXPORT int ao_is_big_endian(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __AO_H__ */
|
||||
10
ao-play-async/windows/ao/os_types.h
Normal file
10
ao-play-async/windows/ao/os_types.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint8_t uint_8;
|
||||
typedef uint16_t uint_16;
|
||||
typedef uint32_t uint_32;
|
||||
typedef int8_t sint_8;
|
||||
typedef int16_t sint_16;
|
||||
typedef int32_t sint_32;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/windows-x86_64/ao-play-async.lib
Normal file
BIN
lib/windows-x86_64/ao-play-async.lib
Normal file
Binary file not shown.
BIN
lib/windows-x86_64/libao-1.2.2.dll
Normal file
BIN
lib/windows-x86_64/libao-1.2.2.dll
Normal file
Binary file not shown.
BIN
lib/windows-x86_64/libao-1.2.2.lib
Normal file
BIN
lib/windows-x86_64/libao-1.2.2.lib
Normal file
Binary file not shown.
Binary file not shown.
BIN
lib/windows-x86_64/libao-static-1.2.2.lib
Normal file
BIN
lib/windows-x86_64/libao-static-1.2.2.lib
Normal file
Binary file not shown.
Reference in New Issue
Block a user