Commit d0b82d3c authored by David Reid's avatar David Reid

Try fixing a potential thread safety issue.

parent 9dbcc39c
...@@ -2431,7 +2431,7 @@ struct ma_device ...@@ -2431,7 +2431,7 @@ struct ma_device
ma_context* pContext; ma_context* pContext;
ma_device_type type; ma_device_type type;
ma_uint32 sampleRate; ma_uint32 sampleRate;
ma_uint32 state; volatile ma_uint32 state; /* The state of the device is variable and can change at any time on any thread, so tell the compiler as such with `volatile`. */
ma_device_callback_proc onData; ma_device_callback_proc onData;
ma_stop_proc onStop; ma_stop_proc onStop;
void* pUserData; /* Application defined data. */ void* pUserData; /* Application defined data. */
...@@ -6167,10 +6167,7 @@ static MA_INLINE void ma_device__set_state(ma_device* pDevice, ma_uint32 newStat ...@@ -6167,10 +6167,7 @@ static MA_INLINE void ma_device__set_state(ma_device* pDevice, ma_uint32 newStat
/* A helper for getting the state of the device. */ /* A helper for getting the state of the device. */
static MA_INLINE ma_uint32 ma_device__get_state(ma_device* pDevice) static MA_INLINE ma_uint32 ma_device__get_state(ma_device* pDevice)
{ {
ma_uint32 state; return pDevice->state;
ma_atomic_exchange_32(&state, pDevice->state);
return state;
} }
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