Commit 5f145039 authored by David Reid's avatar David Reid

Fix build when compiling with MA_NO_THREADING.

parent ffb5a995
...@@ -2068,7 +2068,9 @@ typedef struct ...@@ -2068,7 +2068,9 @@ typedef struct
ma_log_callback callbacks[MA_MAX_LOG_CALLBACKS]; ma_log_callback callbacks[MA_MAX_LOG_CALLBACKS];
ma_uint32 callbackCount; ma_uint32 callbackCount;
ma_allocation_callbacks allocationCallbacks; /* Need to store these persistently because ma_log_postv() might need to allocate a buffer on the heap. */ ma_allocation_callbacks allocationCallbacks; /* Need to store these persistently because ma_log_postv() might need to allocate a buffer on the heap. */
#ifndef MA_NO_THREADING
ma_mutex lock; /* For thread safety just to make it easier and safer for the logging implementation. */ ma_mutex lock; /* For thread safety just to make it easier and safer for the logging implementation. */
#endif
} ma_log; } ma_log;
MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks, ma_log* pLog); MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks, ma_log* pLog);
...@@ -8527,8 +8529,6 @@ MA_API ma_log_callback ma_log_callback_init(ma_log_callback_proc onLog, void* pU ...@@ -8527,8 +8529,6 @@ MA_API ma_log_callback ma_log_callback_init(ma_log_callback_proc onLog, void* pU
MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks, ma_log* pLog) MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks, ma_log* pLog)
{ {
ma_result result;
if (pLog == NULL) { if (pLog == NULL) {
return MA_INVALID_ARGS; return MA_INVALID_ARGS;
} }
...@@ -8537,10 +8537,14 @@ MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks ...@@ -8537,10 +8537,14 @@ MA_API ma_result ma_log_init(const ma_allocation_callbacks* pAllocationCallbacks
ma_allocation_callbacks_init_copy(&pLog->allocationCallbacks, pAllocationCallbacks); ma_allocation_callbacks_init_copy(&pLog->allocationCallbacks, pAllocationCallbacks);
/* We need a mutex for thread safety. */ /* We need a mutex for thread safety. */
result = ma_mutex_init(&pLog->lock); #ifndef MA_NO_THREADING
if (result != MA_SUCCESS) { {
return result; ma_result result = ma_mutex_init(&pLog->lock);
if (result != MA_SUCCESS) {
return result;
}
} }
#endif
/* If we're using debug output, enable it. */ /* If we're using debug output, enable it. */
#if defined(MA_DEBUG_OUTPUT) #if defined(MA_DEBUG_OUTPUT)
...@@ -8558,7 +8562,27 @@ MA_API void ma_log_uninit(ma_log* pLog) ...@@ -8558,7 +8562,27 @@ MA_API void ma_log_uninit(ma_log* pLog)
return; return;
} }
#ifndef MA_NO_THREADING
ma_mutex_uninit(&pLog->lock); ma_mutex_uninit(&pLog->lock);
#endif
}
static void ma_log_lock(ma_log* pLog)
{
#ifndef MA_NO_THREADING
ma_mutex_lock(&pLog->lock);
#else
(void)pLog;
#endif
}
static void ma_log_unlock(ma_log* pLog)
{
#ifndef MA_NO_THREADING
ma_mutex_unlock(&pLog->lock);
#else
(void)pLog;
#endif
} }
MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback) MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback)
...@@ -8569,7 +8593,7 @@ MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback ...@@ -8569,7 +8593,7 @@ MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback
return MA_INVALID_ARGS; return MA_INVALID_ARGS;
} }
ma_mutex_lock(&pLog->lock); ma_log_lock(pLog);
{ {
if (pLog->callbackCount == ma_countof(pLog->callbacks)) { if (pLog->callbackCount == ma_countof(pLog->callbacks)) {
result = MA_OUT_OF_MEMORY; /* Reached the maximum allowed log callbacks. */ result = MA_OUT_OF_MEMORY; /* Reached the maximum allowed log callbacks. */
...@@ -8578,7 +8602,7 @@ MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback ...@@ -8578,7 +8602,7 @@ MA_API ma_result ma_log_register_callback(ma_log* pLog, ma_log_callback callback
pLog->callbackCount += 1; pLog->callbackCount += 1;
} }
} }
ma_mutex_unlock(&pLog->lock); ma_log_unlock(pLog);
return result; return result;
} }
...@@ -8589,7 +8613,7 @@ MA_API ma_result ma_log_unregister_callback(ma_log* pLog, ma_log_callback callba ...@@ -8589,7 +8613,7 @@ MA_API ma_result ma_log_unregister_callback(ma_log* pLog, ma_log_callback callba
return MA_INVALID_ARGS; return MA_INVALID_ARGS;
} }
ma_mutex_lock(&pLog->lock); ma_log_lock(pLog);
{ {
ma_uint32 iLog; ma_uint32 iLog;
for (iLog = 0; iLog < pLog->callbackCount; ) { for (iLog = 0; iLog < pLog->callbackCount; ) {
...@@ -8607,7 +8631,7 @@ MA_API ma_result ma_log_unregister_callback(ma_log* pLog, ma_log_callback callba ...@@ -8607,7 +8631,7 @@ MA_API ma_result ma_log_unregister_callback(ma_log* pLog, ma_log_callback callba
} }
} }
} }
ma_mutex_unlock(&pLog->lock); ma_log_unlock(pLog);
return MA_SUCCESS; return MA_SUCCESS;
} }
...@@ -8627,7 +8651,7 @@ MA_API ma_result ma_log_post(ma_log* pLog, ma_uint32 level, const char* pMessage ...@@ -8627,7 +8651,7 @@ MA_API ma_result ma_log_post(ma_log* pLog, ma_uint32 level, const char* pMessage
} }
#endif #endif
ma_mutex_lock(&pLog->lock); ma_log_lock(pLog);
{ {
ma_uint32 iLog; ma_uint32 iLog;
for (iLog = 0; iLog < pLog->callbackCount; iLog += 1) { for (iLog = 0; iLog < pLog->callbackCount; iLog += 1) {
...@@ -8636,7 +8660,7 @@ MA_API ma_result ma_log_post(ma_log* pLog, ma_uint32 level, const char* pMessage ...@@ -8636,7 +8660,7 @@ MA_API ma_result ma_log_post(ma_log* pLog, ma_uint32 level, const char* pMessage
} }
} }
} }
ma_mutex_unlock(&pLog->lock); ma_log_unlock(pLog);
return MA_SUCCESS; return MA_SUCCESS;
} }
...@@ -69271,6 +69295,7 @@ The following miscellaneous changes have also been made. ...@@ -69271,6 +69295,7 @@ The following miscellaneous changes have also been made.
REVISION HISTORY REVISION HISTORY
================ ================
0.10.37 - TBD 0.10.37 - TBD
- Fix build when compiling with MA_NO_THREADING.
- Minor updates to channel mapping. - Minor updates to channel mapping.
0.10.36 - 2021-07-03 0.10.36 - 2021-07-03
...@@ -326,5 +326,19 @@ int main(int argc, char** argv) ...@@ -326,5 +326,19 @@ int main(int argc, char** argv)
/* stb_vorbis implementation must come after the implementation of miniaudio. */ /* stb_vorbis implementation must come after the implementation of miniaudio. */
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable:4100) /* unreferenced formal parameter */
#pragma warning(disable:4244) /* '=': conversion from '' to '', possible loss of data */
#pragma warning(disable:4245) /* '=': conversion from '' to '', signed/unsigned mismatch */
#pragma warning(disable:4456) /* declaration of '' hides previous local declaration */
#pragma warning(disable:4457) /* declaration of '' hides function parameter */
#pragma warning(disable:4701) /* potentially uninitialized local variable '' used */
#else
#endif
#undef STB_VORBIS_HEADER_ONLY #undef STB_VORBIS_HEADER_ONLY
#include "../../extras/stb_vorbis.c" #include "../../extras/stb_vorbis.c"
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#else
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment