You need to sign in or sign up before continuing.
Commit db61a91a authored by David Reid's avatar David Reid

Clean up some old atomic stuff.

I've noticed that a lot of this doesn't actually require atomic
operations so this may be reviewed again later.
parent 6734a527
...@@ -7605,10 +7605,6 @@ static MA_INLINE ma_int32 ma_dither_s32(ma_dither_mode ditherMode, ma_int32 dith ...@@ -7605,10 +7605,6 @@ static MA_INLINE ma_int32 ma_dither_s32(ma_dither_mode ditherMode, ma_int32 dith
Atomics Atomics
ma_atomic_increment/decrement_*() takes a pointer to the variable being incremented and returns the new value. Usage:
ma_uint32 newValue = ma_atomic_increment_32(&theValueToIncrement);
**************************************************************************************************************************************************************/ **************************************************************************************************************************************************************/
/* c89atomic.h begin */ /* c89atomic.h begin */
#ifndef c89atomic_h #ifndef c89atomic_h
...@@ -11825,12 +11821,12 @@ static HRESULT STDMETHODCALLTYPE ma_completion_handler_uwp_QueryInterface(ma_com ...@@ -11825,12 +11821,12 @@ static HRESULT STDMETHODCALLTYPE ma_completion_handler_uwp_QueryInterface(ma_com
static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_AddRef(ma_completion_handler_uwp* pThis) static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_AddRef(ma_completion_handler_uwp* pThis)
{ {
return (ULONG)ma_atomic_increment_32(&pThis->counter); return (ULONG)c89atomic_fetch_add_32(&pThis->counter, 1) + 1;
} }
static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_Release(ma_completion_handler_uwp* pThis) static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_Release(ma_completion_handler_uwp* pThis)
{ {
ma_uint32 newRefCount = ma_atomic_decrement_32(&pThis->counter); ma_uint32 newRefCount = c89atomic_fetch_sub_32(&pThis->counter, 1) - 1;
if (newRefCount == 0) { if (newRefCount == 0) {
return 0; /* We don't free anything here because we never allocate the object on the heap. */ return 0; /* We don't free anything here because we never allocate the object on the heap. */
} }
...@@ -24243,7 +24239,7 @@ static ma_result ma_context__init_device_tracking__coreaudio(ma_context* pContex ...@@ -24243,7 +24239,7 @@ static ma_result ma_context__init_device_tracking__coreaudio(ma_context* pContex
{ {
MA_ASSERT(pContext != NULL); MA_ASSERT(pContext != NULL);
if (ma_atomic_increment_32(&g_DeviceTrackingInitCounter_CoreAudio) == 1) { if (c89atomic_fetch_add_32(&g_DeviceTrackingInitCounter_CoreAudio, 1) == 0) {
AudioObjectPropertyAddress propAddress; AudioObjectPropertyAddress propAddress;
propAddress.mScope = kAudioObjectPropertyScopeGlobal; propAddress.mScope = kAudioObjectPropertyScopeGlobal;
propAddress.mElement = kAudioObjectPropertyElementMaster; propAddress.mElement = kAudioObjectPropertyElementMaster;
...@@ -24264,7 +24260,7 @@ static ma_result ma_context__uninit_device_tracking__coreaudio(ma_context* pCont ...@@ -24264,7 +24260,7 @@ static ma_result ma_context__uninit_device_tracking__coreaudio(ma_context* pCont
{ {
MA_ASSERT(pContext != NULL); MA_ASSERT(pContext != NULL);
if (ma_atomic_decrement_32(&g_DeviceTrackingInitCounter_CoreAudio) == 0) { if (c89atomic_fetch_sub_32(&g_DeviceTrackingInitCounter_CoreAudio, 1) == 1) {
AudioObjectPropertyAddress propAddress; AudioObjectPropertyAddress propAddress;
propAddress.mScope = kAudioObjectPropertyScopeGlobal; propAddress.mScope = kAudioObjectPropertyScopeGlobal;
propAddress.mElement = kAudioObjectPropertyElementMaster; propAddress.mElement = kAudioObjectPropertyElementMaster;
...@@ -29794,7 +29790,7 @@ static ma_result ma_context_uninit__opensl(ma_context* pContext) ...@@ -29794,7 +29790,7 @@ static ma_result ma_context_uninit__opensl(ma_context* pContext)
/* Uninit global data. */ /* Uninit global data. */
if (g_maOpenSLInitCounter > 0) { if (g_maOpenSLInitCounter > 0) {
if (ma_atomic_decrement_32(&g_maOpenSLInitCounter) == 0) { if (c89atomic_fetch_sub_32(&g_maOpenSLInitCounter, 1) == 1) {
(*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL); (*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL);
} }
} }
...@@ -29809,10 +29805,10 @@ static ma_result ma_context_init__opensl(const ma_context_config* pConfig, ma_co ...@@ -29809,10 +29805,10 @@ static ma_result ma_context_init__opensl(const ma_context_config* pConfig, ma_co
(void)pConfig; (void)pConfig;
/* Initialize global data first if applicable. */ /* Initialize global data first if applicable. */
if (ma_atomic_increment_32(&g_maOpenSLInitCounter) == 1) { if (c89atomic_fetch_add_32(&g_maOpenSLInitCounter, 1) == 0) {
SLresult resultSL = slCreateEngine(&g_maEngineObjectSL, 0, NULL, 0, NULL, NULL); SLresult resultSL = slCreateEngine(&g_maEngineObjectSL, 0, NULL, 0, NULL, NULL);
if (resultSL != SL_RESULT_SUCCESS) { if (resultSL != SL_RESULT_SUCCESS) {
ma_atomic_decrement_32(&g_maOpenSLInitCounter); c89atomic_fetch_sub_32(&g_maOpenSLInitCounter, 1);
return ma_result_from_OpenSL(resultSL); return ma_result_from_OpenSL(resultSL);
} }
...@@ -29821,7 +29817,7 @@ static ma_result ma_context_init__opensl(const ma_context_config* pConfig, ma_co ...@@ -29821,7 +29817,7 @@ static ma_result ma_context_init__opensl(const ma_context_config* pConfig, ma_co
resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, SL_IID_ENGINE, &g_maEngineSL); resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, SL_IID_ENGINE, &g_maEngineSL);
if (resultSL != SL_RESULT_SUCCESS) { if (resultSL != SL_RESULT_SUCCESS) {
(*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL); (*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL);
ma_atomic_decrement_32(&g_maOpenSLInitCounter); c89atomic_fetch_sub_32(&g_maOpenSLInitCounter, 1);
return ma_result_from_OpenSL(resultSL); return ma_result_from_OpenSL(resultSL);
} }
} }
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