From 2c1a09d6b1b3cf14a70cef333db076e706b57aa8 Mon Sep 17 00:00:00 2001 From: David Reid Date: Tue, 18 Jun 2019 17:26:15 +1000 Subject: [PATCH] Make device state retrieval explicitly atomic. --- miniaudio.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/miniaudio.h b/miniaudio.h index 1ad51b32..4f230e4d 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -5488,7 +5488,10 @@ static MA_INLINE void ma_device__set_state(ma_device* pDevice, ma_uint32 newStat /* A helper for getting the state of the device. */ static MA_INLINE ma_uint32 ma_device__get_state(ma_device* pDevice) { - return pDevice->state; + ma_uint32 state; + ma_atomic_exchange_32(&state, pDevice->state); + + return state; }