From 5b5c3a74e0d64d252fec4b380805c428875880c9 Mon Sep 17 00:00:00 2001 From: David Reid Date: Thu, 25 Jun 2020 07:00:02 +1000 Subject: [PATCH] Fix build with MA_NO_DEVICE_IO. Public issue https://github.com/dr-soft/miniaudio/issues/171 --- miniaudio.h | 103 +++++++++++++------------- tools/audioconverter/audioconverter.c | 1 + 2 files changed, 53 insertions(+), 51 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index be539e78..88f5ca39 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -2007,6 +2007,58 @@ typedef struct } ma_lcg; +/* Thread priorties should be ordered such that the default priority of the worker thread is 0. */ +typedef enum +{ + ma_thread_priority_idle = -5, + ma_thread_priority_lowest = -4, + ma_thread_priority_low = -3, + ma_thread_priority_normal = -2, + ma_thread_priority_high = -1, + ma_thread_priority_highest = 0, + ma_thread_priority_realtime = 1, + ma_thread_priority_default = 0 +} ma_thread_priority; + +#if defined(MA_WIN32) +typedef ma_handle ma_thread; +#endif +#if defined(MA_POSIX) +typedef pthread_t ma_thread; +#endif + +#if defined(MA_WIN32) +typedef ma_handle ma_mutex; +#endif +#if defined(MA_POSIX) +typedef pthread_mutex_t ma_mutex; +#endif + +#if defined(MA_WIN32) +typedef ma_handle ma_event; +#endif +#if defined(MA_POSIX) +typedef struct +{ + ma_uint32 value; + pthread_mutex_t lock; + pthread_cond_t cond; +} ma_event; +#endif + +#if defined(MA_WIN32) +typedef ma_handle ma_semaphore; +#endif +#if defined(MA_POSIX) +typedef struct +{ + int value; + pthread_mutex_t lock; + pthread_cond_t cond; +} ma_semaphore; +#endif + + /* Retrieves the version of miniaudio as separated integers. Each component can be NULL if it's not required. */ @@ -2997,57 +3049,6 @@ typedef enum ma_backend_null /* <-- Must always be the last item. Lowest priority, and used as the terminator for backend enumeration. */ } ma_backend; -/* Thread priorties should be ordered such that the default priority of the worker thread is 0. */ -typedef enum -{ - ma_thread_priority_idle = -5, - ma_thread_priority_lowest = -4, - ma_thread_priority_low = -3, - ma_thread_priority_normal = -2, - ma_thread_priority_high = -1, - ma_thread_priority_highest = 0, - ma_thread_priority_realtime = 1, - ma_thread_priority_default = 0 -} ma_thread_priority; - -#if defined(MA_WIN32) -typedef ma_handle ma_thread; -#endif -#if defined(MA_POSIX) -typedef pthread_t ma_thread; -#endif - -#if defined(MA_WIN32) -typedef ma_handle ma_mutex; -#endif -#if defined(MA_POSIX) -typedef pthread_mutex_t ma_mutex; -#endif - -#if defined(MA_WIN32) -typedef ma_handle ma_event; -#endif -#if defined(MA_POSIX) -typedef struct -{ - ma_uint32 value; - pthread_mutex_t lock; - pthread_cond_t cond; -} ma_event; -#endif - -#if defined(MA_WIN32) -typedef ma_handle ma_semaphore; -#endif -#if defined(MA_POSIX) -typedef struct -{ - int value; - pthread_mutex_t lock; - pthread_cond_t cond; -} ma_semaphore; -#endif - /* The callback for processing audio data from the device. diff --git a/tools/audioconverter/audioconverter.c b/tools/audioconverter/audioconverter.c index 57700e22..509ffaa7 100644 --- a/tools/audioconverter/audioconverter.c +++ b/tools/audioconverter/audioconverter.c @@ -23,6 +23,7 @@ find a copy of this text in extras/speex_resampler/README.md in the miniaudio re #include "../../extras/speex_resampler/ma_speex_resampler.h" #endif +#define MA_NO_DEVICE_IO #define MINIAUDIO_IMPLEMENTATION #include "../../miniaudio.h"