mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +02:00
Try fixing a potential thread safety issue.
This commit is contained in:
+2
-5
@@ -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
|
|||||||
/* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user