mirror of https://github.com/libsdl-org/SDL
Renamed atomic functions to match SDL 3.0 naming convention
This will also allow us to cleanly add atomic operations for other types in the future.
This commit is contained in:
parent
f3e419596b
commit
8d223b3037
|
@ -2907,12 +2907,37 @@ expression e1, e2, e3, e4;
|
|||
@@
|
||||
@@
|
||||
- SDL_AtomicCAS
|
||||
+ SDL_AtomicCompareAndSwap
|
||||
+ SDL_CompareAndSwapAtomicInt
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_AtomicSet
|
||||
+ SDL_SetAtomicInt
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_AtomicGet
|
||||
+ SDL_GetAtomicInt
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_AtomicAdd
|
||||
+ SDL_AddAtomicInt
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_AtomicCASPtr
|
||||
+ SDL_AtomicCompareAndSwapPointer
|
||||
+ SDL_CompareAndSwapAtomicPointer
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_AtomicSetPtr
|
||||
+ SDL_SetAtomicPointer
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_AtomicGetPtr
|
||||
+ SDL_GetAtomicPointer
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
|
@ -3586,16 +3611,6 @@ typedef SDL_JoystickGUID, SDL_GUID;
|
|||
+ SDL_HINT_MOUSE_EMULATE_WARP_WITH_RELATIVE
|
||||
@@
|
||||
@@
|
||||
- SDL_AtomicSetPtr
|
||||
+ SDL_AtomicSetPointer
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_AtomicGetPtr
|
||||
+ SDL_AtomicGetPointer
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_DelEventWatch
|
||||
+ SDL_RemoveEventWatch
|
||||
(...)
|
||||
|
|
|
@ -86,11 +86,14 @@ The following structures have been renamed:
|
|||
- SDL_atomic_t => SDL_AtomicInt
|
||||
|
||||
The following functions have been renamed:
|
||||
* SDL_AtomicCAS() => SDL_AtomicCompareAndSwap()
|
||||
* SDL_AtomicCASPtr() => SDL_AtomicCompareAndSwapPointer()
|
||||
* SDL_AtomicGetPtr() => SDL_AtomicGetPointer()
|
||||
* SDL_AtomicAdd() => SDL_AddAtomicInt()
|
||||
* SDL_AtomicCAS() => SDL_CompareAndSwapAtomicInt()
|
||||
* SDL_AtomicCASPtr() => SDL_CompareAndSwapAtomicPointer()
|
||||
* SDL_AtomicGet() => SDL_GetAtomicInt()
|
||||
* SDL_AtomicGetPtr() => SDL_GetAtomicPointer()
|
||||
* SDL_AtomicLock() => SDL_LockSpinlock()
|
||||
* SDL_AtomicSetPtr() => SDL_AtomicSetPointer()
|
||||
* SDL_AtomicSet() => SDL_SetAtomicInt()
|
||||
* SDL_AtomicSetPtr() => SDL_SetAtomicPointer()
|
||||
* SDL_AtomicTryLock() => SDL_TryLockSpinlock()
|
||||
* SDL_AtomicUnlock() => SDL_UnlockSpinlock()
|
||||
|
||||
|
|
|
@ -303,9 +303,9 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
|
|||
* A type representing an atomic integer value.
|
||||
*
|
||||
* This can be used to manage a value that is synchronized across multiple
|
||||
* CPUs without a race condition; when an app sets a value with SDL_AtomicSet
|
||||
* CPUs without a race condition; when an app sets a value with SDL_SetAtomicInt
|
||||
* all other threads, regardless of the CPU it is running on, will see that
|
||||
* value when retrieved with SDL_AtomicGet, regardless of CPU caches, etc.
|
||||
* value when retrieved with SDL_GetAtomicInt, regardless of CPU caches, etc.
|
||||
*
|
||||
* This is also useful for atomic compare-and-swap operations: a thread can
|
||||
* change the value as long as its current value matches expectations. When
|
||||
|
@ -320,10 +320,10 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
|
|||
*
|
||||
* \since This struct is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicCompareAndSwap
|
||||
* \sa SDL_AtomicGet
|
||||
* \sa SDL_AtomicSet
|
||||
* \sa SDL_AtomicAdd
|
||||
* \sa SDL_CompareAndSwapAtomicInt
|
||||
* \sa SDL_GetAtomicInt
|
||||
* \sa SDL_SetAtomicInt
|
||||
* \sa SDL_AddAtomicInt
|
||||
*/
|
||||
typedef struct SDL_AtomicInt { int value; } SDL_AtomicInt;
|
||||
|
||||
|
@ -342,9 +342,9 @@ typedef struct SDL_AtomicInt { int value; } SDL_AtomicInt;
|
|||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicCompareAndSwapPointer
|
||||
* \sa SDL_CompareAndSwapAtomicPointer
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareAndSwap(SDL_AtomicInt *a, int oldval, int newval);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CompareAndSwapAtomicInt(SDL_AtomicInt *a, int oldval, int newval);
|
||||
|
||||
/**
|
||||
* Set an atomic variable to a value.
|
||||
|
@ -362,9 +362,9 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareAndSwap(SDL_AtomicInt *a,
|
|||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicGet
|
||||
* \sa SDL_GetAtomicInt
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_AtomicSet(SDL_AtomicInt *a, int v);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetAtomicInt(SDL_AtomicInt *a, int v);
|
||||
|
||||
/**
|
||||
* Get the value of an atomic variable.
|
||||
|
@ -379,9 +379,9 @@ extern SDL_DECLSPEC int SDLCALL SDL_AtomicSet(SDL_AtomicInt *a, int v);
|
|||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicSet
|
||||
* \sa SDL_SetAtomicInt
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_AtomicGet(SDL_AtomicInt *a);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetAtomicInt(SDL_AtomicInt *a);
|
||||
|
||||
/**
|
||||
* Add to an atomic variable.
|
||||
|
@ -402,7 +402,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_AtomicGet(SDL_AtomicInt *a);
|
|||
* \sa SDL_AtomicDecRef
|
||||
* \sa SDL_AtomicIncRef
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_AtomicInt *a, int v);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_AddAtomicInt(SDL_AtomicInt *a, int v);
|
||||
|
||||
#ifndef SDL_AtomicIncRef
|
||||
|
||||
|
@ -418,7 +418,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_AtomicInt *a, int v);
|
|||
*
|
||||
* \sa SDL_AtomicDecRef
|
||||
*/
|
||||
#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1)
|
||||
#define SDL_AtomicIncRef(a) SDL_AddAtomicInt(a, 1)
|
||||
#endif
|
||||
|
||||
#ifndef SDL_AtomicDecRef
|
||||
|
@ -436,7 +436,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_AtomicInt *a, int v);
|
|||
*
|
||||
* \sa SDL_AtomicIncRef
|
||||
*/
|
||||
#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1)
|
||||
#define SDL_AtomicDecRef(a) (SDL_AddAtomicInt(a, -1) == 1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -454,11 +454,11 @@ extern SDL_DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_AtomicInt *a, int v);
|
|||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicCompareAndSwap
|
||||
* \sa SDL_AtomicGetPointer
|
||||
* \sa SDL_AtomicSetPointer
|
||||
* \sa SDL_CompareAndSwapAtomicInt
|
||||
* \sa SDL_GetAtomicPointer
|
||||
* \sa SDL_SetAtomicPointer
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareAndSwapPointer(void **a, void *oldval, void *newval);
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_CompareAndSwapAtomicPointer(void **a, void *oldval, void *newval);
|
||||
|
||||
/**
|
||||
* Set a pointer to a value atomically.
|
||||
|
@ -474,10 +474,10 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_AtomicCompareAndSwapPointer(void **a, v
|
|||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicCompareAndSwapPointer
|
||||
* \sa SDL_AtomicGetPointer
|
||||
* \sa SDL_CompareAndSwapAtomicPointer
|
||||
* \sa SDL_GetAtomicPointer
|
||||
*/
|
||||
extern SDL_DECLSPEC void * SDLCALL SDL_AtomicSetPointer(void **a, void *v);
|
||||
extern SDL_DECLSPEC void * SDLCALL SDL_SetAtomicPointer(void **a, void *v);
|
||||
|
||||
/**
|
||||
* Get the value of a pointer atomically.
|
||||
|
@ -492,10 +492,10 @@ extern SDL_DECLSPEC void * SDLCALL SDL_AtomicSetPointer(void **a, void *v);
|
|||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_AtomicCompareAndSwapPointer
|
||||
* \sa SDL_AtomicSetPointer
|
||||
* \sa SDL_CompareAndSwapAtomicPointer
|
||||
* \sa SDL_SetAtomicPointer
|
||||
*/
|
||||
extern SDL_DECLSPEC void * SDLCALL SDL_AtomicGetPointer(void **a);
|
||||
extern SDL_DECLSPEC void * SDLCALL SDL_GetAtomicPointer(void **a);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -38,11 +38,14 @@
|
|||
#ifdef SDL_ENABLE_OLD_NAMES
|
||||
|
||||
/* ##SDL_atomic.h */
|
||||
#define SDL_AtomicCAS SDL_AtomicCompareAndSwap
|
||||
#define SDL_AtomicCASPtr SDL_AtomicCompareAndSwapPointer
|
||||
#define SDL_AtomicGetPtr SDL_AtomicGetPointer
|
||||
#define SDL_AtomicAdd SDL_AddAtomicInt
|
||||
#define SDL_AtomicCAS SDL_CompareAndSwapAtomicInt
|
||||
#define SDL_AtomicCASPtr SDL_CompareAndSwapAtomicPointer
|
||||
#define SDL_AtomicGet SDL_GetAtomicInt
|
||||
#define SDL_AtomicGetPtr SDL_GetAtomicPointer
|
||||
#define SDL_AtomicLock SDL_LockSpinlock
|
||||
#define SDL_AtomicSetPtr SDL_AtomicSetPointer
|
||||
#define SDL_AtomicSet SDL_SetAtomicInt
|
||||
#define SDL_AtomicSetPtr SDL_SetAtomicPointer
|
||||
#define SDL_AtomicTryLock SDL_TryLockSpinlock
|
||||
#define SDL_AtomicUnlock SDL_UnlockSpinlock
|
||||
#define SDL_atomic_t SDL_AtomicInt
|
||||
|
@ -668,11 +671,14 @@
|
|||
#elif !defined(SDL_DISABLE_OLD_NAMES)
|
||||
|
||||
/* ##SDL_atomic.h */
|
||||
#define SDL_AtomicCAS SDL_AtomicCAS_renamed_SDL_AtomicCompareAndSwap
|
||||
#define SDL_AtomicCASPtr SDL_AtomicCASPtr_renamed_SDL_AtomicCompareAndSwapPointer
|
||||
#define SDL_AtomicGetPtr SDL_AtomicGetPtr_renamed_SDL_AtomicGetPointer
|
||||
#define SDL_AtomicAdd SDL_AtomicAdd_renamed_SDL_AddAtomicInt
|
||||
#define SDL_AtomicCAS SDL_AtomicCAS_renamed_SDL_CompareAndSwapAtomicInt
|
||||
#define SDL_AtomicCASPtr SDL_AtomicCASPtr_renamed_SDL_CompareAndSwapAtomicPointer
|
||||
#define SDL_AtomicGet SDL_AtomicGet_renamed_SDL_GetAtomicInt
|
||||
#define SDL_AtomicGetPtr SDL_AtomicGetPtr_renamed_SDL_GetAtomicPointer
|
||||
#define SDL_AtomicLock SDL_AtomicLock_renamed_SDL_LockSpinlock
|
||||
#define SDL_AtomicSetPtr SDL_AtomicSetPtr_renamed_SDL_AtomicSetPointer
|
||||
#define SDL_AtomicSet SDL_AtomicSet_renamed_SDL_SetAtomicInt
|
||||
#define SDL_AtomicSetPtr SDL_AtomicSetPtr_renamed_SDL_SetAtomicPointer
|
||||
#define SDL_AtomicTryLock SDL_AtomicTryLock_renamed_SDL_TryLockSpinlock
|
||||
#define SDL_AtomicUnlock SDL_AtomicUnlock_renamed_SDL_UnlockSpinlock
|
||||
#define SDL_atomic_t SDL_atomic_t_renamed_SDL_AtomicInt
|
||||
|
|
|
@ -165,7 +165,7 @@ void SDL_QuitLog(void)
|
|||
|
||||
static void SDL_CheckInitLog(void)
|
||||
{
|
||||
int status = SDL_AtomicGet(&SDL_log_init.status);
|
||||
int status = SDL_GetAtomicInt(&SDL_log_init.status);
|
||||
if (status == SDL_INIT_STATUS_INITIALIZED ||
|
||||
(status == SDL_INIT_STATUS_INITIALIZING && SDL_log_init.thread == SDL_GetCurrentThreadID())) {
|
||||
return;
|
||||
|
|
|
@ -123,8 +123,8 @@ bool SDL_endswith(const char *string, const char *suffix)
|
|||
|
||||
bool SDL_ShouldInit(SDL_InitState *state)
|
||||
{
|
||||
while (SDL_AtomicGet(&state->status) != SDL_INIT_STATUS_INITIALIZED) {
|
||||
if (SDL_AtomicCompareAndSwap(&state->status, SDL_INIT_STATUS_UNINITIALIZED, SDL_INIT_STATUS_INITIALIZING)) {
|
||||
while (SDL_GetAtomicInt(&state->status) != SDL_INIT_STATUS_INITIALIZED) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&state->status, SDL_INIT_STATUS_UNINITIALIZED, SDL_INIT_STATUS_INITIALIZING)) {
|
||||
state->thread = SDL_GetCurrentThreadID();
|
||||
return true;
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ bool SDL_ShouldInit(SDL_InitState *state)
|
|||
|
||||
bool SDL_ShouldQuit(SDL_InitState *state)
|
||||
{
|
||||
if (SDL_AtomicCompareAndSwap(&state->status, SDL_INIT_STATUS_INITIALIZED, SDL_INIT_STATUS_UNINITIALIZING)) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&state->status, SDL_INIT_STATUS_INITIALIZED, SDL_INIT_STATUS_UNINITIALIZING)) {
|
||||
state->thread = SDL_GetCurrentThreadID();
|
||||
return true;
|
||||
}
|
||||
|
@ -149,9 +149,9 @@ void SDL_SetInitialized(SDL_InitState *state, bool initialized)
|
|||
SDL_assert(state->thread == SDL_GetCurrentThreadID());
|
||||
|
||||
if (initialized) {
|
||||
SDL_AtomicSet(&state->status, SDL_INIT_STATUS_INITIALIZED);
|
||||
SDL_SetAtomicInt(&state->status, SDL_INIT_STATUS_INITIALIZED);
|
||||
} else {
|
||||
SDL_AtomicSet(&state->status, SDL_INIT_STATUS_UNINITIALIZED);
|
||||
SDL_SetAtomicInt(&state->status, SDL_INIT_STATUS_UNINITIALIZED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ static SDL_INLINE void leaveLock(void *a)
|
|||
}
|
||||
#endif
|
||||
|
||||
SDL_bool SDL_AtomicCompareAndSwap(SDL_AtomicInt *a, int oldval, int newval)
|
||||
SDL_bool SDL_CompareAndSwapAtomicInt(SDL_AtomicInt *a, int oldval, int newval)
|
||||
{
|
||||
#ifdef HAVE_MSC_ATOMICS
|
||||
SDL_COMPILE_TIME_ASSERT(atomic_cas, sizeof(long) == sizeof(a->value));
|
||||
|
@ -151,7 +151,7 @@ SDL_bool SDL_AtomicCompareAndSwap(SDL_AtomicInt *a, int oldval, int newval)
|
|||
#endif
|
||||
}
|
||||
|
||||
SDL_bool SDL_AtomicCompareAndSwapPointer(void **a, void *oldval, void *newval)
|
||||
SDL_bool SDL_CompareAndSwapAtomicPointer(void **a, void *oldval, void *newval)
|
||||
{
|
||||
#ifdef HAVE_MSC_ATOMICS
|
||||
return _InterlockedCompareExchangePointer(a, newval, oldval) == oldval;
|
||||
|
@ -181,7 +181,7 @@ SDL_bool SDL_AtomicCompareAndSwapPointer(void **a, void *oldval, void *newval)
|
|||
#endif
|
||||
}
|
||||
|
||||
int SDL_AtomicSet(SDL_AtomicInt *a, int v)
|
||||
int SDL_SetAtomicInt(SDL_AtomicInt *a, int v)
|
||||
{
|
||||
#ifdef HAVE_MSC_ATOMICS
|
||||
SDL_COMPILE_TIME_ASSERT(atomic_set, sizeof(long) == sizeof(a->value));
|
||||
|
@ -196,12 +196,12 @@ int SDL_AtomicSet(SDL_AtomicInt *a, int v)
|
|||
int value;
|
||||
do {
|
||||
value = a->value;
|
||||
} while (!SDL_AtomicCompareAndSwap(a, value, v));
|
||||
} while (!SDL_CompareAndSwapAtomicInt(a, value, v));
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
void *SDL_AtomicSetPointer(void **a, void *v)
|
||||
void *SDL_SetAtomicPointer(void **a, void *v)
|
||||
{
|
||||
#ifdef HAVE_MSC_ATOMICS
|
||||
return _InterlockedExchangePointer(a, v);
|
||||
|
@ -215,12 +215,12 @@ void *SDL_AtomicSetPointer(void **a, void *v)
|
|||
void *value;
|
||||
do {
|
||||
value = *a;
|
||||
} while (!SDL_AtomicCompareAndSwapPointer(a, value, v));
|
||||
} while (!SDL_CompareAndSwapAtomicPointer(a, value, v));
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
int SDL_AtomicAdd(SDL_AtomicInt *a, int v)
|
||||
int SDL_AddAtomicInt(SDL_AtomicInt *a, int v)
|
||||
{
|
||||
#ifdef HAVE_MSC_ATOMICS
|
||||
SDL_COMPILE_TIME_ASSERT(atomic_add, sizeof(long) == sizeof(a->value));
|
||||
|
@ -238,12 +238,12 @@ int SDL_AtomicAdd(SDL_AtomicInt *a, int v)
|
|||
int value;
|
||||
do {
|
||||
value = a->value;
|
||||
} while (!SDL_AtomicCompareAndSwap(a, value, (value + v)));
|
||||
} while (!SDL_CompareAndSwapAtomicInt(a, value, (value + v)));
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
int SDL_AtomicGet(SDL_AtomicInt *a)
|
||||
int SDL_GetAtomicInt(SDL_AtomicInt *a)
|
||||
{
|
||||
#ifdef HAVE_ATOMIC_LOAD_N
|
||||
return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST);
|
||||
|
@ -262,12 +262,12 @@ int SDL_AtomicGet(SDL_AtomicInt *a)
|
|||
int value;
|
||||
do {
|
||||
value = a->value;
|
||||
} while (!SDL_AtomicCompareAndSwap(a, value, value));
|
||||
} while (!SDL_CompareAndSwapAtomicInt(a, value, value));
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
void *SDL_AtomicGetPointer(void **a)
|
||||
void *SDL_GetAtomicPointer(void **a)
|
||||
{
|
||||
#ifdef HAVE_ATOMIC_LOAD_N
|
||||
return __atomic_load_n(a, __ATOMIC_SEQ_CST);
|
||||
|
@ -281,7 +281,7 @@ void *SDL_AtomicGetPointer(void **a)
|
|||
void *value;
|
||||
do {
|
||||
value = *a;
|
||||
} while (!SDL_AtomicCompareAndSwapPointer(a, value, value));
|
||||
} while (!SDL_CompareAndSwapAtomicPointer(a, value, value));
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ bool SDL_AudioSpecsEqual(const SDL_AudioSpec *a, const SDL_AudioSpec *b, const i
|
|||
// consumed and apps relying on audio callbacks don't stop making progress.
|
||||
static bool ZombieWaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
if (!SDL_AtomicGet(&device->shutdown)) {
|
||||
if (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
const int frames = device->buffer_size / SDL_AUDIO_FRAMESIZE(device->spec);
|
||||
SDL_Delay((frames * 1000) / device->spec.freq);
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ static SDL_LogicalAudioDevice *ObtainLogicalAudioDevice(SDL_AudioDeviceID devid,
|
|||
// to make sure the correct physical device gets locked, in case we're in a race with the default changing.
|
||||
while (true) {
|
||||
SDL_LockMutex(device->lock);
|
||||
SDL_AudioDevice *recheck_device = (SDL_AudioDevice *) SDL_AtomicGetPointer((void **) &logdev->physical_device);
|
||||
SDL_AudioDevice *recheck_device = (SDL_AudioDevice *) SDL_GetAtomicPointer((void **) &logdev->physical_device);
|
||||
if (device == recheck_device) {
|
||||
break;
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ void UnrefPhysicalAudioDevice(SDL_AudioDevice *device)
|
|||
// take it out of the device list.
|
||||
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
||||
if (SDL_RemoveFromHashTable(current_audio.device_hash, (const void *) (uintptr_t) device->instance_id)) {
|
||||
SDL_AtomicAdd(device->recording ? ¤t_audio.recording_device_count : ¤t_audio.playback_device_count, -1);
|
||||
SDL_AddAtomicInt(device->recording ? ¤t_audio.recording_device_count : ¤t_audio.playback_device_count, -1);
|
||||
}
|
||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||
DestroyPhysicalAudioDevice(device); // ...and nuke it.
|
||||
|
@ -576,7 +576,7 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, bool recordi
|
|||
SDL_assert(name != NULL);
|
||||
|
||||
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
||||
const int shutting_down = SDL_AtomicGet(¤t_audio.shutting_down);
|
||||
const int shutting_down = SDL_GetAtomicInt(¤t_audio.shutting_down);
|
||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||
if (shutting_down) {
|
||||
return NULL; // we're shutting down, don't add any devices that are hotplugged at the last possible moment.
|
||||
|
@ -608,8 +608,8 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, bool recordi
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&device->shutdown, 0);
|
||||
SDL_AtomicSet(&device->zombie, 0);
|
||||
SDL_SetAtomicInt(&device->shutdown, 0);
|
||||
SDL_SetAtomicInt(&device->zombie, 0);
|
||||
device->recording = recording;
|
||||
SDL_copyp(&device->spec, spec);
|
||||
SDL_copyp(&device->default_spec, spec);
|
||||
|
@ -621,7 +621,7 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, bool recordi
|
|||
|
||||
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
||||
if (SDL_InsertIntoHashTable(current_audio.device_hash, (const void *) (uintptr_t) device->instance_id, device)) {
|
||||
SDL_AtomicAdd(device_count, 1);
|
||||
SDL_AddAtomicInt(device_count, 1);
|
||||
} else {
|
||||
SDL_DestroyCondition(device->close_cond);
|
||||
SDL_DestroyMutex(device->lock);
|
||||
|
@ -711,7 +711,7 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device)
|
|||
const bool is_default_device = ((devid == current_audio.default_playback_device_id) || (devid == current_audio.default_recording_device_id));
|
||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||
|
||||
const bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
|
||||
const bool first_disconnect = SDL_CompareAndSwapAtomicInt(&device->zombie, 0, 1);
|
||||
if (first_disconnect) { // if already disconnected this device, don't do it twice.
|
||||
// Swap in "Zombie" versions of the usual platform interfaces, so the device will keep
|
||||
// making progress until the app closes it. Otherwise, streams might continue to
|
||||
|
@ -886,7 +886,7 @@ bool SDL_InitAudio(const char *driver_name)
|
|||
}
|
||||
|
||||
// make sure device IDs start at 2 (because of SDL2 legacy interface), but don't reset the counter on each init, in case the app is holding an old device ID somewhere.
|
||||
SDL_AtomicCompareAndSwap(&last_device_instance_id, 0, 2);
|
||||
SDL_CompareAndSwapAtomicInt(&last_device_instance_id, 0, 2);
|
||||
|
||||
SDL_ChooseAudioConverters();
|
||||
SDL_SetupAudioResampler();
|
||||
|
@ -1031,13 +1031,13 @@ void SDL_QuitAudio(void)
|
|||
}
|
||||
|
||||
SDL_LockRWLockForWriting(current_audio.device_hash_lock);
|
||||
SDL_AtomicSet(¤t_audio.shutting_down, 1);
|
||||
SDL_SetAtomicInt(¤t_audio.shutting_down, 1);
|
||||
SDL_HashTable *device_hash = current_audio.device_hash;
|
||||
current_audio.device_hash = NULL;
|
||||
SDL_PendingAudioDeviceEvent *pending_events = current_audio.pending_events.next;
|
||||
current_audio.pending_events.next = NULL;
|
||||
SDL_AtomicSet(¤t_audio.playback_device_count, 0);
|
||||
SDL_AtomicSet(¤t_audio.recording_device_count, 0);
|
||||
SDL_SetAtomicInt(¤t_audio.playback_device_count, 0);
|
||||
SDL_SetAtomicInt(¤t_audio.recording_device_count, 0);
|
||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||
|
||||
SDL_PendingAudioDeviceEvent *pending_next = NULL;
|
||||
|
@ -1094,7 +1094,7 @@ bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
|||
|
||||
SDL_LockMutex(device->lock);
|
||||
|
||||
if (SDL_AtomicGet(&device->shutdown)) {
|
||||
if (SDL_GetAtomicInt(&device->shutdown)) {
|
||||
SDL_UnlockMutex(device->lock);
|
||||
return false; // we're done, shut it down.
|
||||
}
|
||||
|
@ -1118,7 +1118,7 @@ bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
|||
// We should have updated this elsewhere if the format changed!
|
||||
SDL_assert(SDL_AudioSpecsEqual(&stream->dst_spec, &device->spec, stream->dst_chmap, device->chmap));
|
||||
|
||||
const int br = SDL_AtomicGet(&logdev->paused) ? 0 : SDL_GetAudioStreamDataAdjustGain(stream, device_buffer, buffer_size, logdev->gain);
|
||||
const int br = SDL_GetAtomicInt(&logdev->paused) ? 0 : SDL_GetAudioStreamDataAdjustGain(stream, device_buffer, buffer_size, logdev->gain);
|
||||
if (br < 0) { // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow.
|
||||
failed = true;
|
||||
SDL_memset(device_buffer, device->silence_value, buffer_size); // just supply silence to the device before we die.
|
||||
|
@ -1139,7 +1139,7 @@ bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
|
|||
SDL_memset(final_mix_buffer, '\0', work_buffer_size); // start with silence.
|
||||
|
||||
for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) {
|
||||
if (SDL_AtomicGet(&logdev->paused)) {
|
||||
if (SDL_GetAtomicInt(&logdev->paused)) {
|
||||
continue; // paused? Skip this logical device.
|
||||
}
|
||||
|
||||
|
@ -1202,7 +1202,7 @@ void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device)
|
|||
SDL_assert(!device->recording);
|
||||
const int frames = device->buffer_size / SDL_AUDIO_FRAMESIZE(device->spec);
|
||||
// Wait for the audio to drain if device didn't die.
|
||||
if (!SDL_AtomicGet(&device->zombie)) {
|
||||
if (!SDL_GetAtomicInt(&device->zombie)) {
|
||||
SDL_Delay(((frames * 1000) / device->spec.freq) * 2);
|
||||
}
|
||||
current_audio.impl.ThreadDeinit(device);
|
||||
|
@ -1242,7 +1242,7 @@ bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
|||
|
||||
SDL_LockMutex(device->lock);
|
||||
|
||||
if (SDL_AtomicGet(&device->shutdown)) {
|
||||
if (SDL_GetAtomicInt(&device->shutdown)) {
|
||||
SDL_UnlockMutex(device->lock);
|
||||
return false; // we're done, shut it down.
|
||||
}
|
||||
|
@ -1258,7 +1258,7 @@ bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
|
|||
failed = true;
|
||||
} else if (br > 0) { // queue the new data to each bound stream.
|
||||
for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) {
|
||||
if (SDL_AtomicGet(&logdev->paused)) {
|
||||
if (SDL_GetAtomicInt(&logdev->paused)) {
|
||||
continue; // paused? Skip this logical device.
|
||||
}
|
||||
|
||||
|
@ -1342,7 +1342,7 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, bool recording)
|
|||
if (SDL_GetCurrentAudioDriver()) {
|
||||
SDL_LockRWLockForReading(current_audio.device_hash_lock);
|
||||
{
|
||||
num_devices = SDL_AtomicGet(recording ? ¤t_audio.recording_device_count : ¤t_audio.playback_device_count);
|
||||
num_devices = SDL_GetAtomicInt(recording ? ¤t_audio.recording_device_count : ¤t_audio.playback_device_count);
|
||||
result = (SDL_AudioDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_AudioDeviceID));
|
||||
if (result) {
|
||||
int devs_seen = 0;
|
||||
|
@ -1490,7 +1490,7 @@ int *SDL_GetAudioDeviceChannelMap(SDL_AudioDeviceID devid, int *count)
|
|||
// BE CAREFUL WITH THIS.
|
||||
static void SerializePhysicalDeviceClose(SDL_AudioDevice *device)
|
||||
{
|
||||
while (SDL_AtomicGet(&device->shutdown)) {
|
||||
while (SDL_GetAtomicInt(&device->shutdown)) {
|
||||
SDL_WaitCondition(device->close_cond, device->lock);
|
||||
}
|
||||
}
|
||||
|
@ -1500,7 +1500,7 @@ static void ClosePhysicalAudioDevice(SDL_AudioDevice *device)
|
|||
{
|
||||
SerializePhysicalDeviceClose(device);
|
||||
|
||||
SDL_AtomicSet(&device->shutdown, 1);
|
||||
SDL_SetAtomicInt(&device->shutdown, 1);
|
||||
|
||||
// YOU MUST PROTECT KEY POINTS WITH SerializePhysicalDeviceClose() WHILE THE THREAD JOINS
|
||||
SDL_UnlockMutex(device->lock);
|
||||
|
@ -1517,7 +1517,7 @@ static void ClosePhysicalAudioDevice(SDL_AudioDevice *device)
|
|||
}
|
||||
|
||||
SDL_LockMutex(device->lock);
|
||||
SDL_AtomicSet(&device->shutdown, 0); // ready to go again.
|
||||
SDL_SetAtomicInt(&device->shutdown, 0); // ready to go again.
|
||||
SDL_BroadcastCondition(device->close_cond); // release anyone waiting in SerializePhysicalDeviceClose; they'll still block until we release device->lock, though.
|
||||
|
||||
SDL_aligned_free(device->work_buffer);
|
||||
|
@ -1630,7 +1630,7 @@ static bool OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
|
|||
}
|
||||
|
||||
// Just pretend to open a zombie device. It can still collect logical devices on a default device under the assumption they will all migrate when the default device is officially changed.
|
||||
if (SDL_AtomicGet(&device->zombie)) {
|
||||
if (SDL_GetAtomicInt(&device->zombie)) {
|
||||
return true; // Braaaaaaaaains.
|
||||
}
|
||||
|
||||
|
@ -1719,7 +1719,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
|||
|
||||
if (device) {
|
||||
SDL_LogicalAudioDevice *logdev = NULL;
|
||||
if (!wants_default && SDL_AtomicGet(&device->zombie)) {
|
||||
if (!wants_default && SDL_GetAtomicInt(&device->zombie)) {
|
||||
// uhoh, this device is undead, and just waiting to be cleaned up. Refuse explicit opens.
|
||||
SDL_SetError("Device was already lost and can't accept new opens");
|
||||
} else if ((logdev = (SDL_LogicalAudioDevice *) SDL_calloc(1, sizeof (SDL_LogicalAudioDevice))) == NULL) {
|
||||
|
@ -1728,7 +1728,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
|||
SDL_free(logdev);
|
||||
} else {
|
||||
RefPhysicalAudioDevice(device); // unref'd on successful SDL_CloseAudioDevice
|
||||
SDL_AtomicSet(&logdev->paused, 0);
|
||||
SDL_SetAtomicInt(&logdev->paused, 0);
|
||||
result = logdev->instance_id = AssignAudioDeviceInstanceId(device->recording, /*islogical=*/true);
|
||||
logdev->physical_device = device;
|
||||
logdev->gain = 1.0f;
|
||||
|
@ -1761,7 +1761,7 @@ static bool SetLogicalAudioDevicePauseState(SDL_AudioDeviceID devid, int value)
|
|||
SDL_AudioDevice *device = NULL;
|
||||
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device);
|
||||
if (logdev) {
|
||||
SDL_AtomicSet(&logdev->paused, value);
|
||||
SDL_SetAtomicInt(&logdev->paused, value);
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
return logdev ? true : false; // ObtainLogicalAudioDevice will have set an error.
|
||||
|
@ -1782,7 +1782,7 @@ SDL_bool SDL_AudioDevicePaused(SDL_AudioDeviceID devid)
|
|||
SDL_AudioDevice *device = NULL;
|
||||
SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device);
|
||||
bool result = false;
|
||||
if (logdev && SDL_AtomicGet(&logdev->paused)) {
|
||||
if (logdev && SDL_GetAtomicInt(&logdev->paused)) {
|
||||
result = true;
|
||||
}
|
||||
ReleaseAudioDevice(device);
|
||||
|
@ -2067,7 +2067,7 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au
|
|||
if (!logdev) { // this shouldn't happen, but just in case.
|
||||
failed = true;
|
||||
} else {
|
||||
SDL_AtomicSet(&logdev->paused, 1); // start the device paused, to match SDL2.
|
||||
SDL_SetAtomicInt(&logdev->paused, 1); // start the device paused, to match SDL2.
|
||||
|
||||
SDL_assert(device != NULL);
|
||||
const bool recording = device->recording;
|
||||
|
@ -2302,7 +2302,7 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
|||
new_default_device->logical_devices = logdev;
|
||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||
|
||||
SDL_assert(SDL_AtomicGet(¤t_default_device->refcount) > 1); // we should hold at least one extra reference to this device, beyond logical devices, during this phase...
|
||||
SDL_assert(SDL_GetAtomicInt(¤t_default_device->refcount) > 1); // we should hold at least one extra reference to this device, beyond logical devices, during this phase...
|
||||
RefPhysicalAudioDevice(new_default_device);
|
||||
UnrefPhysicalAudioDevice(current_default_device);
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ static void AAUDIO_errorCallback(AAudioStream *stream, void *userData, aaudio_re
|
|||
// You MUST NOT close the audio stream from this callback, so we cannot call SDL_AudioDeviceDisconnected here.
|
||||
// Just flag the device so we can kill it in PlayDevice instead.
|
||||
SDL_AudioDevice *device = (SDL_AudioDevice *) userData;
|
||||
SDL_AtomicSet(&device->hidden->error_callback_triggered, (int) error); // AAUDIO_OK is zero, so !triggered means no error.
|
||||
SDL_SetAtomicInt(&device->hidden->error_callback_triggered, (int) error); // AAUDIO_OK is zero, so !triggered means no error.
|
||||
SDL_SignalSemaphore(device->hidden->semaphore); // in case we're blocking in WaitDevice.
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ static Uint8 *AAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *bufsize)
|
|||
|
||||
static bool AAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
// this semaphore won't fire when the app is in the background (AAUDIO_PauseDevices was called).
|
||||
if (SDL_WaitSemaphoreTimeout(device->hidden->semaphore, 100)) {
|
||||
return true; // semaphore was signaled, let's go!
|
||||
|
@ -218,7 +218,7 @@ static bool AAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int
|
|||
struct SDL_PrivateAudioData *hidden = device->hidden;
|
||||
|
||||
// AAUDIO_dataCallback picks up our work and unblocks AAUDIO_WaitDevice. But make sure we didn't fail here.
|
||||
const aaudio_result_t err = (aaudio_result_t) SDL_AtomicGet(&hidden->error_callback_triggered);
|
||||
const aaudio_result_t err = (aaudio_result_t) SDL_GetAtomicInt(&hidden->error_callback_triggered);
|
||||
if (err) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "aaudio: Audio device triggered error %d (%s)", (int) err, ctx.AAudio_convertResultToText(err));
|
||||
|
||||
|
@ -237,8 +237,8 @@ static int AAUDIO_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen
|
|||
struct SDL_PrivateAudioData *hidden = device->hidden;
|
||||
|
||||
// AAUDIO_dataCallback picks up our work and unblocks AAUDIO_WaitDevice. But make sure we didn't fail here.
|
||||
if (SDL_AtomicGet(&hidden->error_callback_triggered)) {
|
||||
SDL_AtomicSet(&hidden->error_callback_triggered, 0);
|
||||
if (SDL_GetAtomicInt(&hidden->error_callback_triggered)) {
|
||||
SDL_SetAtomicInt(&hidden->error_callback_triggered, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ static bool BuildAAudioStream(SDL_AudioDevice *device)
|
|||
const bool recording = device->recording;
|
||||
aaudio_result_t res;
|
||||
|
||||
SDL_AtomicSet(&hidden->error_callback_triggered, 0);
|
||||
SDL_SetAtomicInt(&hidden->error_callback_triggered, 0);
|
||||
|
||||
AAudioStreamBuilder *builder = NULL;
|
||||
res = ctx.AAudio_createStreamBuilder(&builder);
|
||||
|
@ -388,7 +388,7 @@ static bool BuildAAudioStream(SDL_AudioDevice *device)
|
|||
// !!! FIXME: make this non-blocking!
|
||||
static void SDLCALL RequestAndroidPermissionBlockingCallback(void *userdata, const char *permission, SDL_bool granted)
|
||||
{
|
||||
SDL_AtomicSet((SDL_AtomicInt *) userdata, granted ? 1 : -1);
|
||||
SDL_SetAtomicInt((SDL_AtomicInt *) userdata, granted ? 1 : -1);
|
||||
}
|
||||
|
||||
static bool AAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
|
@ -402,16 +402,16 @@ static bool AAUDIO_OpenDevice(SDL_AudioDevice *device)
|
|||
if (device->recording) {
|
||||
// !!! FIXME: make this non-blocking!
|
||||
SDL_AtomicInt permission_response;
|
||||
SDL_AtomicSet(&permission_response, 0);
|
||||
SDL_SetAtomicInt(&permission_response, 0);
|
||||
if (!SDL_RequestAndroidPermission("android.permission.RECORD_AUDIO", RequestAndroidPermissionBlockingCallback, &permission_response)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (SDL_AtomicGet(&permission_response) == 0) {
|
||||
while (SDL_GetAtomicInt(&permission_response) == 0) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
if (SDL_AtomicGet(&permission_response) < 0) {
|
||||
if (SDL_GetAtomicInt(&permission_response) < 0) {
|
||||
LOGI("This app doesn't have RECORD_AUDIO permission");
|
||||
return SDL_SetError("This app doesn't have RECORD_AUDIO permission");
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ static bool ALSA_WaitDevice(SDL_AudioDevice *device)
|
|||
const int fulldelay = (int) ((((Uint64) device->sample_frames) * 1000) / device->spec.freq);
|
||||
const int delay = SDL_max(fulldelay, 10);
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
const int rc = ALSA_snd_pcm_wait(device->hidden->pcm_handle, delay);
|
||||
if (rc < 0 && (rc != -EAGAIN)) {
|
||||
const int status = ALSA_snd_pcm_recover(device->hidden->pcm_handle, rc, 0);
|
||||
|
@ -294,7 +294,7 @@ static bool ALSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int bu
|
|||
const int frame_size = SDL_AUDIO_FRAMESIZE(device->spec);
|
||||
snd_pcm_uframes_t frames_left = (snd_pcm_uframes_t) (buflen / frame_size);
|
||||
|
||||
while ((frames_left > 0) && !SDL_AtomicGet(&device->shutdown)) {
|
||||
while ((frames_left > 0) && !SDL_GetAtomicInt(&device->shutdown)) {
|
||||
const int rc = ALSA_snd_pcm_writei(device->hidden->pcm_handle, sample_buf, frames_left);
|
||||
//SDL_LogInfo(SDL_LOG_CATEGORY_AUDIO, "ALSA PLAYDEVICE: WROTE %d of %d bytes", (rc >= 0) ? ((int) (rc * frame_size)) : rc, (int) (frames_left * frame_size));
|
||||
SDL_assert(rc != 0); // assuming this can't happen if we used snd_pcm_wait and queried for available space.
|
||||
|
@ -825,10 +825,10 @@ static int SDLCALL ALSA_HotplugThread(void *arg)
|
|||
{
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW);
|
||||
|
||||
while (!SDL_AtomicGet(&ALSA_hotplug_shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&ALSA_hotplug_shutdown)) {
|
||||
// Block awhile before checking again, unless we're told to stop.
|
||||
const Uint64 ticks = SDL_GetTicks() + 5000;
|
||||
while (!SDL_AtomicGet(&ALSA_hotplug_shutdown) && SDL_GetTicks() < ticks) {
|
||||
while (!SDL_GetAtomicInt(&ALSA_hotplug_shutdown) && SDL_GetTicks() < ticks) {
|
||||
SDL_Delay(100);
|
||||
}
|
||||
|
||||
|
@ -853,7 +853,7 @@ static void ALSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevi
|
|||
}
|
||||
|
||||
#if SDL_ALSA_HOTPLUG_THREAD
|
||||
SDL_AtomicSet(&ALSA_hotplug_shutdown, 0);
|
||||
SDL_SetAtomicInt(&ALSA_hotplug_shutdown, 0);
|
||||
ALSA_hotplug_thread = SDL_CreateThread(ALSA_HotplugThread, "SDLHotplugALSA", NULL);
|
||||
// if the thread doesn't spin, oh well, you just don't get further hotplug events.
|
||||
#endif
|
||||
|
@ -866,7 +866,7 @@ static void ALSA_DeinitializeStart(void)
|
|||
|
||||
#if SDL_ALSA_HOTPLUG_THREAD
|
||||
if (ALSA_hotplug_thread) {
|
||||
SDL_AtomicSet(&ALSA_hotplug_shutdown, 1);
|
||||
SDL_SetAtomicInt(&ALSA_hotplug_shutdown, 1);
|
||||
SDL_WaitThread(ALSA_hotplug_thread, NULL);
|
||||
ALSA_hotplug_thread = NULL;
|
||||
}
|
||||
|
|
|
@ -622,7 +622,7 @@ static void RecordingBufferReadyCallback(void *inUserData, AudioQueueRef inAQ, A
|
|||
|
||||
// buffer is unexpectedly here? We're probably dying, but try to requeue this buffer anyhow.
|
||||
if (device->hidden->current_buffer != NULL) {
|
||||
SDL_assert(SDL_AtomicGet(&device->shutdown) != 0);
|
||||
SDL_assert(SDL_GetAtomicInt(&device->shutdown) != 0);
|
||||
COREAUDIO_FlushRecording(device); // just flush it manually, which will requeue it.
|
||||
}
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ static void COREAUDIO_CloseDevice(SDL_AudioDevice *device)
|
|||
}
|
||||
|
||||
if (device->hidden->thread) {
|
||||
SDL_assert(SDL_AtomicGet(&device->shutdown) != 0); // should have been set by SDL_audio.c
|
||||
SDL_assert(SDL_GetAtomicInt(&device->shutdown) != 0); // should have been set by SDL_audio.c
|
||||
SDL_WaitThread(device->hidden->thread, NULL);
|
||||
}
|
||||
|
||||
|
@ -839,7 +839,7 @@ static int AudioQueueThreadEntry(void *arg)
|
|||
SDL_SignalSemaphore(device->hidden->ready_semaphore);
|
||||
|
||||
// This would be WaitDevice/WaitRecordingDevice in the normal SDL audio thread, but we get *BufferReadyCallback calls here to know when to iterate.
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.10, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ static bool DSOUND_WaitDevice(SDL_AudioDevice *device)
|
|||
/* Semi-busy wait, since we have no way of getting play notification
|
||||
on a primary mixing buffer located in hardware (DirectX 5.0)
|
||||
*/
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
DWORD status = 0;
|
||||
DWORD cursor = 0;
|
||||
DWORD junk = 0;
|
||||
|
@ -336,7 +336,7 @@ static Uint8 *DSOUND_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
|
|||
static bool DSOUND_WaitRecordingDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = device->hidden;
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
DWORD junk, cursor;
|
||||
if (IDirectSoundCaptureBuffer_GetCurrentPosition(h->capturebuf, &junk, &cursor) != DS_OK) {
|
||||
return false;
|
||||
|
|
|
@ -204,7 +204,7 @@ static bool DSP_WaitDevice(SDL_AudioDevice *device)
|
|||
const unsigned long ioctlreq = device->recording ? SNDCTL_DSP_GETISPACE : SNDCTL_DSP_GETOSPACE;
|
||||
struct SDL_PrivateAudioData *h = device->hidden;
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
audio_buf_info info;
|
||||
const int rc = ioctl(h->audio_fd, ioctlreq, &info);
|
||||
if (rc < 0) {
|
||||
|
|
|
@ -203,7 +203,7 @@ static bool N3DSAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, i
|
|||
static bool N3DSAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
contextLock(device);
|
||||
while (!device->hidden->isCancelled && !SDL_AtomicGet(&device->shutdown) &&
|
||||
while (!device->hidden->isCancelled && !SDL_GetAtomicInt(&device->shutdown) &&
|
||||
device->hidden->waveBuf[device->hidden->nextbuf].status != NDSP_WBUF_FREE) {
|
||||
CondVar_Wait(&device->hidden->cv, &device->hidden->lock);
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ static void NETBSDAUDIO_Status(SDL_AudioDevice *device)
|
|||
static bool NETBSDAUDIO_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
const bool recording = device->recording;
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
audio_info_t info;
|
||||
const int rc = ioctl(device->hidden->audio_fd, AUDIO_GETINFO, &info);
|
||||
if (rc < 0) {
|
||||
|
|
|
@ -231,7 +231,7 @@ static void OPENSLES_DestroyPCMRecorder(SDL_AudioDevice *device)
|
|||
// !!! FIXME: make this non-blocking!
|
||||
static void SDLCALL RequestAndroidPermissionBlockingCallback(void *userdata, const char *permission, SDL_bool granted)
|
||||
{
|
||||
SDL_AtomicSet((SDL_AtomicInt *) userdata, granted ? 1 : -1);
|
||||
SDL_SetAtomicInt((SDL_AtomicInt *) userdata, granted ? 1 : -1);
|
||||
}
|
||||
|
||||
static bool OPENSLES_CreatePCMRecorder(SDL_AudioDevice *device)
|
||||
|
@ -250,16 +250,16 @@ static bool OPENSLES_CreatePCMRecorder(SDL_AudioDevice *device)
|
|||
// !!! FIXME: make this non-blocking!
|
||||
{
|
||||
SDL_AtomicInt permission_response;
|
||||
SDL_AtomicSet(&permission_response, 0);
|
||||
SDL_SetAtomicInt(&permission_response, 0);
|
||||
if (!SDL_RequestAndroidPermission("android.permission.RECORD_AUDIO", RequestAndroidPermissionBlockingCallback, &permission_response)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (SDL_AtomicGet(&permission_response) == 0) {
|
||||
while (SDL_GetAtomicInt(&permission_response) == 0) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
if (SDL_AtomicGet(&permission_response) < 0) {
|
||||
if (SDL_GetAtomicInt(&permission_response) < 0) {
|
||||
LOGE("This app doesn't have RECORD_AUDIO permission");
|
||||
return SDL_SetError("This app doesn't have RECORD_AUDIO permission");
|
||||
}
|
||||
|
@ -652,7 +652,7 @@ static bool OPENSLES_WaitDevice(SDL_AudioDevice *device)
|
|||
|
||||
LOGV("OPENSLES_WaitDevice()");
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
// this semaphore won't fire when the app is in the background (OPENSLES_PauseDevices was called).
|
||||
if (SDL_WaitSemaphoreTimeout(audiodata->playsem, 100)) {
|
||||
return true; // semaphore was signaled, let's go!
|
||||
|
|
|
@ -413,7 +413,7 @@ static bool PULSEAUDIO_WaitDevice(SDL_AudioDevice *device)
|
|||
|
||||
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown) && (h->bytes_requested == 0)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown) && (h->bytes_requested == 0)) {
|
||||
//SDL_Log("PULSEAUDIO WAIT IN WAITDEVICE!");
|
||||
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);
|
||||
|
||||
|
@ -486,7 +486,7 @@ static bool PULSEAUDIO_WaitRecordingDevice(SDL_AudioDevice *device)
|
|||
|
||||
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);
|
||||
if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) {
|
||||
//SDL_Log("PULSEAUDIO DEVICE FAILURE IN WAITRECORDINGDEVICE!");
|
||||
|
@ -553,7 +553,7 @@ static void PULSEAUDIO_FlushRecording(SDL_AudioDevice *device)
|
|||
h->recordinglen = 0;
|
||||
}
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown) && (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown) && (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0)) {
|
||||
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);
|
||||
if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) {
|
||||
//SDL_Log("PULSEAUDIO DEVICE FAILURE IN FLUSHRECORDING!");
|
||||
|
@ -901,7 +901,7 @@ static int SDLCALL HotplugThread(void *data)
|
|||
|
||||
SDL_SignalSemaphore((SDL_Semaphore *) data);
|
||||
|
||||
while (SDL_AtomicGet(&pulseaudio_hotplug_thread_active)) {
|
||||
while (SDL_GetAtomicInt(&pulseaudio_hotplug_thread_active)) {
|
||||
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);
|
||||
if (op && PULSEAUDIO_pa_operation_get_state(op) != PA_OPERATION_RUNNING) {
|
||||
PULSEAUDIO_pa_operation_unref(op);
|
||||
|
@ -956,12 +956,12 @@ static void PULSEAUDIO_DetectDevices(SDL_AudioDevice **default_playback, SDL_Aud
|
|||
}
|
||||
|
||||
// ok, we have a sane list, let's set up hotplug notifications now...
|
||||
SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 1);
|
||||
SDL_SetAtomicInt(&pulseaudio_hotplug_thread_active, 1);
|
||||
pulseaudio_hotplug_thread = SDL_CreateThread(HotplugThread, "PulseHotplug", ready_sem);
|
||||
if (pulseaudio_hotplug_thread) {
|
||||
SDL_WaitSemaphore(ready_sem); // wait until the thread hits it's main loop.
|
||||
} else {
|
||||
SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 0); // thread failed to start, we'll go on without hotplug.
|
||||
SDL_SetAtomicInt(&pulseaudio_hotplug_thread_active, 0); // thread failed to start, we'll go on without hotplug.
|
||||
}
|
||||
|
||||
SDL_DestroySemaphore(ready_sem);
|
||||
|
@ -978,7 +978,7 @@ static void PULSEAUDIO_DeinitializeStart(void)
|
|||
{
|
||||
if (pulseaudio_hotplug_thread) {
|
||||
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
|
||||
SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 0);
|
||||
SDL_SetAtomicInt(&pulseaudio_hotplug_thread_active, 0);
|
||||
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0);
|
||||
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
||||
SDL_WaitThread(pulseaudio_hotplug_thread, NULL);
|
||||
|
|
|
@ -112,14 +112,14 @@ static bool QSA_WaitDevice(SDL_AudioDevice *device)
|
|||
|
||||
static bool QSA_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen)
|
||||
{
|
||||
if (SDL_AtomicGet(&device->shutdown) || !device->hidden) {
|
||||
if (SDL_GetAtomicInt(&device->shutdown) || !device->hidden) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int towrite = buflen;
|
||||
|
||||
// Write the audio data, checking for EAGAIN (buffer full) and underrun
|
||||
while ((towrite > 0) && !SDL_AtomicGet(&device->shutdown));
|
||||
while ((towrite > 0) && !SDL_GetAtomicInt(&device->shutdown));
|
||||
const int bw = snd_pcm_plugin_write(device->hidden->audio_handle, buffer, towrite);
|
||||
if (bw != towrite) {
|
||||
// Check if samples playback got stuck somewhere in hardware or in the audio device driver
|
||||
|
|
|
@ -151,7 +151,7 @@ static bool SNDIO_WaitDevice(SDL_AudioDevice *device)
|
|||
{
|
||||
const bool recording = device->recording;
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
if (SNDIO_sio_eof(device->hidden->dev)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ static int SNDIO_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
|||
static void SNDIO_FlushRecording(SDL_AudioDevice *device)
|
||||
{
|
||||
char buf[512];
|
||||
while (!SDL_AtomicGet(&device->shutdown) && (SNDIO_sio_read(device->hidden->dev, buf, sizeof(buf)) > 0)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown) && (SNDIO_sio_read(device->hidden->dev, buf, sizeof(buf)) > 0)) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ static bool VITAAUD_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int
|
|||
static bool VITAAUD_WaitDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
// !!! FIXME: we might just need to sleep roughly as long as playback buffers take to process, based on sample rate, etc.
|
||||
while (!SDL_AtomicGet(&device->shutdown) && (sceAudioOutGetRestSample(device->hidden->port) >= device->buffer_size)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown) && (sceAudioOutGetRestSample(device->hidden->port) >= device->buffer_size)) {
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return true;
|
||||
|
@ -176,7 +176,7 @@ static bool VITAAUD_WaitRecordingDevice(SDL_AudioDevice *device)
|
|||
// there's only a blocking call to obtain more data, so we'll just sleep as
|
||||
// long as a buffer would run.
|
||||
const Uint64 endticks = SDL_GetTicks() + ((device->sample_frames * 1000) / device->spec.freq);
|
||||
while (!SDL_AtomicGet(&device->shutdown) && (SDL_GetTicks() < endticks)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown) && (SDL_GetTicks() < endticks)) {
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -74,11 +74,11 @@ static void ManagementThreadMainloop(void)
|
|||
{
|
||||
SDL_LockMutex(ManagementThreadLock);
|
||||
ManagementThreadPendingTask *task;
|
||||
while (((task = (ManagementThreadPendingTask *)SDL_AtomicGetPointer((void **)&ManagementThreadPendingTasks)) != NULL) || !SDL_AtomicGet(&ManagementThreadShutdown)) {
|
||||
while (((task = (ManagementThreadPendingTask *)SDL_GetAtomicPointer((void **)&ManagementThreadPendingTasks)) != NULL) || !SDL_GetAtomicInt(&ManagementThreadShutdown)) {
|
||||
if (!task) {
|
||||
SDL_WaitCondition(ManagementThreadCondition, ManagementThreadLock); // block until there's something to do.
|
||||
} else {
|
||||
SDL_AtomicSetPointer((void **) &ManagementThreadPendingTasks, task->next); // take task off the pending list.
|
||||
SDL_SetAtomicPointer((void **) &ManagementThreadPendingTasks, task->next); // take task off the pending list.
|
||||
SDL_UnlockMutex(ManagementThreadLock); // let other things add to the list while we chew on this task.
|
||||
task->result = task->fn(task->userdata); // run this task.
|
||||
if (task->task_complete_sem) { // something waiting on result?
|
||||
|
@ -101,7 +101,7 @@ bool WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, b
|
|||
return true; // completed!
|
||||
}
|
||||
|
||||
if (SDL_AtomicGet(&ManagementThreadShutdown)) {
|
||||
if (SDL_GetAtomicInt(&ManagementThreadShutdown)) {
|
||||
return SDL_SetError("Can't add task, we're shutting down");
|
||||
}
|
||||
|
||||
|
@ -127,14 +127,14 @@ bool WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, b
|
|||
|
||||
// add to end of task list.
|
||||
ManagementThreadPendingTask *prev = NULL;
|
||||
for (ManagementThreadPendingTask *i = (ManagementThreadPendingTask *)SDL_AtomicGetPointer((void **)&ManagementThreadPendingTasks); i; i = i->next) {
|
||||
for (ManagementThreadPendingTask *i = (ManagementThreadPendingTask *)SDL_GetAtomicPointer((void **)&ManagementThreadPendingTasks); i; i = i->next) {
|
||||
prev = i;
|
||||
}
|
||||
|
||||
if (prev) {
|
||||
prev->next = pending;
|
||||
} else {
|
||||
SDL_AtomicSetPointer((void **) &ManagementThreadPendingTasks, pending);
|
||||
SDL_SetAtomicPointer((void **) &ManagementThreadPendingTasks, pending);
|
||||
}
|
||||
|
||||
// task is added to the end of the pending list, let management thread rip!
|
||||
|
@ -210,8 +210,8 @@ static bool InitManagementThread(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
SDL_AtomicSetPointer((void **) &ManagementThreadPendingTasks, NULL);
|
||||
SDL_AtomicSet(&ManagementThreadShutdown, 0);
|
||||
SDL_SetAtomicPointer((void **) &ManagementThreadPendingTasks, NULL);
|
||||
SDL_SetAtomicInt(&ManagementThreadShutdown, 0);
|
||||
ManagementThread = SDL_CreateThreadWithStackSize(ManagementThreadEntry, "SDLWASAPIMgmt", 256 * 1024, &mgmtdata); // !!! FIXME: maybe even smaller stack size?
|
||||
if (!ManagementThread) {
|
||||
return false;
|
||||
|
@ -234,7 +234,7 @@ static bool InitManagementThread(void)
|
|||
static void DeinitManagementThread(void)
|
||||
{
|
||||
if (ManagementThread) {
|
||||
SDL_AtomicSet(&ManagementThreadShutdown, 1);
|
||||
SDL_SetAtomicInt(&ManagementThreadShutdown, 1);
|
||||
SDL_LockMutex(ManagementThreadLock);
|
||||
SDL_SignalCondition(ManagementThreadCondition);
|
||||
SDL_UnlockMutex(ManagementThreadLock);
|
||||
|
@ -242,13 +242,13 @@ static void DeinitManagementThread(void)
|
|||
ManagementThread = NULL;
|
||||
}
|
||||
|
||||
SDL_assert(SDL_AtomicGetPointer((void **) &ManagementThreadPendingTasks) == NULL);
|
||||
SDL_assert(SDL_GetAtomicPointer((void **) &ManagementThreadPendingTasks) == NULL);
|
||||
|
||||
SDL_DestroyCondition(ManagementThreadCondition);
|
||||
SDL_DestroyMutex(ManagementThreadLock);
|
||||
ManagementThreadCondition = NULL;
|
||||
ManagementThreadLock = NULL;
|
||||
SDL_AtomicSet(&ManagementThreadShutdown, 0);
|
||||
SDL_SetAtomicInt(&ManagementThreadShutdown, 0);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
@ -403,14 +403,14 @@ static bool RecoverWasapiDevice(SDL_AudioDevice *device)
|
|||
// do not call when holding the device lock!
|
||||
static bool RecoverWasapiIfLost(SDL_AudioDevice *device)
|
||||
{
|
||||
if (SDL_AtomicGet(&device->shutdown)) {
|
||||
if (SDL_GetAtomicInt(&device->shutdown)) {
|
||||
return false; // already failed.
|
||||
} else if (device->hidden->device_dead) { // had a fatal error elsewhere, clean up and quit
|
||||
IAudioClient_Stop(device->hidden->client);
|
||||
WASAPI_DisconnectDevice(device);
|
||||
SDL_assert(SDL_AtomicGet(&device->shutdown)); // so we don't come back through here.
|
||||
SDL_assert(SDL_GetAtomicInt(&device->shutdown)); // so we don't come back through here.
|
||||
return false; // already failed.
|
||||
} else if (SDL_AtomicGet(&device->zombie)) {
|
||||
} else if (SDL_GetAtomicInt(&device->zombie)) {
|
||||
return false; // we're already dead, so just leave and let the Zombie implementations take over.
|
||||
} else if (!device->hidden->client) {
|
||||
return true; // still waiting for activation.
|
||||
|
@ -538,7 +538,7 @@ static void WASAPI_FlushRecording(SDL_AudioDevice *device)
|
|||
DWORD flags = 0;
|
||||
|
||||
// just read until we stop getting packets, throwing them away.
|
||||
while (!SDL_AtomicGet(&device->shutdown) && device->hidden->capture) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown) && device->hidden->capture) {
|
||||
const HRESULT ret = IAudioCaptureClient_GetBuffer(device->hidden->capture, &ptr, &frames, &flags, NULL, NULL);
|
||||
if (ret == AUDCLNT_S_BUFFER_EMPTY) {
|
||||
break; // no more buffered data; we're done.
|
||||
|
|
|
@ -115,7 +115,7 @@ bool SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_
|
|||
// loss notifications will get black frames but otherwise keep functioning.
|
||||
static bool ZombieWaitDevice(SDL_Camera *device)
|
||||
{
|
||||
if (!SDL_AtomicGet(&device->shutdown)) {
|
||||
if (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
// !!! FIXME: this is bad for several reasons (uses double, could be precalculated, doesn't track elasped time).
|
||||
const double duration = ((double) device->actual_spec.framerate_denominator / ((double) device->actual_spec.framerate_numerator));
|
||||
SDL_Delay((Uint32) (duration * 1000.0));
|
||||
|
@ -230,7 +230,7 @@ static void ClosePhysicalCamera(SDL_Camera *device)
|
|||
return;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&device->shutdown, 1);
|
||||
SDL_SetAtomicInt(&device->shutdown, 1);
|
||||
|
||||
// !!! FIXME: the close_cond stuff from audio might help the race condition here.
|
||||
|
||||
|
@ -297,7 +297,7 @@ void UnrefPhysicalCamera(SDL_Camera *device)
|
|||
// take it out of the device list.
|
||||
SDL_LockRWLockForWriting(camera_driver.device_hash_lock);
|
||||
if (SDL_RemoveFromHashTable(camera_driver.device_hash, (const void *) (uintptr_t) device->instance_id)) {
|
||||
SDL_AtomicAdd(&camera_driver.device_count, -1);
|
||||
SDL_AddAtomicInt(&camera_driver.device_count, -1);
|
||||
}
|
||||
SDL_UnlockRWLock(camera_driver.device_hash_lock);
|
||||
DestroyPhysicalCamera(device); // ...and nuke it.
|
||||
|
@ -421,7 +421,7 @@ SDL_Camera *SDL_AddCamera(const char *name, SDL_CameraPosition position, int num
|
|||
SDL_assert(handle != NULL);
|
||||
|
||||
SDL_LockRWLockForReading(camera_driver.device_hash_lock);
|
||||
const int shutting_down = SDL_AtomicGet(&camera_driver.shutting_down);
|
||||
const int shutting_down = SDL_GetAtomicInt(&camera_driver.shutting_down);
|
||||
SDL_UnlockRWLock(camera_driver.device_hash_lock);
|
||||
if (shutting_down) {
|
||||
return NULL; // we're shutting down, don't add any devices that are hotplugged at the last possible moment.
|
||||
|
@ -488,13 +488,13 @@ SDL_Camera *SDL_AddCamera(const char *name, SDL_CameraPosition position, int num
|
|||
device->num_specs = num_specs;
|
||||
device->handle = handle;
|
||||
device->instance_id = SDL_GetNextObjectID();
|
||||
SDL_AtomicSet(&device->shutdown, 0);
|
||||
SDL_AtomicSet(&device->zombie, 0);
|
||||
SDL_SetAtomicInt(&device->shutdown, 0);
|
||||
SDL_SetAtomicInt(&device->zombie, 0);
|
||||
RefPhysicalCamera(device);
|
||||
|
||||
SDL_LockRWLockForWriting(camera_driver.device_hash_lock);
|
||||
if (SDL_InsertIntoHashTable(camera_driver.device_hash, (const void *) (uintptr_t) device->instance_id, device)) {
|
||||
SDL_AtomicAdd(&camera_driver.device_count, 1);
|
||||
SDL_AddAtomicInt(&camera_driver.device_count, 1);
|
||||
} else {
|
||||
SDL_DestroyMutex(device->lock);
|
||||
SDL_free(device->all_specs);
|
||||
|
@ -542,7 +542,7 @@ void SDL_CameraDisconnected(SDL_Camera *device)
|
|||
|
||||
ObtainPhysicalCameraObj(device);
|
||||
|
||||
const bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
|
||||
const bool first_disconnect = SDL_CompareAndSwapAtomicInt(&device->zombie, 0, 1);
|
||||
if (first_disconnect) { // if already disconnected this device, don't do it twice.
|
||||
// Swap in "Zombie" versions of the usual platform interfaces, so the device will keep
|
||||
// making progress until the app closes it. Otherwise, streams might continue to
|
||||
|
@ -713,7 +713,7 @@ SDL_CameraID *SDL_GetCameras(int *count)
|
|||
SDL_CameraID *result = NULL;
|
||||
|
||||
SDL_LockRWLockForReading(camera_driver.device_hash_lock);
|
||||
int num_devices = SDL_AtomicGet(&camera_driver.device_count);
|
||||
int num_devices = SDL_GetAtomicInt(&camera_driver.device_count);
|
||||
result = (SDL_CameraID *) SDL_malloc((num_devices + 1) * sizeof (SDL_CameraID));
|
||||
if (!result) {
|
||||
num_devices = 0;
|
||||
|
@ -792,7 +792,7 @@ bool SDL_CameraThreadIterate(SDL_Camera *device)
|
|||
{
|
||||
SDL_LockMutex(device->lock);
|
||||
|
||||
if (SDL_AtomicGet(&device->shutdown)) {
|
||||
if (SDL_GetAtomicInt(&device->shutdown)) {
|
||||
SDL_UnlockMutex(device->lock);
|
||||
return false; // we're done, shut it down.
|
||||
}
|
||||
|
@ -1078,7 +1078,7 @@ SDL_Camera *SDL_OpenCamera(SDL_CameraID instance_id, const SDL_CameraSpec *spec)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&device->shutdown, 0);
|
||||
SDL_SetAtomicInt(&device->shutdown, 0);
|
||||
|
||||
// These start with the backend's implementation, but we might swap them out with zombie versions later.
|
||||
device->WaitDevice = camera_driver.impl.WaitDevice;
|
||||
|
@ -1360,12 +1360,12 @@ void SDL_QuitCamera(void)
|
|||
}
|
||||
|
||||
SDL_LockRWLockForWriting(camera_driver.device_hash_lock);
|
||||
SDL_AtomicSet(&camera_driver.shutting_down, 1);
|
||||
SDL_SetAtomicInt(&camera_driver.shutting_down, 1);
|
||||
SDL_HashTable *device_hash = camera_driver.device_hash;
|
||||
camera_driver.device_hash = NULL;
|
||||
SDL_PendingCameraEvent *pending_events = camera_driver.pending_events.next;
|
||||
camera_driver.pending_events.next = NULL;
|
||||
SDL_AtomicSet(&camera_driver.device_count, 0);
|
||||
SDL_SetAtomicInt(&camera_driver.device_count, 0);
|
||||
SDL_UnlockRWLock(camera_driver.device_hash_lock);
|
||||
|
||||
SDL_PendingCameraEvent *pending_next = NULL;
|
||||
|
|
|
@ -354,7 +354,7 @@ static bool MEDIAFOUNDATION_WaitDevice(SDL_Camera *device)
|
|||
IMFSourceReader *srcreader = device->hidden->srcreader;
|
||||
IMFSample *sample = NULL;
|
||||
|
||||
while (!SDL_AtomicGet(&device->shutdown)) {
|
||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||
DWORD stream_flags = 0;
|
||||
const HRESULT ret = IMFSourceReader_ReadSample(srcreader, (DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, NULL, &stream_flags, NULL, &sample);
|
||||
if (FAILED(ret)) {
|
||||
|
|
|
@ -112,7 +112,7 @@ static bool V4L2_WaitDevice(SDL_Camera *device)
|
|||
}
|
||||
|
||||
// Thread is requested to shut down
|
||||
if (SDL_AtomicGet(&device->shutdown)) {
|
||||
if (SDL_GetAtomicInt(&device->shutdown)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -558,7 +558,7 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
|||
register_methods(env, "org/libsdl/app/SDLAudioManager", SDLAudioManager_tab, SDL_arraysize(SDLAudioManager_tab));
|
||||
register_methods(env, "org/libsdl/app/SDLControllerManager", SDLControllerManager_tab, SDL_arraysize(SDLControllerManager_tab));
|
||||
register_methods(env, "org/libsdl/app/HIDDeviceManager", HIDDeviceManager_tab, SDL_arraysize(HIDDeviceManager_tab));
|
||||
SDL_AtomicSet(&bAllowRecreateActivity, false);
|
||||
SDL_SetAtomicInt(&bAllowRecreateActivity, false);
|
||||
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
@ -761,16 +761,16 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeCheckSDLThreadCounter)(
|
|||
static void SDLCALL SDL_AllowRecreateActivityChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
if (SDL_GetStringBoolean(hint, false)) {
|
||||
SDL_AtomicSet(&bAllowRecreateActivity, true);
|
||||
SDL_SetAtomicInt(&bAllowRecreateActivity, true);
|
||||
} else {
|
||||
SDL_AtomicSet(&bAllowRecreateActivity, false);
|
||||
SDL_SetAtomicInt(&bAllowRecreateActivity, false);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(nativeAllowRecreateActivity)(
|
||||
JNIEnv *env, jclass jcls)
|
||||
{
|
||||
return SDL_AtomicGet(&bAllowRecreateActivity);
|
||||
return SDL_GetAtomicInt(&bAllowRecreateActivity);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeInitMainThread)(
|
||||
|
@ -1690,7 +1690,7 @@ static bool Android_JNI_ExceptionOccurred(bool silent)
|
|||
jthrowable exception;
|
||||
|
||||
// Detect mismatch LocalReferenceHolder_Init/Cleanup
|
||||
SDL_assert(SDL_AtomicGet(&s_active) > 0);
|
||||
SDL_assert(SDL_GetAtomicInt(&s_active) > 0);
|
||||
|
||||
exception = (*env)->ExceptionOccurred(env);
|
||||
if (exception != NULL) {
|
||||
|
@ -2539,7 +2539,7 @@ SDL_bool SDL_RequestAndroidPermission(const char *permission, SDL_RequestAndroid
|
|||
}
|
||||
|
||||
static SDL_AtomicInt next_request_code;
|
||||
info->request_code = SDL_AtomicAdd(&next_request_code, 1);
|
||||
info->request_code = SDL_AddAtomicInt(&next_request_code, 1);
|
||||
|
||||
info->callback = cb;
|
||||
info->userdata = userdata;
|
||||
|
@ -2798,7 +2798,7 @@ bool Android_JNI_OpenFileDialog(
|
|||
|
||||
// Setup data
|
||||
static SDL_AtomicInt next_request_code;
|
||||
mAndroidFileDialogData.request_code = SDL_AtomicAdd(&next_request_code, 1);
|
||||
mAndroidFileDialogData.request_code = SDL_AddAtomicInt(&next_request_code, 1);
|
||||
mAndroidFileDialogData.userdata = userdata;
|
||||
mAndroidFileDialogData.callback = callback;
|
||||
|
||||
|
@ -2808,7 +2808,7 @@ bool Android_JNI_OpenFileDialog(
|
|||
(*env)->DeleteLocalRef(env, filtersArray);
|
||||
if (!success) {
|
||||
mAndroidFileDialogData.callback = NULL;
|
||||
SDL_AtomicAdd(&next_request_code, -1);
|
||||
SDL_AddAtomicInt(&next_request_code, -1);
|
||||
SDL_SetError("Unspecified error in JNI");
|
||||
|
||||
return false;
|
||||
|
|
|
@ -313,12 +313,12 @@ typedef void (*signal_handler)(int signum);
|
|||
|
||||
static void kbd_vt_release_signal_action(int signum)
|
||||
{
|
||||
SDL_AtomicSet(&vt_signal_pending, VT_SIGNAL_RELEASE);
|
||||
SDL_SetAtomicInt(&vt_signal_pending, VT_SIGNAL_RELEASE);
|
||||
}
|
||||
|
||||
static void kbd_vt_acquire_signal_action(int signum)
|
||||
{
|
||||
SDL_AtomicSet(&vt_signal_pending, VT_SIGNAL_ACQUIRE);
|
||||
SDL_SetAtomicInt(&vt_signal_pending, VT_SIGNAL_ACQUIRE);
|
||||
}
|
||||
|
||||
static bool setup_vt_signal(int signum, signal_handler handler)
|
||||
|
@ -403,7 +403,7 @@ static bool kbd_vt_init(int console_fd)
|
|||
|
||||
static void kbd_vt_update(SDL_EVDEV_keyboard_state *state)
|
||||
{
|
||||
int signal_pending = SDL_AtomicGet(&vt_signal_pending);
|
||||
int signal_pending = SDL_GetAtomicInt(&vt_signal_pending);
|
||||
if (signal_pending != VT_SIGNAL_NONE) {
|
||||
if (signal_pending == VT_SIGNAL_RELEASE) {
|
||||
if (state->vt_release_callback) {
|
||||
|
@ -416,7 +416,7 @@ static void kbd_vt_update(SDL_EVDEV_keyboard_state *state)
|
|||
}
|
||||
ioctl(state->console_fd, VT_RELDISP, VT_ACKACQ);
|
||||
}
|
||||
SDL_AtomicCompareAndSwap(&vt_signal_pending, signal_pending, VT_SIGNAL_NONE);
|
||||
SDL_CompareAndSwapAtomicInt(&vt_signal_pending, signal_pending, VT_SIGNAL_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const bool recording, const char *devn
|
|||
// see if we already have this one first.
|
||||
SDL_AudioDevice *device = SDL_IMMDevice_FindByDevID(devid);
|
||||
if (device) {
|
||||
if (SDL_AtomicGet(&device->zombie)) {
|
||||
if (SDL_GetAtomicInt(&device->zombie)) {
|
||||
// whoa, it came back! This can happen if you unplug and replug USB headphones while we're still keeping the SDL object alive.
|
||||
// Kill this device's IMMDevice id; the device will go away when the app closes it, or maybe a new default device is chosen
|
||||
// (possibly this reconnected device), so we just want to make sure IMMDevice doesn't try to find the old device by the existing ID string.
|
||||
|
@ -209,7 +209,7 @@ static ULONG STDMETHODCALLTYPE SDLMMNotificationClient_Release(IMMNotificationCl
|
|||
SDLMMNotificationClient *client = (SDLMMNotificationClient *)iclient;
|
||||
const ULONG rc = SDL_AtomicDecRef(&client->refcount);
|
||||
if (rc == 0) {
|
||||
SDL_AtomicSet(&client->refcount, 0); // uhh...
|
||||
SDL_SetAtomicInt(&client->refcount, 0); // uhh...
|
||||
return 0;
|
||||
}
|
||||
return rc - 1;
|
||||
|
|
|
@ -5,6 +5,7 @@ SDL3_0.0.0 {
|
|||
SDL_AcquireCameraFrame;
|
||||
SDL_AcquireGPUCommandBuffer;
|
||||
SDL_AcquireGPUSwapchainTexture;
|
||||
SDL_AddAtomicInt;
|
||||
SDL_AddEventWatch;
|
||||
SDL_AddGamepadMapping;
|
||||
SDL_AddGamepadMappingsFromFile;
|
||||
|
@ -14,13 +15,6 @@ SDL3_0.0.0 {
|
|||
SDL_AddTimer;
|
||||
SDL_AddTimerNS;
|
||||
SDL_AddVulkanRenderSemaphores;
|
||||
SDL_AtomicAdd;
|
||||
SDL_AtomicCompareAndSwap;
|
||||
SDL_AtomicCompareAndSwapPointer;
|
||||
SDL_AtomicGet;
|
||||
SDL_AtomicGetPointer;
|
||||
SDL_AtomicSet;
|
||||
SDL_AtomicSetPointer;
|
||||
SDL_AttachVirtualJoystick;
|
||||
SDL_AudioDevicePaused;
|
||||
SDL_BeginGPUComputePass;
|
||||
|
@ -67,6 +61,8 @@ SDL3_0.0.0 {
|
|||
SDL_CloseJoystick;
|
||||
SDL_CloseSensor;
|
||||
SDL_CloseStorage;
|
||||
SDL_CompareAndSwapAtomicInt;
|
||||
SDL_CompareAndSwapAtomicPointer;
|
||||
SDL_ComposeCustomBlendMode;
|
||||
SDL_ConvertAudioSamples;
|
||||
SDL_ConvertEventToRenderCoordinates;
|
||||
|
@ -217,6 +213,8 @@ SDL3_0.0.0 {
|
|||
SDL_GetAppMetadataProperty;
|
||||
SDL_GetAssertionHandler;
|
||||
SDL_GetAssertionReport;
|
||||
SDL_GetAtomicInt;
|
||||
SDL_GetAtomicPointer;
|
||||
SDL_GetAudioDeviceChannelMap;
|
||||
SDL_GetAudioDeviceFormat;
|
||||
SDL_GetAudioDeviceGain;
|
||||
|
@ -780,6 +778,8 @@ SDL3_0.0.0 {
|
|||
SDL_SetAppMetadata;
|
||||
SDL_SetAppMetadataProperty;
|
||||
SDL_SetAssertionHandler;
|
||||
SDL_SetAtomicInt;
|
||||
SDL_SetAtomicPointer;
|
||||
SDL_SetAudioDeviceGain;
|
||||
SDL_SetAudioPostmixCallback;
|
||||
SDL_SetAudioStreamFormat;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#define SDL_AcquireCameraFrame SDL_AcquireCameraFrame_REAL
|
||||
#define SDL_AcquireGPUCommandBuffer SDL_AcquireGPUCommandBuffer_REAL
|
||||
#define SDL_AcquireGPUSwapchainTexture SDL_AcquireGPUSwapchainTexture_REAL
|
||||
#define SDL_AddAtomicInt SDL_AddAtomicInt_REAL
|
||||
#define SDL_AddEventWatch SDL_AddEventWatch_REAL
|
||||
#define SDL_AddGamepadMapping SDL_AddGamepadMapping_REAL
|
||||
#define SDL_AddGamepadMappingsFromFile SDL_AddGamepadMappingsFromFile_REAL
|
||||
|
@ -39,13 +40,6 @@
|
|||
#define SDL_AddTimer SDL_AddTimer_REAL
|
||||
#define SDL_AddTimerNS SDL_AddTimerNS_REAL
|
||||
#define SDL_AddVulkanRenderSemaphores SDL_AddVulkanRenderSemaphores_REAL
|
||||
#define SDL_AtomicAdd SDL_AtomicAdd_REAL
|
||||
#define SDL_AtomicCompareAndSwap SDL_AtomicCompareAndSwap_REAL
|
||||
#define SDL_AtomicCompareAndSwapPointer SDL_AtomicCompareAndSwapPointer_REAL
|
||||
#define SDL_AtomicGet SDL_AtomicGet_REAL
|
||||
#define SDL_AtomicGetPointer SDL_AtomicGetPointer_REAL
|
||||
#define SDL_AtomicSet SDL_AtomicSet_REAL
|
||||
#define SDL_AtomicSetPointer SDL_AtomicSetPointer_REAL
|
||||
#define SDL_AttachVirtualJoystick SDL_AttachVirtualJoystick_REAL
|
||||
#define SDL_AudioDevicePaused SDL_AudioDevicePaused_REAL
|
||||
#define SDL_BeginGPUComputePass SDL_BeginGPUComputePass_REAL
|
||||
|
@ -92,6 +86,8 @@
|
|||
#define SDL_CloseJoystick SDL_CloseJoystick_REAL
|
||||
#define SDL_CloseSensor SDL_CloseSensor_REAL
|
||||
#define SDL_CloseStorage SDL_CloseStorage_REAL
|
||||
#define SDL_CompareAndSwapAtomicInt SDL_CompareAndSwapAtomicInt_REAL
|
||||
#define SDL_CompareAndSwapAtomicPointer SDL_CompareAndSwapAtomicPointer_REAL
|
||||
#define SDL_ComposeCustomBlendMode SDL_ComposeCustomBlendMode_REAL
|
||||
#define SDL_ConvertAudioSamples SDL_ConvertAudioSamples_REAL
|
||||
#define SDL_ConvertEventToRenderCoordinates SDL_ConvertEventToRenderCoordinates_REAL
|
||||
|
@ -242,6 +238,8 @@
|
|||
#define SDL_GetAppMetadataProperty SDL_GetAppMetadataProperty_REAL
|
||||
#define SDL_GetAssertionHandler SDL_GetAssertionHandler_REAL
|
||||
#define SDL_GetAssertionReport SDL_GetAssertionReport_REAL
|
||||
#define SDL_GetAtomicInt SDL_GetAtomicInt_REAL
|
||||
#define SDL_GetAtomicPointer SDL_GetAtomicPointer_REAL
|
||||
#define SDL_GetAudioDeviceChannelMap SDL_GetAudioDeviceChannelMap_REAL
|
||||
#define SDL_GetAudioDeviceFormat SDL_GetAudioDeviceFormat_REAL
|
||||
#define SDL_GetAudioDeviceGain SDL_GetAudioDeviceGain_REAL
|
||||
|
@ -805,6 +803,8 @@
|
|||
#define SDL_SetAppMetadata SDL_SetAppMetadata_REAL
|
||||
#define SDL_SetAppMetadataProperty SDL_SetAppMetadataProperty_REAL
|
||||
#define SDL_SetAssertionHandler SDL_SetAssertionHandler_REAL
|
||||
#define SDL_SetAtomicInt SDL_SetAtomicInt_REAL
|
||||
#define SDL_SetAtomicPointer SDL_SetAtomicPointer_REAL
|
||||
#define SDL_SetAudioDeviceGain SDL_SetAudioDeviceGain_REAL
|
||||
#define SDL_SetAudioPostmixCallback SDL_SetAudioPostmixCallback_REAL
|
||||
#define SDL_SetAudioStreamFormat SDL_SetAudioStreamFormat_REAL
|
||||
|
|
|
@ -51,6 +51,7 @@ SDL_DYNAPI_PROC(int,SDL_swprintf,(SDL_OUT_Z_CAP(b) wchar_t *a, size_t b, SDL_PRI
|
|||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_AcquireCameraFrame,(SDL_Camera *a, Uint64 *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_GPUCommandBuffer*,SDL_AcquireGPUCommandBuffer,(SDL_GPUDevice *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_GPUTexture*,SDL_AcquireGPUSwapchainTexture,(SDL_GPUCommandBuffer *a, SDL_Window *b, Uint32 *c, Uint32 *d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_AddAtomicInt,(SDL_AtomicInt *a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_AddEventWatch,(SDL_EventFilter a, void *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_AddGamepadMapping,(const char *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_AddGamepadMappingsFromFile,(const char *a),(a),return)
|
||||
|
@ -60,13 +61,6 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_AddSurfaceAlternateImage,(SDL_Surface *a, SDL_Surfa
|
|||
SDL_DYNAPI_PROC(SDL_TimerID,SDL_AddTimer,(Uint32 a, SDL_TimerCallback b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_TimerID,SDL_AddTimerNS,(Uint64 a, SDL_NSTimerCallback b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_AddVulkanRenderSemaphores,(SDL_Renderer *a, Uint32 b, Sint64 c, Sint64 d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_AtomicAdd,(SDL_AtomicInt *a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicCompareAndSwap,(SDL_AtomicInt *a, int b, int c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicCompareAndSwapPointer,(void **a, void *b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_AtomicGet,(SDL_AtomicInt *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void*,SDL_AtomicGetPointer,(void **a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_AtomicSet,(SDL_AtomicInt *a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(void*,SDL_AtomicSetPointer,(void **a, void *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_JoystickID,SDL_AttachVirtualJoystick,(const SDL_VirtualJoystickDesc *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_AudioDevicePaused,(SDL_AudioDeviceID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_GPUComputePass*,SDL_BeginGPUComputePass,(SDL_GPUCommandBuffer *a, const SDL_GPUStorageTextureWriteOnlyBinding *b, Uint32 c, const SDL_GPUStorageBufferWriteOnlyBinding *d, Uint32 e),(a,b,c,d,e),return)
|
||||
|
@ -113,6 +107,8 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_CloseIO,(SDL_IOStream *a),(a),return)
|
|||
SDL_DYNAPI_PROC(void,SDL_CloseJoystick,(SDL_Joystick *a),(a),)
|
||||
SDL_DYNAPI_PROC(void,SDL_CloseSensor,(SDL_Sensor *a),(a),)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_CloseStorage,(SDL_Storage *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_CompareAndSwapAtomicInt,(SDL_AtomicInt *a, int b, int c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_CompareAndSwapAtomicPointer,(void **a, void *b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_ConvertAudioSamples,(const SDL_AudioSpec *a, const Uint8 *b, int c, const SDL_AudioSpec *d, Uint8 **e, int *f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_ConvertEventToRenderCoordinates,(SDL_Renderer *a, SDL_Event *b),(a,b),return)
|
||||
|
@ -263,6 +259,8 @@ SDL_DYNAPI_PROC(int,SDL_GetAndroidSDKVersion,(void),(),return)
|
|||
SDL_DYNAPI_PROC(const char*,SDL_GetAppMetadataProperty,(const char *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetAssertionHandler,(void **a),(a),return)
|
||||
SDL_DYNAPI_PROC(const SDL_AssertData*,SDL_GetAssertionReport,(void),(),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetAtomicInt,(SDL_AtomicInt *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void*,SDL_GetAtomicPointer,(void **a),(a),return)
|
||||
SDL_DYNAPI_PROC(int*,SDL_GetAudioDeviceChannelMap,(SDL_AudioDeviceID a, int *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetAudioDeviceFormat,(SDL_AudioDeviceID a, SDL_AudioSpec *b, int *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(float,SDL_GetAudioDeviceGain,(SDL_AudioDeviceID a),(a),return)
|
||||
|
@ -816,6 +814,8 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_SendJoystickVirtualSensorData,(SDL_Joystick *a, SDL
|
|||
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAppMetadata,(const char *a, const char *b, const char *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAppMetadataProperty,(const char *a, const char *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_SetAssertionHandler,(SDL_AssertionHandler a, void *b),(a,b),)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetAtomicInt,(SDL_AtomicInt *a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(void*,SDL_SetAtomicPointer,(void **a, void *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioDeviceGain,(SDL_AudioDeviceID a, float b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioPostmixCallback,(SDL_AudioDeviceID a, SDL_AudioPostmixCallback b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_SetAudioStreamFormat,(SDL_AudioStream *a, const SDL_AudioSpec *b, const SDL_AudioSpec *c),(a,b,c),return)
|
||||
|
|
|
@ -852,12 +852,12 @@ void SDL_StopEventLoop(void)
|
|||
entry = next;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&SDL_EventQ.count, 0);
|
||||
SDL_SetAtomicInt(&SDL_EventQ.count, 0);
|
||||
SDL_EventQ.max_events_seen = 0;
|
||||
SDL_EventQ.head = NULL;
|
||||
SDL_EventQ.tail = NULL;
|
||||
SDL_EventQ.free = NULL;
|
||||
SDL_AtomicSet(&SDL_sentinel_pending, 0);
|
||||
SDL_SetAtomicInt(&SDL_sentinel_pending, 0);
|
||||
|
||||
// Clear disabled event state
|
||||
for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
|
||||
|
@ -921,7 +921,7 @@ bool SDL_StartEventLoop(void)
|
|||
static int SDL_AddEvent(SDL_Event *event)
|
||||
{
|
||||
SDL_EventEntry *entry;
|
||||
const int initial_count = SDL_AtomicGet(&SDL_EventQ.count);
|
||||
const int initial_count = SDL_GetAtomicInt(&SDL_EventQ.count);
|
||||
int final_count;
|
||||
|
||||
if (initial_count >= SDL_MAX_QUEUED_EVENTS) {
|
||||
|
@ -945,7 +945,7 @@ static int SDL_AddEvent(SDL_Event *event)
|
|||
|
||||
SDL_copyp(&entry->event, event);
|
||||
if (event->type == SDL_EVENT_POLL_SENTINEL) {
|
||||
SDL_AtomicAdd(&SDL_sentinel_pending, 1);
|
||||
SDL_AddAtomicInt(&SDL_sentinel_pending, 1);
|
||||
}
|
||||
entry->memory = NULL;
|
||||
SDL_TransferTemporaryMemoryToEvent(entry);
|
||||
|
@ -963,7 +963,7 @@ static int SDL_AddEvent(SDL_Event *event)
|
|||
entry->next = NULL;
|
||||
}
|
||||
|
||||
final_count = SDL_AtomicAdd(&SDL_EventQ.count, 1) + 1;
|
||||
final_count = SDL_AddAtomicInt(&SDL_EventQ.count, 1) + 1;
|
||||
if (final_count > SDL_EventQ.max_events_seen) {
|
||||
SDL_EventQ.max_events_seen = final_count;
|
||||
}
|
||||
|
@ -995,13 +995,13 @@ static void SDL_CutEvent(SDL_EventEntry *entry)
|
|||
}
|
||||
|
||||
if (entry->event.type == SDL_EVENT_POLL_SENTINEL) {
|
||||
SDL_AtomicAdd(&SDL_sentinel_pending, -1);
|
||||
SDL_AddAtomicInt(&SDL_sentinel_pending, -1);
|
||||
}
|
||||
|
||||
entry->next = SDL_EventQ.free;
|
||||
SDL_EventQ.free = entry;
|
||||
SDL_assert(SDL_AtomicGet(&SDL_EventQ.count) > 0);
|
||||
SDL_AtomicAdd(&SDL_EventQ.count, -1);
|
||||
SDL_assert(SDL_GetAtomicInt(&SDL_EventQ.count) > 0);
|
||||
SDL_AddAtomicInt(&SDL_EventQ.count, -1);
|
||||
}
|
||||
|
||||
static void SDL_SendWakeupEvent(void)
|
||||
|
@ -1079,7 +1079,7 @@ static int SDL_PeepEventsInternal(SDL_Event *events, int numevents, SDL_EventAct
|
|||
if (events == NULL || action != SDL_GETEVENT) {
|
||||
++sentinels_expected;
|
||||
}
|
||||
if (SDL_AtomicGet(&SDL_sentinel_pending) > sentinels_expected) {
|
||||
if (SDL_GetAtomicInt(&SDL_sentinel_pending) > sentinels_expected) {
|
||||
// Skip it, there's another one pending
|
||||
continue;
|
||||
}
|
||||
|
@ -1198,7 +1198,7 @@ static void SDL_PumpEventsInternal(bool push_sentinel)
|
|||
SDL_Event sentinel;
|
||||
|
||||
// Make sure we don't already have a sentinel in the queue, and add one to the end
|
||||
if (SDL_AtomicGet(&SDL_sentinel_pending) > 0) {
|
||||
if (SDL_GetAtomicInt(&SDL_sentinel_pending) > 0) {
|
||||
SDL_PeepEventsInternal(&sentinel, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, true);
|
||||
}
|
||||
|
||||
|
@ -1362,7 +1362,7 @@ SDL_bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS)
|
|||
}
|
||||
|
||||
// If there isn't a poll sentinel event pending, pump events and add one
|
||||
if (SDL_AtomicGet(&SDL_sentinel_pending) == 0) {
|
||||
if (SDL_GetAtomicInt(&SDL_sentinel_pending) == 0) {
|
||||
SDL_PumpEventsInternal(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -343,7 +343,7 @@ void SDL_SendPenTouch(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window
|
|||
send_event = true;
|
||||
}
|
||||
|
||||
pen->input_state = input_state; // we could do an SDL_AtomicSet here if we run into trouble...
|
||||
pen->input_state = input_state; // we could do an SDL_SetAtomicInt here if we run into trouble...
|
||||
}
|
||||
SDL_UnlockRWLock(pen_device_rwlock);
|
||||
|
||||
|
@ -383,7 +383,7 @@ void SDL_SendPenAxis(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window *
|
|||
SDL_Pen *pen = FindPenByInstanceId(instance_id);
|
||||
if (pen) {
|
||||
if (pen->axes[axis] != value) {
|
||||
pen->axes[axis] = value; // we could do an SDL_AtomicSet here if we run into trouble...
|
||||
pen->axes[axis] = value; // we could do an SDL_SetAtomicInt here if we run into trouble...
|
||||
input_state = pen->input_state;
|
||||
x = pen->x;
|
||||
y = pen->y;
|
||||
|
@ -421,8 +421,8 @@ void SDL_SendPenMotion(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window
|
|||
SDL_Pen *pen = FindPenByInstanceId(instance_id);
|
||||
if (pen) {
|
||||
if ((pen->x != x) || (pen->y != y)) {
|
||||
pen->x = x; // we could do an SDL_AtomicSet here if we run into trouble...
|
||||
pen->y = y; // we could do an SDL_AtomicSet here if we run into trouble...
|
||||
pen->x = x; // we could do an SDL_SetAtomicInt here if we run into trouble...
|
||||
pen->y = y; // we could do an SDL_SetAtomicInt here if we run into trouble...
|
||||
input_state = pen->input_state;
|
||||
send_event = true;
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ void SDL_SendPenButton(Uint64 timestamp, SDL_PenID instance_id, const SDL_Window
|
|||
input_state &= ~flag;
|
||||
send_event = true;
|
||||
}
|
||||
pen->input_state = input_state; // we could do an SDL_AtomicSet here if we run into trouble...
|
||||
pen->input_state = input_state; // we could do an SDL_SetAtomicInt here if we run into trouble...
|
||||
}
|
||||
SDL_UnlockRWLock(pen_device_rwlock);
|
||||
|
||||
|
|
|
@ -2028,7 +2028,7 @@ static D3D11Texture *D3D11_INTERNAL_CreateTexture(
|
|||
d3d11Texture = (D3D11Texture *)SDL_malloc(sizeof(D3D11Texture));
|
||||
d3d11Texture->handle = textureHandle;
|
||||
d3d11Texture->shaderView = srv;
|
||||
SDL_AtomicSet(&d3d11Texture->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&d3d11Texture->referenceCount, 0);
|
||||
d3d11Texture->container = NULL;
|
||||
d3d11Texture->containerIndex = 0;
|
||||
|
||||
|
@ -2204,7 +2204,7 @@ static void D3D11_INTERNAL_CycleActiveTexture(
|
|||
D3D11TextureContainer *container)
|
||||
{
|
||||
for (Uint32 i = 0; i < container->textureCount; i += 1) {
|
||||
if (SDL_AtomicGet(&container->textures[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&container->textures[i]->referenceCount) == 0) {
|
||||
container->activeTexture = container->textures[i];
|
||||
return;
|
||||
}
|
||||
|
@ -2270,7 +2270,7 @@ static D3D11TextureSubresource *D3D11_INTERNAL_PrepareTextureSubresourceForWrite
|
|||
if (
|
||||
container->canBeCycled &&
|
||||
cycle &&
|
||||
SDL_AtomicGet(&subresource->parent->referenceCount) > 0) {
|
||||
SDL_GetAtomicInt(&subresource->parent->referenceCount) > 0) {
|
||||
D3D11_INTERNAL_CycleActiveTexture(
|
||||
renderer,
|
||||
container);
|
||||
|
@ -2351,7 +2351,7 @@ static D3D11Buffer *D3D11_INTERNAL_CreateBuffer(
|
|||
d3d11Buffer->size = size;
|
||||
d3d11Buffer->uav = uav;
|
||||
d3d11Buffer->srv = srv;
|
||||
SDL_AtomicSet(&d3d11Buffer->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&d3d11Buffer->referenceCount, 0);
|
||||
|
||||
return d3d11Buffer;
|
||||
}
|
||||
|
@ -2460,7 +2460,7 @@ static void D3D11_INTERNAL_CycleActiveBuffer(
|
|||
Uint32 size = container->activeBuffer->size;
|
||||
|
||||
for (Uint32 i = 0; i < container->bufferCount; i += 1) {
|
||||
if (SDL_AtomicGet(&container->buffers[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&container->buffers[i]->referenceCount) == 0) {
|
||||
container->activeBuffer = container->buffers[i];
|
||||
return;
|
||||
}
|
||||
|
@ -2496,7 +2496,7 @@ static D3D11Buffer *D3D11_INTERNAL_PrepareBufferForWrite(
|
|||
{
|
||||
if (
|
||||
cycle &&
|
||||
SDL_AtomicGet(&container->activeBuffer->referenceCount) > 0) {
|
||||
SDL_GetAtomicInt(&container->activeBuffer->referenceCount) > 0) {
|
||||
D3D11_INTERNAL_CycleActiveBuffer(
|
||||
renderer,
|
||||
container);
|
||||
|
@ -2513,7 +2513,7 @@ static D3D11TransferBuffer *D3D11_INTERNAL_CreateTransferBuffer(
|
|||
|
||||
transferBuffer->data = (Uint8 *)SDL_malloc(size);
|
||||
transferBuffer->size = size;
|
||||
SDL_AtomicSet(&transferBuffer->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&transferBuffer->referenceCount, 0);
|
||||
|
||||
transferBuffer->bufferDownloads = NULL;
|
||||
transferBuffer->bufferDownloadCount = 0;
|
||||
|
@ -2558,7 +2558,7 @@ static void D3D11_INTERNAL_CycleActiveTransferBuffer(
|
|||
Uint32 size = container->activeBuffer->size;
|
||||
|
||||
for (Uint32 i = 0; i < container->bufferCount; i += 1) {
|
||||
if (SDL_AtomicGet(&container->buffers[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&container->buffers[i]->referenceCount) == 0) {
|
||||
container->activeBuffer = container->buffers[i];
|
||||
return;
|
||||
}
|
||||
|
@ -2591,7 +2591,7 @@ static void *D3D11_MapTransferBuffer(
|
|||
// Rotate the transfer buffer if necessary
|
||||
if (
|
||||
cycle &&
|
||||
SDL_AtomicGet(&container->activeBuffer->referenceCount) > 0) {
|
||||
SDL_GetAtomicInt(&container->activeBuffer->referenceCount) > 0) {
|
||||
D3D11_INTERNAL_CycleActiveTransferBuffer(
|
||||
renderer,
|
||||
container);
|
||||
|
@ -3126,7 +3126,7 @@ static bool D3D11_INTERNAL_CreateFence(
|
|||
|
||||
fence = SDL_malloc(sizeof(D3D11Fence));
|
||||
fence->handle = queryHandle;
|
||||
SDL_AtomicSet(&fence->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&fence->referenceCount, 0);
|
||||
|
||||
// Add it to the available pool
|
||||
if (renderer->availableFenceCount >= renderer->availableFenceCapacity) {
|
||||
|
@ -4839,7 +4839,7 @@ static void D3D11_INTERNAL_PerformPendingDestroys(
|
|||
for (i = renderer->transferBufferContainersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
referenceCount = 0;
|
||||
for (j = 0; j < renderer->transferBufferContainersToDestroy[i]->bufferCount; j += 1) {
|
||||
referenceCount += SDL_AtomicGet(&renderer->transferBufferContainersToDestroy[i]->buffers[j]->referenceCount);
|
||||
referenceCount += SDL_GetAtomicInt(&renderer->transferBufferContainersToDestroy[i]->buffers[j]->referenceCount);
|
||||
}
|
||||
|
||||
if (referenceCount == 0) {
|
||||
|
@ -4854,7 +4854,7 @@ static void D3D11_INTERNAL_PerformPendingDestroys(
|
|||
for (i = renderer->bufferContainersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
referenceCount = 0;
|
||||
for (j = 0; j < renderer->bufferContainersToDestroy[i]->bufferCount; j += 1) {
|
||||
referenceCount += SDL_AtomicGet(&renderer->bufferContainersToDestroy[i]->buffers[j]->referenceCount);
|
||||
referenceCount += SDL_GetAtomicInt(&renderer->bufferContainersToDestroy[i]->buffers[j]->referenceCount);
|
||||
}
|
||||
|
||||
if (referenceCount == 0) {
|
||||
|
@ -4869,7 +4869,7 @@ static void D3D11_INTERNAL_PerformPendingDestroys(
|
|||
for (i = renderer->textureContainersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
referenceCount = 0;
|
||||
for (j = 0; j < renderer->textureContainersToDestroy[i]->textureCount; j += 1) {
|
||||
referenceCount += SDL_AtomicGet(&renderer->textureContainersToDestroy[i]->textures[j]->referenceCount);
|
||||
referenceCount += SDL_GetAtomicInt(&renderer->textureContainersToDestroy[i]->textures[j]->referenceCount);
|
||||
}
|
||||
|
||||
if (referenceCount == 0) {
|
||||
|
@ -5038,7 +5038,7 @@ static bool D3D11_INTERNAL_InitializeSwapchainTexture(
|
|||
// Fill out the texture struct
|
||||
pTexture->handle = NULL; // This will be set in AcquireSwapchainTexture.
|
||||
pTexture->shaderView = NULL; // We don't allow swapchain texture to be sampled
|
||||
SDL_AtomicSet(&pTexture->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&pTexture->referenceCount, 0);
|
||||
pTexture->subresourceCount = 1;
|
||||
pTexture->subresources = SDL_malloc(sizeof(D3D11TextureSubresource));
|
||||
pTexture->subresources[0].colorTargetViews = SDL_calloc(1, sizeof(ID3D11RenderTargetView *));
|
||||
|
|
|
@ -2397,7 +2397,7 @@ static SDL_GPUComputePipeline *D3D12_CreateComputePipeline(
|
|||
computePipeline->numWriteOnlyStorageTextures = createinfo->num_writeonly_storage_textures;
|
||||
computePipeline->numWriteOnlyStorageBuffers = createinfo->num_writeonly_storage_buffers;
|
||||
computePipeline->numUniformBuffers = createinfo->num_uniform_buffers;
|
||||
SDL_AtomicSet(&computePipeline->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&computePipeline->referenceCount, 0);
|
||||
|
||||
return (SDL_GPUComputePipeline *)computePipeline;
|
||||
}
|
||||
|
@ -2679,7 +2679,7 @@ static SDL_GPUGraphicsPipeline *D3D12_CreateGraphicsPipeline(
|
|||
pipeline->fragmentStorageBufferCount = fragShader->numStorageBuffers;
|
||||
pipeline->fragmentUniformBufferCount = fragShader->numUniformBuffers;
|
||||
|
||||
SDL_AtomicSet(&pipeline->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&pipeline->referenceCount, 0);
|
||||
return (SDL_GPUGraphicsPipeline *)pipeline;
|
||||
}
|
||||
|
||||
|
@ -2724,7 +2724,7 @@ static SDL_GPUSampler *D3D12_CreateSampler(
|
|||
sampler->handle.cpuHandle);
|
||||
|
||||
sampler->createInfo = *createinfo;
|
||||
SDL_AtomicSet(&sampler->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&sampler->referenceCount, 0);
|
||||
return (SDL_GPUSampler *)sampler;
|
||||
}
|
||||
|
||||
|
@ -2917,7 +2917,7 @@ static D3D12Texture *D3D12_INTERNAL_CreateTexture(
|
|||
texture->srvHandle.cpuHandle);
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&texture->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&texture->referenceCount, 0);
|
||||
|
||||
texture->subresourceCount = createinfo->num_levels * layerCount;
|
||||
texture->subresources = (D3D12TextureSubresource *)SDL_calloc(
|
||||
|
@ -3200,7 +3200,7 @@ static D3D12Buffer *D3D12_INTERNAL_CreateBuffer(
|
|||
}
|
||||
|
||||
buffer->handle = handle;
|
||||
SDL_AtomicSet(&buffer->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&buffer->referenceCount, 0);
|
||||
|
||||
buffer->uavDescriptor.heap = NULL;
|
||||
buffer->srvDescriptor.heap = NULL;
|
||||
|
@ -3294,7 +3294,7 @@ static D3D12Buffer *D3D12_INTERNAL_CreateBuffer(
|
|||
buffer->containerIndex = 0;
|
||||
|
||||
buffer->transitioned = initialState != D3D12_RESOURCE_STATE_COMMON;
|
||||
SDL_AtomicSet(&buffer->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&buffer->referenceCount, 0);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -3734,7 +3734,7 @@ static void D3D12_INTERNAL_CycleActiveTexture(
|
|||
for (Uint32 i = 0; i < container->textureCount; i += 1) {
|
||||
texture = container->textures[i];
|
||||
|
||||
if (SDL_AtomicGet(&texture->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&texture->referenceCount) == 0) {
|
||||
container->activeTexture = texture;
|
||||
return;
|
||||
}
|
||||
|
@ -3789,7 +3789,7 @@ static D3D12TextureSubresource *D3D12_INTERNAL_PrepareTextureSubresourceForWrite
|
|||
if (
|
||||
container->canBeCycled &&
|
||||
cycle &&
|
||||
SDL_AtomicGet(&subresource->parent->referenceCount) > 0) {
|
||||
SDL_GetAtomicInt(&subresource->parent->referenceCount) > 0) {
|
||||
D3D12_INTERNAL_CycleActiveTexture(
|
||||
commandBuffer->renderer,
|
||||
container);
|
||||
|
@ -3815,7 +3815,7 @@ static void D3D12_INTERNAL_CycleActiveBuffer(
|
|||
// If a previously-cycled buffer is available, we can use that.
|
||||
for (Uint32 i = 0; i < container->bufferCount; i += 1) {
|
||||
D3D12Buffer *buffer = container->buffers[i];
|
||||
if (SDL_AtomicGet(&buffer->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&buffer->referenceCount) == 0) {
|
||||
container->activeBuffer = buffer;
|
||||
return;
|
||||
}
|
||||
|
@ -3863,7 +3863,7 @@ static D3D12Buffer *D3D12_INTERNAL_PrepareBufferForWrite(
|
|||
{
|
||||
if (
|
||||
cycle &&
|
||||
SDL_AtomicGet(&container->activeBuffer->referenceCount) > 0) {
|
||||
SDL_GetAtomicInt(&container->activeBuffer->referenceCount) > 0) {
|
||||
D3D12_INTERNAL_CycleActiveBuffer(
|
||||
commandBuffer->renderer,
|
||||
container);
|
||||
|
@ -5320,7 +5320,7 @@ static void *D3D12_MapTransferBuffer(
|
|||
|
||||
if (
|
||||
cycle &&
|
||||
SDL_AtomicGet(&container->activeBuffer->referenceCount) > 0) {
|
||||
SDL_GetAtomicInt(&container->activeBuffer->referenceCount) > 0) {
|
||||
D3D12_INTERNAL_CycleActiveBuffer(
|
||||
renderer,
|
||||
container);
|
||||
|
@ -6177,7 +6177,7 @@ static bool D3D12_INTERNAL_InitializeSwapchainTexture(
|
|||
return false;
|
||||
}
|
||||
pTexture->resource = NULL; // This will be set in AcquireSwapchainTexture
|
||||
SDL_AtomicSet(&pTexture->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&pTexture->referenceCount, 0);
|
||||
pTexture->subresourceCount = 1;
|
||||
pTexture->subresources = (D3D12TextureSubresource *)SDL_calloc(1, sizeof(D3D12TextureSubresource));
|
||||
if (!pTexture->subresources) {
|
||||
|
@ -6671,7 +6671,7 @@ static D3D12Fence *D3D12_INTERNAL_AcquireFence(
|
|||
}
|
||||
fence->handle = handle;
|
||||
fence->event = CreateEventEx(NULL, 0, 0, EVENT_ALL_ACCESS);
|
||||
SDL_AtomicSet(&fence->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&fence->referenceCount, 0);
|
||||
} else {
|
||||
fence = renderer->availableFences[renderer->availableFenceCount - 1];
|
||||
renderer->availableFenceCount -= 1;
|
||||
|
@ -7000,7 +7000,7 @@ static void D3D12_INTERNAL_PerformPendingDestroys(D3D12Renderer *renderer)
|
|||
SDL_LockMutex(renderer->disposeLock);
|
||||
|
||||
for (Sint32 i = renderer->buffersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->buffersToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->buffersToDestroy[i]->referenceCount) == 0) {
|
||||
D3D12_INTERNAL_DestroyBuffer(
|
||||
renderer,
|
||||
renderer->buffersToDestroy[i]);
|
||||
|
@ -7011,7 +7011,7 @@ static void D3D12_INTERNAL_PerformPendingDestroys(D3D12Renderer *renderer)
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->texturesToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->texturesToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->texturesToDestroy[i]->referenceCount) == 0) {
|
||||
D3D12_INTERNAL_DestroyTexture(
|
||||
renderer,
|
||||
renderer->texturesToDestroy[i]);
|
||||
|
@ -7022,7 +7022,7 @@ static void D3D12_INTERNAL_PerformPendingDestroys(D3D12Renderer *renderer)
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->samplersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->samplersToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->samplersToDestroy[i]->referenceCount) == 0) {
|
||||
D3D12_INTERNAL_DestroySampler(
|
||||
renderer,
|
||||
renderer->samplersToDestroy[i]);
|
||||
|
@ -7033,7 +7033,7 @@ static void D3D12_INTERNAL_PerformPendingDestroys(D3D12Renderer *renderer)
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->graphicsPipelinesToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->graphicsPipelinesToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->graphicsPipelinesToDestroy[i]->referenceCount) == 0) {
|
||||
D3D12_INTERNAL_DestroyGraphicsPipeline(
|
||||
renderer->graphicsPipelinesToDestroy[i]);
|
||||
|
||||
|
@ -7043,7 +7043,7 @@ static void D3D12_INTERNAL_PerformPendingDestroys(D3D12Renderer *renderer)
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->computePipelinesToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->computePipelinesToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->computePipelinesToDestroy[i]->referenceCount) == 0) {
|
||||
D3D12_INTERNAL_DestroyComputePipeline(
|
||||
renderer->computePipelinesToDestroy[i]);
|
||||
|
||||
|
|
|
@ -1361,7 +1361,7 @@ static MetalTexture *METAL_INTERNAL_CreateTexture(
|
|||
|
||||
metalTexture = (MetalTexture *)SDL_calloc(1, sizeof(MetalTexture));
|
||||
metalTexture->handle = texture;
|
||||
SDL_AtomicSet(&metalTexture->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&metalTexture->referenceCount, 0);
|
||||
return metalTexture;
|
||||
}
|
||||
|
||||
|
@ -1421,7 +1421,7 @@ static MetalTexture *METAL_INTERNAL_PrepareTextureForWrite(
|
|||
// Cycle the active texture handle if needed
|
||||
if (cycle && container->canBeCycled) {
|
||||
for (i = 0; i < container->textureCount; i += 1) {
|
||||
if (SDL_AtomicGet(&container->textures[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&container->textures[i]->referenceCount) == 0) {
|
||||
container->activeTexture = container->textures[i];
|
||||
return container->activeTexture;
|
||||
}
|
||||
|
@ -1469,7 +1469,7 @@ static MetalBuffer *METAL_INTERNAL_CreateBuffer(
|
|||
|
||||
metalBuffer = SDL_calloc(1, sizeof(MetalBuffer));
|
||||
metalBuffer->handle = bufferHandle;
|
||||
SDL_AtomicSet(&metalBuffer->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&metalBuffer->referenceCount, 0);
|
||||
|
||||
return metalBuffer;
|
||||
}
|
||||
|
@ -1572,9 +1572,9 @@ static MetalBuffer *METAL_INTERNAL_PrepareBufferForWrite(
|
|||
Uint32 i;
|
||||
|
||||
// Cycle if needed
|
||||
if (cycle && SDL_AtomicGet(&container->activeBuffer->referenceCount) > 0) {
|
||||
if (cycle && SDL_GetAtomicInt(&container->activeBuffer->referenceCount) > 0) {
|
||||
for (i = 0; i < container->bufferCount; i += 1) {
|
||||
if (SDL_AtomicGet(&container->buffers[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&container->buffers[i]->referenceCount) == 0) {
|
||||
container->activeBuffer = container->buffers[i];
|
||||
return container->activeBuffer;
|
||||
}
|
||||
|
@ -1945,7 +1945,7 @@ static Uint8 METAL_INTERNAL_CreateFence(
|
|||
MetalFence *fence;
|
||||
|
||||
fence = SDL_calloc(1, sizeof(MetalFence));
|
||||
SDL_AtomicSet(&fence->complete, 0);
|
||||
SDL_SetAtomicInt(&fence->complete, 0);
|
||||
|
||||
// Add it to the available pool
|
||||
// FIXME: Should this be EXPAND_IF_NEEDED?
|
||||
|
@ -1987,7 +1987,7 @@ static Uint8 METAL_INTERNAL_AcquireFence(
|
|||
|
||||
// Associate the fence with the command buffer
|
||||
commandBuffer->fence = fence;
|
||||
SDL_AtomicSet(&fence->complete, 0); // FIXME: Is this right?
|
||||
SDL_SetAtomicInt(&fence->complete, 0); // FIXME: Is this right?
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -3297,7 +3297,7 @@ static void METAL_INTERNAL_PerformPendingDestroys(
|
|||
for (i = renderer->bufferContainersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
referenceCount = 0;
|
||||
for (j = 0; j < renderer->bufferContainersToDestroy[i]->bufferCount; j += 1) {
|
||||
referenceCount += SDL_AtomicGet(&renderer->bufferContainersToDestroy[i]->buffers[j]->referenceCount);
|
||||
referenceCount += SDL_GetAtomicInt(&renderer->bufferContainersToDestroy[i]->buffers[j]->referenceCount);
|
||||
}
|
||||
|
||||
if (referenceCount == 0) {
|
||||
|
@ -3312,7 +3312,7 @@ static void METAL_INTERNAL_PerformPendingDestroys(
|
|||
for (i = renderer->textureContainersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
referenceCount = 0;
|
||||
for (j = 0; j < renderer->textureContainersToDestroy[i]->textureCount; j += 1) {
|
||||
referenceCount += SDL_AtomicGet(&renderer->textureContainersToDestroy[i]->textures[j]->referenceCount);
|
||||
referenceCount += SDL_GetAtomicInt(&renderer->textureContainersToDestroy[i]->textures[j]->referenceCount);
|
||||
}
|
||||
|
||||
if (referenceCount == 0) {
|
||||
|
@ -3339,7 +3339,7 @@ static void METAL_WaitForFences(
|
|||
|
||||
if (waitAll) {
|
||||
for (Uint32 i = 0; i < numFences; i += 1) {
|
||||
while (!SDL_AtomicGet(&((MetalFence *)fences[i])->complete)) {
|
||||
while (!SDL_GetAtomicInt(&((MetalFence *)fences[i])->complete)) {
|
||||
// Spin!
|
||||
}
|
||||
}
|
||||
|
@ -3347,7 +3347,7 @@ static void METAL_WaitForFences(
|
|||
waiting = 1;
|
||||
while (waiting) {
|
||||
for (Uint32 i = 0; i < numFences; i += 1) {
|
||||
if (SDL_AtomicGet(&((MetalFence *)fences[i])->complete) > 0) {
|
||||
if (SDL_GetAtomicInt(&((MetalFence *)fences[i])->complete) > 0) {
|
||||
waiting = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -3364,7 +3364,7 @@ static bool METAL_QueryFence(
|
|||
SDL_GPUFence *fence)
|
||||
{
|
||||
MetalFence *metalFence = (MetalFence *)fence;
|
||||
return SDL_AtomicGet(&metalFence->complete) == 1;
|
||||
return SDL_GetAtomicInt(&metalFence->complete) == 1;
|
||||
}
|
||||
|
||||
// Window and Swapchain Management
|
||||
|
@ -3688,7 +3688,7 @@ static void METAL_Submit(
|
|||
|
||||
// Check if we can perform any cleanups
|
||||
for (Sint32 i = renderer->submittedCommandBufferCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->submittedCommandBuffers[i]->fence->complete)) {
|
||||
if (SDL_GetAtomicInt(&renderer->submittedCommandBuffers[i]->fence->complete)) {
|
||||
METAL_INTERNAL_CleanCommandBuffer(
|
||||
renderer,
|
||||
renderer->submittedCommandBuffers[i]);
|
||||
|
@ -3725,7 +3725,7 @@ static void METAL_Wait(
|
|||
* Sort of equivalent to vkDeviceWaitIdle.
|
||||
*/
|
||||
for (Uint32 i = 0; i < renderer->submittedCommandBufferCount; i += 1) {
|
||||
while (!SDL_AtomicGet(&renderer->submittedCommandBuffers[i]->fence->complete)) {
|
||||
while (!SDL_GetAtomicInt(&renderer->submittedCommandBuffers[i]->fence->complete)) {
|
||||
// Spin!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3991,7 +3991,7 @@ static VulkanBuffer *VULKAN_INTERNAL_CreateBuffer(
|
|||
|
||||
buffer->usedRegion->vulkanBuffer = buffer; // lol
|
||||
|
||||
SDL_AtomicSet(&buffer->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&buffer->referenceCount, 0);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
@ -4563,7 +4563,7 @@ static bool VULKAN_INTERNAL_CreateSwapchain(
|
|||
swapchainData->textureContainers[i].activeTexture->depth = 1;
|
||||
swapchainData->textureContainers[i].activeTexture->usage = SDL_GPU_TEXTUREUSAGE_COLOR_TARGET;
|
||||
swapchainData->textureContainers[i].activeTexture->container = &swapchainData->textureContainers[i];
|
||||
SDL_AtomicSet(&swapchainData->textureContainers[i].activeTexture->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&swapchainData->textureContainers[i].activeTexture->referenceCount, 0);
|
||||
|
||||
// Create slice
|
||||
swapchainData->textureContainers[i].activeTexture->subresourceCount = 1;
|
||||
|
@ -5450,7 +5450,7 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture(
|
|||
texture->depth = depth;
|
||||
texture->usage = createinfo->usage;
|
||||
texture->fullView = VK_NULL_HANDLE;
|
||||
SDL_AtomicSet(&texture->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&texture->referenceCount, 0);
|
||||
|
||||
if (IsDepthFormat(createinfo->format)) {
|
||||
texture->aspectFlags = VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
|
@ -5648,7 +5648,7 @@ static void VULKAN_INTERNAL_CycleActiveBuffer(
|
|||
// If a previously-cycled buffer is available, we can use that.
|
||||
for (Uint32 i = 0; i < container->bufferCount; i += 1) {
|
||||
buffer = container->buffers[i];
|
||||
if (SDL_AtomicGet(&buffer->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&buffer->referenceCount) == 0) {
|
||||
container->activeBuffer = buffer;
|
||||
return;
|
||||
}
|
||||
|
@ -5698,7 +5698,7 @@ static void VULKAN_INTERNAL_CycleActiveTexture(
|
|||
for (Uint32 i = 0; i < container->textureCount; i += 1) {
|
||||
texture = container->textures[i];
|
||||
|
||||
if (SDL_AtomicGet(&texture->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&texture->referenceCount) == 0) {
|
||||
container->activeTexture = texture;
|
||||
return;
|
||||
}
|
||||
|
@ -5745,7 +5745,7 @@ static VulkanBuffer *VULKAN_INTERNAL_PrepareBufferForWrite(
|
|||
{
|
||||
if (
|
||||
cycle &&
|
||||
SDL_AtomicGet(&bufferContainer->activeBuffer->referenceCount) > 0) {
|
||||
SDL_GetAtomicInt(&bufferContainer->activeBuffer->referenceCount) > 0) {
|
||||
VULKAN_INTERNAL_CycleActiveBuffer(
|
||||
renderer,
|
||||
bufferContainer);
|
||||
|
@ -5777,7 +5777,7 @@ static VulkanTextureSubresource *VULKAN_INTERNAL_PrepareTextureSubresourceForWri
|
|||
if (
|
||||
cycle &&
|
||||
textureContainer->canBeCycled &&
|
||||
SDL_AtomicGet(&textureContainer->activeTexture->referenceCount) > 0) {
|
||||
SDL_GetAtomicInt(&textureContainer->activeTexture->referenceCount) > 0) {
|
||||
VULKAN_INTERNAL_CycleActiveTexture(
|
||||
renderer,
|
||||
textureContainer);
|
||||
|
@ -6345,7 +6345,7 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&graphicsPipeline->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&graphicsPipeline->referenceCount, 0);
|
||||
|
||||
return (SDL_GPUGraphicsPipeline *)graphicsPipeline;
|
||||
}
|
||||
|
@ -6446,7 +6446,7 @@ static SDL_GPUComputePipeline *VULKAN_CreateComputePipeline(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&vulkanComputePipeline->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&vulkanComputePipeline->referenceCount, 0);
|
||||
|
||||
return (SDL_GPUComputePipeline *)vulkanComputePipeline;
|
||||
}
|
||||
|
@ -6491,7 +6491,7 @@ static SDL_GPUSampler *VULKAN_CreateSampler(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&vulkanSampler->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&vulkanSampler->referenceCount, 0);
|
||||
|
||||
return (SDL_GPUSampler *)vulkanSampler;
|
||||
}
|
||||
|
@ -6535,7 +6535,7 @@ static SDL_GPUShader *VULKAN_CreateShader(
|
|||
vulkanShader->numStorageBuffers = createinfo->num_storage_buffers;
|
||||
vulkanShader->numUniformBuffers = createinfo->num_uniform_buffers;
|
||||
|
||||
SDL_AtomicSet(&vulkanShader->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&vulkanShader->referenceCount, 0);
|
||||
|
||||
return (SDL_GPUShader *)vulkanShader;
|
||||
}
|
||||
|
@ -6983,7 +6983,7 @@ static VulkanFramebuffer *VULKAN_INTERNAL_FetchFramebuffer(
|
|||
|
||||
vulkanFramebuffer = SDL_malloc(sizeof(VulkanFramebuffer));
|
||||
|
||||
SDL_AtomicSet(&vulkanFramebuffer->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&vulkanFramebuffer->referenceCount, 0);
|
||||
|
||||
// Create a new framebuffer
|
||||
|
||||
|
@ -8407,7 +8407,7 @@ static void *VULKAN_MapTransferBuffer(
|
|||
|
||||
if (
|
||||
cycle &&
|
||||
SDL_AtomicGet(&transferBufferContainer->activeBuffer->referenceCount) > 0) {
|
||||
SDL_GetAtomicInt(&transferBufferContainer->activeBuffer->referenceCount) > 0) {
|
||||
VULKAN_INTERNAL_CycleActiveBuffer(
|
||||
renderer,
|
||||
transferBufferContainer);
|
||||
|
@ -9821,7 +9821,7 @@ static VulkanFenceHandle *VULKAN_INTERNAL_AcquireFenceFromPool(
|
|||
|
||||
handle = SDL_malloc(sizeof(VulkanFenceHandle));
|
||||
handle->fence = fence;
|
||||
SDL_AtomicSet(&handle->referenceCount, 0);
|
||||
SDL_SetAtomicInt(&handle->referenceCount, 0);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -9850,7 +9850,7 @@ static void VULKAN_INTERNAL_PerformPendingDestroys(
|
|||
SDL_LockMutex(renderer->disposeLock);
|
||||
|
||||
for (Sint32 i = renderer->texturesToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->texturesToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->texturesToDestroy[i]->referenceCount) == 0) {
|
||||
VULKAN_INTERNAL_DestroyTexture(
|
||||
renderer,
|
||||
renderer->texturesToDestroy[i]);
|
||||
|
@ -9861,7 +9861,7 @@ static void VULKAN_INTERNAL_PerformPendingDestroys(
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->buffersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->buffersToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->buffersToDestroy[i]->referenceCount) == 0) {
|
||||
VULKAN_INTERNAL_DestroyBuffer(
|
||||
renderer,
|
||||
renderer->buffersToDestroy[i]);
|
||||
|
@ -9872,7 +9872,7 @@ static void VULKAN_INTERNAL_PerformPendingDestroys(
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->graphicsPipelinesToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->graphicsPipelinesToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->graphicsPipelinesToDestroy[i]->referenceCount) == 0) {
|
||||
VULKAN_INTERNAL_DestroyGraphicsPipeline(
|
||||
renderer,
|
||||
renderer->graphicsPipelinesToDestroy[i]);
|
||||
|
@ -9883,7 +9883,7 @@ static void VULKAN_INTERNAL_PerformPendingDestroys(
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->computePipelinesToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->computePipelinesToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->computePipelinesToDestroy[i]->referenceCount) == 0) {
|
||||
VULKAN_INTERNAL_DestroyComputePipeline(
|
||||
renderer,
|
||||
renderer->computePipelinesToDestroy[i]);
|
||||
|
@ -9894,7 +9894,7 @@ static void VULKAN_INTERNAL_PerformPendingDestroys(
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->shadersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->shadersToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->shadersToDestroy[i]->referenceCount) == 0) {
|
||||
VULKAN_INTERNAL_DestroyShader(
|
||||
renderer,
|
||||
renderer->shadersToDestroy[i]);
|
||||
|
@ -9905,7 +9905,7 @@ static void VULKAN_INTERNAL_PerformPendingDestroys(
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->samplersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->samplersToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->samplersToDestroy[i]->referenceCount) == 0) {
|
||||
VULKAN_INTERNAL_DestroySampler(
|
||||
renderer,
|
||||
renderer->samplersToDestroy[i]);
|
||||
|
@ -9916,7 +9916,7 @@ static void VULKAN_INTERNAL_PerformPendingDestroys(
|
|||
}
|
||||
|
||||
for (Sint32 i = renderer->framebuffersToDestroyCount - 1; i >= 0; i -= 1) {
|
||||
if (SDL_AtomicGet(&renderer->framebuffersToDestroy[i]->referenceCount) == 0) {
|
||||
if (SDL_GetAtomicInt(&renderer->framebuffersToDestroy[i]->referenceCount) == 0) {
|
||||
VULKAN_INTERNAL_DestroyFramebuffer(
|
||||
renderer,
|
||||
renderer->framebuffersToDestroy[i]);
|
||||
|
|
|
@ -1032,23 +1032,23 @@ extern "C"
|
|||
// !!! FIXME: make this non-blocking!
|
||||
static void SDLCALL RequestAndroidPermissionBlockingCallback(void *userdata, const char *permission, SDL_bool granted)
|
||||
{
|
||||
SDL_AtomicSet((SDL_AtomicInt *) userdata, granted ? 1 : -1);
|
||||
SDL_SetAtomicInt((SDL_AtomicInt *) userdata, granted ? 1 : -1);
|
||||
}
|
||||
|
||||
static bool RequestBluetoothPermissions(const char *permission)
|
||||
{
|
||||
// !!! FIXME: make this non-blocking!
|
||||
SDL_AtomicInt permission_response;
|
||||
SDL_AtomicSet(&permission_response, 0);
|
||||
SDL_SetAtomicInt(&permission_response, 0);
|
||||
if (!SDL_RequestAndroidPermission(permission, RequestAndroidPermissionBlockingCallback, &permission_response)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (SDL_AtomicGet(&permission_response) == 0) {
|
||||
while (SDL_GetAtomicInt(&permission_response) == 0) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
return SDL_AtomicGet(&permission_response) > 0;
|
||||
return SDL_GetAtomicInt(&permission_response) > 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -450,7 +450,7 @@ void SDL_UnlockJoysticks(void)
|
|||
|
||||
if (!SDL_joysticks_initialized) {
|
||||
// NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks
|
||||
if (!SDL_joysticks_locked && SDL_AtomicGet(&SDL_joystick_lock_pending) == 0) {
|
||||
if (!SDL_joysticks_locked && SDL_GetAtomicInt(&SDL_joystick_lock_pending) == 0) {
|
||||
last_unlock = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ static int SDLCALL SDL_HIDAPI_RumbleThread(void *data)
|
|||
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
||||
|
||||
while (SDL_AtomicGet(&ctx->running)) {
|
||||
while (SDL_GetAtomicInt(&ctx->running)) {
|
||||
SDL_HIDAPI_RumbleRequest *request = NULL;
|
||||
|
||||
SDL_WaitSemaphore(ctx->request_sem);
|
||||
|
@ -102,7 +102,7 @@ static void SDL_HIDAPI_StopRumbleThread(SDL_HIDAPI_RumbleContext *ctx)
|
|||
{
|
||||
SDL_HIDAPI_RumbleRequest *request;
|
||||
|
||||
SDL_AtomicSet(&ctx->running, false);
|
||||
SDL_SetAtomicInt(&ctx->running, false);
|
||||
|
||||
if (ctx->thread) {
|
||||
int result;
|
||||
|
@ -138,7 +138,7 @@ static void SDL_HIDAPI_StopRumbleThread(SDL_HIDAPI_RumbleContext *ctx)
|
|||
SDL_HIDAPI_rumble_lock = NULL;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&ctx->initialized, false);
|
||||
SDL_SetAtomicInt(&ctx->initialized, false);
|
||||
}
|
||||
|
||||
static bool SDL_HIDAPI_StartRumbleThread(SDL_HIDAPI_RumbleContext *ctx)
|
||||
|
@ -155,7 +155,7 @@ static bool SDL_HIDAPI_StartRumbleThread(SDL_HIDAPI_RumbleContext *ctx)
|
|||
return false;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&ctx->running, true);
|
||||
SDL_SetAtomicInt(&ctx->running, true);
|
||||
ctx->thread = SDL_CreateThread(SDL_HIDAPI_RumbleThread, "HIDAPI Rumble", ctx);
|
||||
if (!ctx->thread) {
|
||||
SDL_HIDAPI_StopRumbleThread(ctx);
|
||||
|
@ -168,7 +168,7 @@ bool SDL_HIDAPI_LockRumble(void)
|
|||
{
|
||||
SDL_HIDAPI_RumbleContext *ctx = &rumble_context;
|
||||
|
||||
if (SDL_AtomicCompareAndSwap(&ctx->initialized, false, true)) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&ctx->initialized, false, true)) {
|
||||
if (!SDL_HIDAPI_StartRumbleThread(ctx)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ void SDL_HIDAPI_QuitRumble(void)
|
|||
{
|
||||
SDL_HIDAPI_RumbleContext *ctx = &rumble_context;
|
||||
|
||||
if (SDL_AtomicGet(&ctx->running)) {
|
||||
if (SDL_GetAtomicInt(&ctx->running)) {
|
||||
SDL_HIDAPI_StopRumbleThread(ctx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ static int ReadInput(SDL_DriverSwitch_Context *ctx)
|
|||
int result;
|
||||
|
||||
// Make sure we don't try to read at the same time a write is happening
|
||||
if (SDL_AtomicGet(&ctx->device->rumble_pending) > 0) {
|
||||
if (SDL_GetAtomicInt(&ctx->device->rumble_pending) > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ static int ReadInput(SDL_DriverWii_Context *ctx)
|
|||
int size;
|
||||
|
||||
// Make sure we don't try to read at the same time a write is happening
|
||||
if (SDL_AtomicGet(&ctx->device->rumble_pending) > 0) {
|
||||
if (SDL_GetAtomicInt(&ctx->device->rumble_pending) > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1033,7 +1033,7 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device)
|
|||
HIDAPI_CleanupDeviceDriver(device);
|
||||
|
||||
// Make sure the rumble thread is done with this device
|
||||
while (SDL_AtomicGet(&device->rumble_pending) > 0) {
|
||||
while (SDL_GetAtomicInt(&device->rumble_pending) > 0) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
|
@ -1245,12 +1245,12 @@ static bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, SDL
|
|||
|
||||
static bool HIDAPI_StartUpdatingDevices()
|
||||
{
|
||||
return SDL_AtomicCompareAndSwap(&SDL_HIDAPI_updating_devices, false, true);
|
||||
return SDL_CompareAndSwapAtomicInt(&SDL_HIDAPI_updating_devices, false, true);
|
||||
}
|
||||
|
||||
static void HIDAPI_FinishUpdatingDevices()
|
||||
{
|
||||
SDL_AtomicSet(&SDL_HIDAPI_updating_devices, false);
|
||||
SDL_SetAtomicInt(&SDL_HIDAPI_updating_devices, false);
|
||||
}
|
||||
|
||||
bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type)
|
||||
|
@ -1645,7 +1645,7 @@ static void HIDAPI_JoystickClose(SDL_Joystick *joystick) SDL_NO_THREAD_SAFETY_AN
|
|||
SDL_UnlockMutex(device->dev_lock);
|
||||
}
|
||||
for (i = 0; i < 3; ++i) {
|
||||
if (SDL_AtomicGet(&device->rumble_pending) > 0) {
|
||||
if (SDL_GetAtomicInt(&device->rumble_pending) > 0) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -493,13 +493,13 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_QueryInterface(__FIE
|
|||
static ULONG STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_AddRef(__FIEventHandler_1_Windows__CGaming__CInput__CGamepad *This)
|
||||
{
|
||||
GamepadDelegate *self = (GamepadDelegate *)This;
|
||||
return SDL_AtomicAdd(&self->refcount, 1) + 1UL;
|
||||
return SDL_AddAtomicInt(&self->refcount, 1) + 1UL;
|
||||
}
|
||||
|
||||
static ULONG STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_Release(__FIEventHandler_1_Windows__CGaming__CInput__CGamepad *This)
|
||||
{
|
||||
GamepadDelegate *self = (GamepadDelegate *)This;
|
||||
int rc = SDL_AtomicAdd(&self->refcount, -1) - 1;
|
||||
int rc = SDL_AddAtomicInt(&self->refcount, -1) - 1;
|
||||
// Should never free the static delegate objects
|
||||
SDL_assert(rc > 0);
|
||||
return rc;
|
||||
|
|
|
@ -343,13 +343,13 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInter
|
|||
static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_AddRef(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This)
|
||||
{
|
||||
RawGameControllerDelegate *self = (RawGameControllerDelegate *)This;
|
||||
return SDL_AtomicAdd(&self->refcount, 1) + 1UL;
|
||||
return SDL_AddAtomicInt(&self->refcount, 1) + 1UL;
|
||||
}
|
||||
|
||||
static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This)
|
||||
{
|
||||
RawGameControllerDelegate *self = (RawGameControllerDelegate *)This;
|
||||
int rc = SDL_AtomicAdd(&self->refcount, -1) - 1;
|
||||
int rc = SDL_AddAtomicInt(&self->refcount, -1) - 1;
|
||||
// Should never free the static delegate objects
|
||||
SDL_assert(rc > 0);
|
||||
return rc;
|
||||
|
|
|
@ -46,8 +46,8 @@ static bool ShouldDispatchImmediately(SDL_Event *event)
|
|||
|
||||
static void SDL_DispatchMainCallbackEvent(SDL_Event *event)
|
||||
{
|
||||
if (SDL_AtomicGet(&apprc) == SDL_APP_CONTINUE) { // if already quitting, don't send the event to the app.
|
||||
SDL_AtomicCompareAndSwap(&apprc, SDL_APP_CONTINUE, SDL_main_event_callback(SDL_main_appstate, event));
|
||||
if (SDL_GetAtomicInt(&apprc) == SDL_APP_CONTINUE) { // if already quitting, don't send the event to the app.
|
||||
SDL_CompareAndSwapAtomicInt(&apprc, SDL_APP_CONTINUE, SDL_main_event_callback(SDL_main_appstate, event));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,23 +94,23 @@ SDL_AppResult SDL_InitMainCallbacks(int argc, char* argv[], SDL_AppInit_func app
|
|||
SDL_main_iteration_callback = appiter;
|
||||
SDL_main_event_callback = appevent;
|
||||
SDL_main_quit_callback = appquit;
|
||||
SDL_AtomicSet(&apprc, SDL_APP_CONTINUE);
|
||||
SDL_SetAtomicInt(&apprc, SDL_APP_CONTINUE);
|
||||
|
||||
const SDL_AppResult rc = appinit(&SDL_main_appstate, argc, argv);
|
||||
if (SDL_AtomicCompareAndSwap(&apprc, SDL_APP_CONTINUE, rc) && (rc == SDL_APP_CONTINUE)) { // bounce if SDL_AppInit already said abort, otherwise...
|
||||
if (SDL_CompareAndSwapAtomicInt(&apprc, SDL_APP_CONTINUE, rc) && (rc == SDL_APP_CONTINUE)) { // bounce if SDL_AppInit already said abort, otherwise...
|
||||
// make sure we definitely have events initialized, even if the app didn't do it.
|
||||
if (!SDL_InitSubSystem(SDL_INIT_EVENTS)) {
|
||||
SDL_AtomicSet(&apprc, SDL_APP_FAILURE);
|
||||
SDL_SetAtomicInt(&apprc, SDL_APP_FAILURE);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
if (!SDL_AddEventWatch(SDL_MainCallbackEventWatcher, NULL)) {
|
||||
SDL_AtomicSet(&apprc, SDL_APP_FAILURE);
|
||||
SDL_SetAtomicInt(&apprc, SDL_APP_FAILURE);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return (SDL_AppResult)SDL_AtomicGet(&apprc);
|
||||
return (SDL_AppResult)SDL_GetAtomicInt(&apprc);
|
||||
}
|
||||
|
||||
SDL_AppResult SDL_IterateMainCallbacks(bool pump_events)
|
||||
|
@ -120,11 +120,11 @@ SDL_AppResult SDL_IterateMainCallbacks(bool pump_events)
|
|||
}
|
||||
SDL_DispatchMainCallbackEvents();
|
||||
|
||||
SDL_AppResult rc = (SDL_AppResult)SDL_AtomicGet(&apprc);
|
||||
SDL_AppResult rc = (SDL_AppResult)SDL_GetAtomicInt(&apprc);
|
||||
if (rc == SDL_APP_CONTINUE) {
|
||||
rc = SDL_main_iteration_callback(SDL_main_appstate);
|
||||
if (!SDL_AtomicCompareAndSwap(&apprc, SDL_APP_CONTINUE, rc)) {
|
||||
rc = (SDL_AppResult)SDL_AtomicGet(&apprc); // something else already set a quit result, keep that.
|
||||
if (!SDL_CompareAndSwapAtomicInt(&apprc, SDL_APP_CONTINUE, rc)) {
|
||||
rc = (SDL_AppResult)SDL_GetAtomicInt(&apprc); // something else already set a quit result, keep that.
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
|
|
|
@ -86,7 +86,7 @@ void SDL_UnlockSensors(void)
|
|||
|
||||
if (!SDL_sensors_initialized) {
|
||||
// NOTE: There's a small window here where another thread could lock the mutex after we've checked for pending locks
|
||||
if (!SDL_sensors_locked && SDL_AtomicGet(&SDL_sensor_lock_pending) == 0) {
|
||||
if (!SDL_sensors_locked && SDL_GetAtomicInt(&SDL_sensor_lock_pending) == 0) {
|
||||
last_unlock = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ static int SDLCALL SDL_ANDROID_SensorThread(void *data)
|
|||
SDL_sensor_looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
|
||||
SDL_SignalSemaphore(ctx->sem);
|
||||
|
||||
while (SDL_AtomicGet(&ctx->running)) {
|
||||
while (SDL_GetAtomicInt(&ctx->running)) {
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
|
||||
if (ALooper_pollOnce(-1, NULL, &events, (void **)&source) == LOOPER_ID_USER) {
|
||||
|
@ -93,7 +93,7 @@ static int SDLCALL SDL_ANDROID_SensorThread(void *data)
|
|||
|
||||
static void SDL_ANDROID_StopSensorThread(SDL_AndroidSensorThreadContext *ctx)
|
||||
{
|
||||
SDL_AtomicSet(&ctx->running, false);
|
||||
SDL_SetAtomicInt(&ctx->running, false);
|
||||
|
||||
if (ctx->thread) {
|
||||
int result;
|
||||
|
@ -119,7 +119,7 @@ static bool SDL_ANDROID_StartSensorThread(SDL_AndroidSensorThreadContext *ctx)
|
|||
return false;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&ctx->running, true);
|
||||
SDL_SetAtomicInt(&ctx->running, true);
|
||||
ctx->thread = SDL_CreateThread(SDL_ANDROID_SensorThread, "Sensors", ctx);
|
||||
if (!ctx->thread) {
|
||||
SDL_ANDROID_StopSensorThread(ctx);
|
||||
|
|
|
@ -6417,7 +6417,7 @@ SDL_bool SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
|
|||
|
||||
int SDL_GetNumAllocations(void)
|
||||
{
|
||||
return SDL_AtomicGet(&s_mem.num_allocations);
|
||||
return SDL_GetAtomicInt(&s_mem.num_allocations);
|
||||
}
|
||||
|
||||
void *SDL_malloc(size_t size)
|
||||
|
|
|
@ -78,12 +78,12 @@ static SDL_AtomicInt s_lock;
|
|||
|
||||
#define LOCK_ALLOCATOR() \
|
||||
do { \
|
||||
if (SDL_AtomicCompareAndSwap(&s_lock, 0, 1)) { \
|
||||
if (SDL_CompareAndSwapAtomicInt(&s_lock, 0, 1)) { \
|
||||
break; \
|
||||
} \
|
||||
SDL_CPUPauseInstruction(); \
|
||||
} while (SDL_TRUE)
|
||||
#define UNLOCK_ALLOCATOR() do { SDL_AtomicSet(&s_lock, 0); } while (0)
|
||||
#define UNLOCK_ALLOCATOR() do { SDL_SetAtomicInt(&s_lock, 0); } while (0)
|
||||
|
||||
static unsigned int get_allocation_bucket(void *mem)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ void *SDL_GetTLS(SDL_TLSID *id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
storage_index = SDL_AtomicGet(id) - 1;
|
||||
storage_index = SDL_GetAtomicInt(id) - 1;
|
||||
storage = SDL_SYS_GetTLSData();
|
||||
if (!storage || storage_index < 0 || storage_index >= storage->limit) {
|
||||
return NULL;
|
||||
|
@ -70,16 +70,16 @@ SDL_bool SDL_SetTLS(SDL_TLSID *id, const void *value, SDL_TLSDestructorCallback
|
|||
SDL_InitTLSData();
|
||||
|
||||
// Get the storage index associated with the ID in a thread-safe way
|
||||
storage_index = SDL_AtomicGet(id) - 1;
|
||||
storage_index = SDL_GetAtomicInt(id) - 1;
|
||||
if (storage_index < 0) {
|
||||
int new_id = (SDL_AtomicIncRef(&SDL_tls_id) + 1);
|
||||
|
||||
SDL_AtomicCompareAndSwap(id, 0, new_id);
|
||||
SDL_CompareAndSwapAtomicInt(id, 0, new_id);
|
||||
|
||||
/* If there was a race condition we'll have wasted an ID, but every thread
|
||||
* will have the same storage index for this id.
|
||||
*/
|
||||
storage_index = SDL_AtomicGet(id) - 1;
|
||||
storage_index = SDL_GetAtomicInt(id) - 1;
|
||||
}
|
||||
|
||||
// Get the storage for the current thread
|
||||
|
@ -135,7 +135,7 @@ void SDL_QuitTLSData(void)
|
|||
{
|
||||
SDL_CleanupTLS();
|
||||
|
||||
if (SDL_AtomicGet(&SDL_tls_allocated) == 0) {
|
||||
if (SDL_GetAtomicInt(&SDL_tls_allocated) == 0) {
|
||||
SDL_SYS_QuitTLSData();
|
||||
} else {
|
||||
// Some thread hasn't called SDL_CleanupTLS()
|
||||
|
@ -326,9 +326,9 @@ void SDL_RunThread(SDL_Thread *thread)
|
|||
SDL_CleanupTLS();
|
||||
|
||||
// Mark us as ready to be joined (or detached)
|
||||
if (!SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_ALIVE, SDL_THREAD_STATE_ZOMBIE)) {
|
||||
if (!SDL_CompareAndSwapAtomicInt(&thread->state, SDL_THREAD_STATE_ALIVE, SDL_THREAD_STATE_ZOMBIE)) {
|
||||
// Clean up if something already detached us.
|
||||
if (SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_DETACHED, SDL_THREAD_STATE_CLEANED)) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&thread->state, SDL_THREAD_STATE_DETACHED, SDL_THREAD_STATE_CLEANED)) {
|
||||
SDL_free(thread->name); // Can't free later, we've already cleaned up TLS
|
||||
SDL_free(thread);
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ SDL_Thread *SDL_CreateThreadWithPropertiesRuntime(SDL_PropertiesID props,
|
|||
return NULL;
|
||||
}
|
||||
thread->status = -1;
|
||||
SDL_AtomicSet(&thread->state, SDL_THREAD_STATE_ALIVE);
|
||||
SDL_SetAtomicInt(&thread->state, SDL_THREAD_STATE_ALIVE);
|
||||
|
||||
// Set up the arguments for the thread
|
||||
if (name) {
|
||||
|
@ -463,11 +463,11 @@ void SDL_DetachThread(SDL_Thread *thread)
|
|||
}
|
||||
|
||||
// Grab dibs if the state is alive+joinable.
|
||||
if (SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_ALIVE, SDL_THREAD_STATE_DETACHED)) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&thread->state, SDL_THREAD_STATE_ALIVE, SDL_THREAD_STATE_DETACHED)) {
|
||||
SDL_SYS_DetachThread(thread);
|
||||
} else {
|
||||
// all other states are pretty final, see where we landed.
|
||||
const int thread_state = SDL_AtomicGet(&thread->state);
|
||||
const int thread_state = SDL_GetAtomicInt(&thread->state);
|
||||
if ((thread_state == SDL_THREAD_STATE_DETACHED) || (thread_state == SDL_THREAD_STATE_CLEANED)) {
|
||||
return; // already detached (you shouldn't call this twice!)
|
||||
} else if (thread_state == SDL_THREAD_STATE_ZOMBIE) {
|
||||
|
|
|
@ -74,8 +74,8 @@ SDL_RWLock *SDL_CreateRWLock_generic(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&rwlock->reader_count, 0);
|
||||
SDL_AtomicSet(&rwlock->writer_count, 0);
|
||||
SDL_SetAtomicInt(&rwlock->reader_count, 0);
|
||||
SDL_SetAtomicInt(&rwlock->writer_count, 0);
|
||||
#endif
|
||||
|
||||
return rwlock;
|
||||
|
@ -98,8 +98,8 @@ void SDL_LockRWLockForReading_generic(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_A
|
|||
if (rwlock) {
|
||||
// !!! FIXME: these don't have to be atomic, we always gate them behind a mutex.
|
||||
SDL_LockMutex(rwlock->lock);
|
||||
SDL_assert(SDL_AtomicGet(&rwlock->writer_count) == 0); // shouldn't be able to grab lock if there's a writer!
|
||||
SDL_AtomicAdd(&rwlock->reader_count, 1);
|
||||
SDL_assert(SDL_GetAtomicInt(&rwlock->writer_count) == 0); // shouldn't be able to grab lock if there's a writer!
|
||||
SDL_AddAtomicInt(&rwlock->reader_count, 1);
|
||||
SDL_UnlockMutex(rwlock->lock); // other readers can attempt to share the lock.
|
||||
}
|
||||
#endif
|
||||
|
@ -110,12 +110,12 @@ void SDL_LockRWLockForWriting_generic(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_A
|
|||
#ifndef SDL_THREADS_DISABLED
|
||||
if (rwlock) {
|
||||
SDL_LockMutex(rwlock->lock);
|
||||
while (SDL_AtomicGet(&rwlock->reader_count) > 0) { // while something is holding the shared lock, keep waiting.
|
||||
while (SDL_GetAtomicInt(&rwlock->reader_count) > 0) { // while something is holding the shared lock, keep waiting.
|
||||
SDL_WaitCondition(rwlock->condition, rwlock->lock); // release the lock and wait for readers holding the shared lock to release it, regrab the lock.
|
||||
}
|
||||
|
||||
// we hold the lock!
|
||||
SDL_AtomicAdd(&rwlock->writer_count, 1); // we let these be recursive, but the API doesn't require this. It _does_ trust you unlock correctly!
|
||||
SDL_AddAtomicInt(&rwlock->writer_count, 1); // we let these be recursive, but the API doesn't require this. It _does_ trust you unlock correctly!
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -129,8 +129,8 @@ bool SDL_TryLockRWLockForReading_generic(SDL_RWLock *rwlock)
|
|||
return false;
|
||||
}
|
||||
|
||||
SDL_assert(SDL_AtomicGet(&rwlock->writer_count) == 0); // shouldn't be able to grab lock if there's a writer!
|
||||
SDL_AtomicAdd(&rwlock->reader_count, 1);
|
||||
SDL_assert(SDL_GetAtomicInt(&rwlock->writer_count) == 0); // shouldn't be able to grab lock if there's a writer!
|
||||
SDL_AddAtomicInt(&rwlock->reader_count, 1);
|
||||
SDL_UnlockMutex(rwlock->lock); // other readers can attempt to share the lock.
|
||||
}
|
||||
#endif
|
||||
|
@ -153,13 +153,13 @@ bool SDL_TryLockRWLockForWriting_generic(SDL_RWLock *rwlock)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (SDL_AtomicGet(&rwlock->reader_count) > 0) { // a reader is using the shared lock, treat it as unavailable.
|
||||
if (SDL_GetAtomicInt(&rwlock->reader_count) > 0) { // a reader is using the shared lock, treat it as unavailable.
|
||||
SDL_UnlockMutex(rwlock->lock);
|
||||
return false;
|
||||
}
|
||||
|
||||
// we hold the lock!
|
||||
SDL_AtomicAdd(&rwlock->writer_count, 1); // we let these be recursive, but the API doesn't require this. It _does_ trust you unlock correctly!
|
||||
SDL_AddAtomicInt(&rwlock->writer_count, 1); // we let these be recursive, but the API doesn't require this. It _does_ trust you unlock correctly!
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -179,11 +179,11 @@ void SDL_UnlockRWLock_generic(SDL_RWLock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS
|
|||
if (rwlock) {
|
||||
SDL_LockMutex(rwlock->lock); // recursive lock for writers, readers grab lock to make sure things are sane.
|
||||
|
||||
if (SDL_AtomicGet(&rwlock->reader_count) > 0) { // we're a reader
|
||||
SDL_AtomicAdd(&rwlock->reader_count, -1);
|
||||
if (SDL_GetAtomicInt(&rwlock->reader_count) > 0) { // we're a reader
|
||||
SDL_AddAtomicInt(&rwlock->reader_count, -1);
|
||||
SDL_BroadcastCondition(rwlock->condition); // alert any pending writers to attempt to try to grab the lock again.
|
||||
} else if (SDL_AtomicGet(&rwlock->writer_count) > 0) { // we're a writer
|
||||
SDL_AtomicAdd(&rwlock->writer_count, -1);
|
||||
} else if (SDL_GetAtomicInt(&rwlock->writer_count) > 0) { // we're a writer
|
||||
SDL_AddAtomicInt(&rwlock->writer_count, -1);
|
||||
SDL_UnlockMutex(rwlock->lock); // recursive unlock.
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ void SDL_SYS_WaitThread(SDL_Thread *thread)
|
|||
Detached threads can be waited on, but should NOT be cleaned manually
|
||||
as it would result in a fatal error.
|
||||
*/
|
||||
if (R_SUCCEEDED(res) && SDL_AtomicGet(&thread->state) != SDL_THREAD_STATE_DETACHED) {
|
||||
if (R_SUCCEEDED(res) && SDL_GetAtomicInt(&thread->state) != SDL_THREAD_STATE_DETACHED) {
|
||||
threadFree(thread->handle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
|||
freelist_tail = NULL;
|
||||
|
||||
// Check to see if we're still running, after maintenance
|
||||
if (!SDL_AtomicGet(&data->active)) {
|
||||
if (!SDL_GetAtomicInt(&data->active)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
|||
// We're going to do something with this timer
|
||||
data->timers = current->next;
|
||||
|
||||
if (SDL_AtomicGet(¤t->canceled)) {
|
||||
if (SDL_GetAtomicInt(¤t->canceled)) {
|
||||
interval = 0;
|
||||
} else {
|
||||
if (current->callback_ms) {
|
||||
|
@ -183,7 +183,7 @@ static int SDLCALL SDL_TimerThread(void *_data)
|
|||
}
|
||||
freelist_tail = current;
|
||||
|
||||
SDL_AtomicSet(¤t->canceled, 1);
|
||||
SDL_SetAtomicInt(¤t->canceled, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ bool SDL_InitTimers(void)
|
|||
goto error;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&data->active, true);
|
||||
SDL_SetAtomicInt(&data->active, true);
|
||||
|
||||
// Timer threads use a callback into the app, so we can't set a limited stack size here.
|
||||
data->thread = SDL_CreateThread(SDL_TimerThread, "SDLTimer", data);
|
||||
|
@ -251,7 +251,7 @@ void SDL_QuitTimers(void)
|
|||
return;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&data->active, false);
|
||||
SDL_SetAtomicInt(&data->active, false);
|
||||
|
||||
// Shutdown the timer thread
|
||||
if (data->thread) {
|
||||
|
@ -331,7 +331,7 @@ static SDL_TimerID SDL_CreateTimer(Uint64 interval, SDL_TimerCallback callback_m
|
|||
timer->userdata = userdata;
|
||||
timer->interval = interval;
|
||||
timer->scheduled = SDL_GetTicksNS() + timer->interval;
|
||||
SDL_AtomicSet(&timer->canceled, 0);
|
||||
SDL_SetAtomicInt(&timer->canceled, 0);
|
||||
|
||||
entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry));
|
||||
if (!entry) {
|
||||
|
@ -394,8 +394,8 @@ SDL_bool SDL_RemoveTimer(SDL_TimerID id)
|
|||
SDL_UnlockMutex(data->timermap_lock);
|
||||
|
||||
if (entry) {
|
||||
if (!SDL_AtomicGet(&entry->timer->canceled)) {
|
||||
SDL_AtomicSet(&entry->timer->canceled, 1);
|
||||
if (!SDL_GetAtomicInt(&entry->timer->canceled)) {
|
||||
SDL_SetAtomicInt(&entry->timer->canceled, 1);
|
||||
canceled = true;
|
||||
}
|
||||
SDL_free(entry);
|
||||
|
|
|
@ -5370,7 +5370,7 @@ SDL_bool SDL_ScreenKeyboardShown(SDL_Window *window)
|
|||
|
||||
int SDL_GetMessageBoxCount(void)
|
||||
{
|
||||
return SDL_AtomicGet(&SDL_messagebox_count);
|
||||
return SDL_GetAtomicInt(&SDL_messagebox_count);
|
||||
}
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_ANDROID
|
||||
|
|
|
@ -64,10 +64,10 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
|||
SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)displayLinkContext;
|
||||
|
||||
// printf("DISPLAY LINK! %u\n", (unsigned int) SDL_GetTicks());
|
||||
const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting);
|
||||
const int setting = SDL_GetAtomicInt(&nscontext->swapIntervalSetting);
|
||||
if (setting != 0) { // nothing to do if vsync is disabled, don't even lock
|
||||
SDL_LockMutex(nscontext->swapIntervalMutex);
|
||||
SDL_AtomicAdd(&nscontext->swapIntervalsPassed, 1);
|
||||
SDL_AddAtomicInt(&nscontext->swapIntervalsPassed, 1);
|
||||
SDL_SignalCondition(nscontext->swapIntervalCond);
|
||||
SDL_UnlockMutex(nscontext->swapIntervalMutex);
|
||||
}
|
||||
|
@ -83,10 +83,10 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
|||
self = [super initWithFormat:format shareContext:share];
|
||||
if (self) {
|
||||
self.openglPixelFormat = format;
|
||||
SDL_AtomicSet(&self->dirty, 0);
|
||||
SDL_SetAtomicInt(&self->dirty, 0);
|
||||
self->window = NULL;
|
||||
SDL_AtomicSet(&self->swapIntervalSetting, 0);
|
||||
SDL_AtomicSet(&self->swapIntervalsPassed, 0);
|
||||
SDL_SetAtomicInt(&self->swapIntervalSetting, 0);
|
||||
SDL_SetAtomicInt(&self->swapIntervalsPassed, 0);
|
||||
self->swapIntervalCond = SDL_CreateCondition();
|
||||
self->swapIntervalMutex = SDL_CreateMutex();
|
||||
if (!self->swapIntervalCond || !self->swapIntervalMutex) {
|
||||
|
@ -113,13 +113,13 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
|||
|
||||
- (void)scheduleUpdate
|
||||
{
|
||||
SDL_AtomicAdd(&self->dirty, 1);
|
||||
SDL_AddAtomicInt(&self->dirty, 1);
|
||||
}
|
||||
|
||||
// This should only be called on the thread on which a user is using the context.
|
||||
- (void)updateIfNeeded
|
||||
{
|
||||
const int value = SDL_AtomicSet(&self->dirty, 0);
|
||||
const int value = SDL_SetAtomicInt(&self->dirty, 0);
|
||||
if (value > 0) {
|
||||
// We call the real underlying update here, since -[SDL3OpenGLContext update] just calls us.
|
||||
[self explicitUpdate];
|
||||
|
@ -463,8 +463,8 @@ bool Cocoa_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval)
|
|||
result = SDL_SetError("No current OpenGL context");
|
||||
} else {
|
||||
SDL_LockMutex(nscontext->swapIntervalMutex);
|
||||
SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0);
|
||||
SDL_AtomicSet(&nscontext->swapIntervalSetting, interval);
|
||||
SDL_SetAtomicInt(&nscontext->swapIntervalsPassed, 0);
|
||||
SDL_SetAtomicInt(&nscontext->swapIntervalSetting, interval);
|
||||
SDL_UnlockMutex(nscontext->swapIntervalMutex);
|
||||
result = true;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ bool Cocoa_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval)
|
|||
@autoreleasepool {
|
||||
SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)SDL_GL_GetCurrentContext();
|
||||
if (nscontext) {
|
||||
*interval = SDL_AtomicGet(&nscontext->swapIntervalSetting);
|
||||
*interval = SDL_GetAtomicInt(&nscontext->swapIntervalSetting);
|
||||
return true;
|
||||
} else {
|
||||
return SDL_SetError("no OpenGL context");
|
||||
|
@ -491,23 +491,23 @@ bool Cocoa_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||
@autoreleasepool {
|
||||
SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)SDL_GL_GetCurrentContext();
|
||||
SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->internal;
|
||||
const int setting = SDL_AtomicGet(&nscontext->swapIntervalSetting);
|
||||
const int setting = SDL_GetAtomicInt(&nscontext->swapIntervalSetting);
|
||||
|
||||
if (setting == 0) {
|
||||
// nothing to do if vsync is disabled, don't even lock
|
||||
} else if (setting < 0) { // late swap tearing
|
||||
SDL_LockMutex(nscontext->swapIntervalMutex);
|
||||
while (SDL_AtomicGet(&nscontext->swapIntervalsPassed) == 0) {
|
||||
while (SDL_GetAtomicInt(&nscontext->swapIntervalsPassed) == 0) {
|
||||
SDL_WaitCondition(nscontext->swapIntervalCond, nscontext->swapIntervalMutex);
|
||||
}
|
||||
SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0);
|
||||
SDL_SetAtomicInt(&nscontext->swapIntervalsPassed, 0);
|
||||
SDL_UnlockMutex(nscontext->swapIntervalMutex);
|
||||
} else {
|
||||
SDL_LockMutex(nscontext->swapIntervalMutex);
|
||||
do { // always wait here so we know we just hit a swap interval.
|
||||
SDL_WaitCondition(nscontext->swapIntervalCond, nscontext->swapIntervalMutex);
|
||||
} while ((SDL_AtomicGet(&nscontext->swapIntervalsPassed) % setting) != 0);
|
||||
SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0);
|
||||
} while ((SDL_GetAtomicInt(&nscontext->swapIntervalsPassed) % setting) != 0);
|
||||
SDL_SetAtomicInt(&nscontext->swapIntervalsPassed, 0);
|
||||
SDL_UnlockMutex(nscontext->swapIntervalMutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ bool Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||
struct wl_display *display = videodata->display;
|
||||
// 20hz, so we'll progress even if throttled to zero.
|
||||
const Uint64 max_wait = SDL_GetTicksNS() + (SDL_NS_PER_SECOND / 20);
|
||||
while (SDL_AtomicGet(&data->swap_interval_ready) == 0) {
|
||||
while (SDL_GetAtomicInt(&data->swap_interval_ready) == 0) {
|
||||
Uint64 now;
|
||||
|
||||
WAYLAND_wl_display_flush(display);
|
||||
|
@ -171,7 +171,7 @@ bool Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
|||
WAYLAND_wl_display_read_events(display);
|
||||
WAYLAND_wl_display_dispatch_queue_pending(display, data->gles_swap_frame_event_queue);
|
||||
}
|
||||
SDL_AtomicSet(&data->swap_interval_ready, 0);
|
||||
SDL_SetAtomicInt(&data->swap_interval_ready, 0);
|
||||
}
|
||||
|
||||
if (!data->double_buffer) {
|
||||
|
|
|
@ -697,7 +697,7 @@ static const struct wl_callback_listener gles_swap_frame_listener;
|
|||
static void gles_swap_frame_done(void *data, struct wl_callback *cb, uint32_t time)
|
||||
{
|
||||
SDL_WindowData *wind = (SDL_WindowData *)data;
|
||||
SDL_AtomicSet(&wind->swap_interval_ready, 1); // mark window as ready to present again.
|
||||
SDL_SetAtomicInt(&wind->swap_interval_ready, 1); // mark window as ready to present again.
|
||||
|
||||
// reset this callback to fire again once a new frame was presented and compositor wants the next one.
|
||||
wind->gles_swap_frame_callback = wl_surface_frame(wind->gles_swap_frame_surface_wrapper);
|
||||
|
|
|
@ -49,30 +49,30 @@ static void RunBasicTest(void)
|
|||
|
||||
SDL_Log("\natomic -----------------------------------------\n\n");
|
||||
|
||||
SDL_AtomicSet(&v, 0);
|
||||
tfret = SDL_AtomicSet(&v, 10) == 0;
|
||||
SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = SDL_AtomicAdd(&v, 10) == 10;
|
||||
SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
SDL_SetAtomicInt(&v, 0);
|
||||
tfret = SDL_SetAtomicInt(&v, 10) == 0;
|
||||
SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
tfret = SDL_AddAtomicInt(&v, 10) == 10;
|
||||
SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
|
||||
SDL_AtomicSet(&v, 0);
|
||||
SDL_SetAtomicInt(&v, 0);
|
||||
SDL_AtomicIncRef(&v);
|
||||
tfret = (SDL_AtomicGet(&v) == 1);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = (SDL_GetAtomicInt(&v) == 1);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
SDL_AtomicIncRef(&v);
|
||||
tfret = (SDL_AtomicGet(&v) == 2);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = (SDL_GetAtomicInt(&v) == 2);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE);
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE);
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
|
||||
SDL_AtomicSet(&v, 10);
|
||||
tfret = (SDL_AtomicCompareAndSwap(&v, 0, 20) == SDL_FALSE);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
value = SDL_AtomicGet(&v);
|
||||
tfret = (SDL_AtomicCompareAndSwap(&v, value, 20) == SDL_TRUE);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
SDL_SetAtomicInt(&v, 10);
|
||||
tfret = (SDL_CompareAndSwapAtomicInt(&v, 0, 20) == SDL_FALSE);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
value = SDL_GetAtomicInt(&v);
|
||||
tfret = (SDL_CompareAndSwapAtomicInt(&v, value, 20) == SDL_TRUE);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -117,10 +117,10 @@ static int SDLCALL adder(void *junk)
|
|||
unsigned long N = NInter;
|
||||
SDL_Log("Thread subtracting %d %lu times\n", CountInc, N);
|
||||
while (N--) {
|
||||
SDL_AtomicAdd(&good, -CountInc);
|
||||
SDL_AddAtomicInt(&good, -CountInc);
|
||||
bad -= CountInc;
|
||||
}
|
||||
SDL_AtomicAdd(&threadsRunning, -1);
|
||||
SDL_AddAtomicInt(&threadsRunning, -1);
|
||||
SDL_SignalSemaphore(threadDone);
|
||||
return 0;
|
||||
}
|
||||
|
@ -135,13 +135,13 @@ static void runAdder(void)
|
|||
|
||||
threadDone = SDL_CreateSemaphore(0);
|
||||
|
||||
SDL_AtomicSet(&threadsRunning, NThreads);
|
||||
SDL_SetAtomicInt(&threadsRunning, NThreads);
|
||||
|
||||
for (i = 0; i < NThreads; i++) {
|
||||
threads[i] = SDL_CreateThread(adder, "Adder", NULL);
|
||||
}
|
||||
|
||||
while (SDL_AtomicGet(&threadsRunning) > 0) {
|
||||
while (SDL_GetAtomicInt(&threadsRunning) > 0) {
|
||||
SDL_WaitSemaphore(threadDone);
|
||||
}
|
||||
|
||||
|
@ -167,65 +167,65 @@ static void RunEpicTest(void)
|
|||
SDL_assert(sizeof(atomicValue) >= 4);
|
||||
|
||||
SDL_Log("Check static initializer\n");
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 42);
|
||||
|
||||
SDL_assert(bad == 42);
|
||||
|
||||
SDL_Log("Test negative values\n");
|
||||
SDL_AtomicSet(&good, -5);
|
||||
v = SDL_AtomicGet(&good);
|
||||
SDL_SetAtomicInt(&good, -5);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == -5);
|
||||
|
||||
SDL_Log("Verify maximum value\n");
|
||||
SDL_AtomicSet(&good, CountTo);
|
||||
v = SDL_AtomicGet(&good);
|
||||
SDL_SetAtomicInt(&good, CountTo);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == CountTo);
|
||||
|
||||
SDL_Log("Test compare and exchange\n");
|
||||
|
||||
b = SDL_AtomicCompareAndSwap(&good, 500, 43);
|
||||
b = SDL_CompareAndSwapAtomicInt(&good, 500, 43);
|
||||
SDL_assert(!b); /* no swap since CountTo!=500 */
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == CountTo); /* ensure no swap */
|
||||
|
||||
b = SDL_AtomicCompareAndSwap(&good, CountTo, 44);
|
||||
b = SDL_CompareAndSwapAtomicInt(&good, CountTo, 44);
|
||||
SDL_assert(!!b); /* will swap */
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 44);
|
||||
|
||||
SDL_Log("Test Add\n");
|
||||
|
||||
v = SDL_AtomicAdd(&good, 1);
|
||||
v = SDL_AddAtomicInt(&good, 1);
|
||||
SDL_assert(v == 44);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 45);
|
||||
|
||||
v = SDL_AtomicAdd(&good, 10);
|
||||
v = SDL_AddAtomicInt(&good, 10);
|
||||
SDL_assert(v == 45);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 55);
|
||||
|
||||
SDL_Log("Test Add (Negative values)\n");
|
||||
|
||||
v = SDL_AtomicAdd(&good, -20);
|
||||
v = SDL_AddAtomicInt(&good, -20);
|
||||
SDL_assert(v == 55);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 35);
|
||||
|
||||
v = SDL_AtomicAdd(&good, -50); /* crossing zero down */
|
||||
v = SDL_AddAtomicInt(&good, -50); /* crossing zero down */
|
||||
SDL_assert(v == 35);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == -15);
|
||||
|
||||
v = SDL_AtomicAdd(&good, 30); /* crossing zero up */
|
||||
v = SDL_AddAtomicInt(&good, 30); /* crossing zero up */
|
||||
SDL_assert(v == -15);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 15);
|
||||
|
||||
SDL_Log("Reset before count down test\n");
|
||||
SDL_AtomicSet(&good, CountTo);
|
||||
v = SDL_AtomicGet(&good);
|
||||
SDL_SetAtomicInt(&good, CountTo);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == CountTo);
|
||||
|
||||
bad = CountTo;
|
||||
|
@ -234,7 +234,7 @@ static void RunEpicTest(void)
|
|||
SDL_Log("Counting down from %d, Expect %d remaining\n", CountTo, Expect);
|
||||
runAdder();
|
||||
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_Log("Atomic %d Non-Atomic %d\n", v, bad);
|
||||
SDL_assert(v == Expect);
|
||||
/* We can't guarantee that bad != Expect, this would happen on a single core system, for example. */
|
||||
|
@ -300,16 +300,16 @@ static void InitEventQueue(SDL_EventQueue *queue)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < MAX_ENTRIES; ++i) {
|
||||
SDL_AtomicSet(&queue->entries[i].sequence, i);
|
||||
SDL_SetAtomicInt(&queue->entries[i].sequence, i);
|
||||
}
|
||||
SDL_AtomicSet(&queue->enqueue_pos, 0);
|
||||
SDL_AtomicSet(&queue->dequeue_pos, 0);
|
||||
SDL_SetAtomicInt(&queue->enqueue_pos, 0);
|
||||
SDL_SetAtomicInt(&queue->dequeue_pos, 0);
|
||||
#ifdef TEST_SPINLOCK_FIFO
|
||||
queue->lock = 0;
|
||||
SDL_AtomicSet(&queue->rwcount, 0);
|
||||
SDL_AtomicSet(&queue->watcher, 0);
|
||||
SDL_SetAtomicInt(&queue->rwcount, 0);
|
||||
SDL_SetAtomicInt(&queue->watcher, 0);
|
||||
#endif
|
||||
SDL_AtomicSet(&queue->active, 1);
|
||||
SDL_SetAtomicInt(&queue->active, 1);
|
||||
}
|
||||
|
||||
static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *event)
|
||||
|
@ -323,23 +323,23 @@ static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *ev
|
|||
#ifdef TEST_SPINLOCK_FIFO
|
||||
/* This is a gate so an external thread can lock the queue */
|
||||
SDL_LockSpinlock(&queue->lock);
|
||||
SDL_assert(SDL_AtomicGet(&queue->watcher) == 0);
|
||||
SDL_assert(SDL_GetAtomicInt(&queue->watcher) == 0);
|
||||
SDL_AtomicIncRef(&queue->rwcount);
|
||||
SDL_UnlockSpinlock(&queue->lock);
|
||||
#endif
|
||||
|
||||
queue_pos = (unsigned)SDL_AtomicGet(&queue->enqueue_pos);
|
||||
queue_pos = (unsigned)SDL_GetAtomicInt(&queue->enqueue_pos);
|
||||
for (;;) {
|
||||
entry = &queue->entries[queue_pos & WRAP_MASK];
|
||||
entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence);
|
||||
entry_seq = (unsigned)SDL_GetAtomicInt(&entry->sequence);
|
||||
|
||||
delta = (int)(entry_seq - queue_pos);
|
||||
if (delta == 0) {
|
||||
/* The entry and the queue position match, try to increment the queue position */
|
||||
if (SDL_AtomicCompareAndSwap(&queue->enqueue_pos, (int)queue_pos, (int)(queue_pos + 1))) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&queue->enqueue_pos, (int)queue_pos, (int)(queue_pos + 1))) {
|
||||
/* We own the object, fill it! */
|
||||
entry->event = *event;
|
||||
SDL_AtomicSet(&entry->sequence, (int)(queue_pos + 1));
|
||||
SDL_SetAtomicInt(&entry->sequence, (int)(queue_pos + 1));
|
||||
status = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *ev
|
|||
break;
|
||||
} else {
|
||||
/* We ran into a new queue entry, get the new queue position */
|
||||
queue_pos = (unsigned)SDL_AtomicGet(&queue->enqueue_pos);
|
||||
queue_pos = (unsigned)SDL_GetAtomicInt(&queue->enqueue_pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,23 +370,23 @@ static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event)
|
|||
#ifdef TEST_SPINLOCK_FIFO
|
||||
/* This is a gate so an external thread can lock the queue */
|
||||
SDL_LockSpinlock(&queue->lock);
|
||||
SDL_assert(SDL_AtomicGet(&queue->watcher) == 0);
|
||||
SDL_assert(SDL_GetAtomicInt(&queue->watcher) == 0);
|
||||
SDL_AtomicIncRef(&queue->rwcount);
|
||||
SDL_UnlockSpinlock(&queue->lock);
|
||||
#endif
|
||||
|
||||
queue_pos = (unsigned)SDL_AtomicGet(&queue->dequeue_pos);
|
||||
queue_pos = (unsigned)SDL_GetAtomicInt(&queue->dequeue_pos);
|
||||
for (;;) {
|
||||
entry = &queue->entries[queue_pos & WRAP_MASK];
|
||||
entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence);
|
||||
entry_seq = (unsigned)SDL_GetAtomicInt(&entry->sequence);
|
||||
|
||||
delta = (int)(entry_seq - (queue_pos + 1));
|
||||
if (delta == 0) {
|
||||
/* The entry and the queue position match, try to increment the queue position */
|
||||
if (SDL_AtomicCompareAndSwap(&queue->dequeue_pos, (int)queue_pos, (int)(queue_pos + 1))) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&queue->dequeue_pos, (int)queue_pos, (int)(queue_pos + 1))) {
|
||||
/* We own the object, fill it! */
|
||||
*event = entry->event;
|
||||
SDL_AtomicSet(&entry->sequence, (int)(queue_pos + MAX_ENTRIES));
|
||||
SDL_SetAtomicInt(&entry->sequence, (int)(queue_pos + MAX_ENTRIES));
|
||||
status = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event)
|
|||
break;
|
||||
} else {
|
||||
/* We ran into a new queue entry, get the new queue position */
|
||||
queue_pos = (unsigned)SDL_AtomicGet(&queue->dequeue_pos);
|
||||
queue_pos = (unsigned)SDL_GetAtomicInt(&queue->dequeue_pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ static int SDLCALL FIFO_Reader(void *_data)
|
|||
if (DequeueEvent_LockFree(queue, &event)) {
|
||||
WriterData *writer = (WriterData *)event.user.data1;
|
||||
++data->counters[writer->index];
|
||||
} else if (SDL_AtomicGet(&queue->active)) {
|
||||
} else if (SDL_GetAtomicInt(&queue->active)) {
|
||||
++data->waits;
|
||||
SDL_Delay(0);
|
||||
} else {
|
||||
|
@ -550,7 +550,7 @@ static int SDLCALL FIFO_Reader(void *_data)
|
|||
if (DequeueEvent_Mutex(queue, &event)) {
|
||||
WriterData *writer = (WriterData *)event.user.data1;
|
||||
++data->counters[writer->index];
|
||||
} else if (SDL_AtomicGet(&queue->active)) {
|
||||
} else if (SDL_GetAtomicInt(&queue->active)) {
|
||||
++data->waits;
|
||||
SDL_Delay(0);
|
||||
} else {
|
||||
|
@ -568,10 +568,10 @@ static int SDLCALL FIFO_Watcher(void *_data)
|
|||
{
|
||||
SDL_EventQueue *queue = (SDL_EventQueue *)_data;
|
||||
|
||||
while (SDL_AtomicGet(&queue->active)) {
|
||||
while (SDL_GetAtomicInt(&queue->active)) {
|
||||
SDL_LockSpinlock(&queue->lock);
|
||||
SDL_AtomicIncRef(&queue->watcher);
|
||||
while (SDL_AtomicGet(&queue->rwcount) > 0) {
|
||||
while (SDL_GetAtomicInt(&queue->rwcount) > 0) {
|
||||
SDL_Delay(0);
|
||||
}
|
||||
/* Do queue manipulation here... */
|
||||
|
@ -645,7 +645,7 @@ static void RunFIFOTest(SDL_bool lock_free)
|
|||
}
|
||||
|
||||
/* Shut down the queue so readers exit */
|
||||
SDL_AtomicSet(&queue.active, 0);
|
||||
SDL_SetAtomicInt(&queue.active, 0);
|
||||
|
||||
/* Wait for the readers */
|
||||
for (i = 0; i < NUM_READERS; ++i) {
|
||||
|
|
|
@ -786,7 +786,7 @@ static void SDLCALL PostmixCallback(void *userdata, const SDL_AudioSpec *spec, f
|
|||
SDL_copyp(&thing->data.logdev.postmix_spec, spec);
|
||||
SDL_memcpy(thing->data.logdev.postmix_buffer, buffer, buflen);
|
||||
thing->data.logdev.postmix_buflen = buflen;
|
||||
SDL_AtomicSet(&thing->data.logdev.postmix_updated, 1);
|
||||
SDL_SetAtomicInt(&thing->data.logdev.postmix_updated, 1);
|
||||
|
||||
SDL_UnlockMutex(thing->data.logdev.postmix_lock);
|
||||
}
|
||||
|
@ -857,7 +857,7 @@ static void LogicalDeviceThing_ontick(Thing *thing, Uint64 now)
|
|||
if (thing->data.logdev.postmix_buffer) {
|
||||
SDL_memset(thing->data.logdev.postmix_buffer, '\0', thing->data.logdev.postmix_buflen);
|
||||
}
|
||||
SDL_AtomicSet(&thing->data.logdev.postmix_updated, 1); /* so this will at least clear the texture later. */
|
||||
SDL_SetAtomicInt(&thing->data.logdev.postmix_updated, 1); /* so this will at least clear the texture later. */
|
||||
SDL_SetAudioPostmixCallback(thing->data.logdev.devid, PostmixCallback, thing);
|
||||
}
|
||||
}
|
||||
|
@ -872,7 +872,7 @@ static void LogicalDeviceThing_ondraw(Thing *thing, SDL_Renderer *renderer)
|
|||
dst.x = thing->rect.x + ((thing->rect.w - dst.w) / 2);
|
||||
dst.y = thing->rect.y + ((thing->rect.h - dst.h) / 2);
|
||||
|
||||
if (SDL_AtomicGet(&thing->data.logdev.postmix_updated)) {
|
||||
if (SDL_GetAtomicInt(&thing->data.logdev.postmix_updated)) {
|
||||
float *buffer;
|
||||
int channels;
|
||||
int buflen;
|
||||
|
@ -883,7 +883,7 @@ static void LogicalDeviceThing_ondraw(Thing *thing, SDL_Renderer *renderer)
|
|||
buffer = (float *) SDL_malloc(thing->data.logdev.postmix_buflen);
|
||||
if (buffer) {
|
||||
SDL_memcpy(buffer, thing->data.logdev.postmix_buffer, thing->data.logdev.postmix_buflen);
|
||||
SDL_AtomicSet(&thing->data.logdev.postmix_updated, 0);
|
||||
SDL_SetAtomicInt(&thing->data.logdev.postmix_updated, 0);
|
||||
}
|
||||
SDL_UnlockMutex(thing->data.logdev.postmix_lock);
|
||||
|
||||
|
|
|
@ -568,7 +568,7 @@ render_thread_fn(void *render_ctx)
|
|||
thread_data *thread = render_ctx;
|
||||
|
||||
while (!done && !thread->done && state->windows[thread->index]) {
|
||||
if (SDL_AtomicCompareAndSwap(&thread->suspended, WAIT_STATE_ENTER_SEM, WAIT_STATE_WAITING_ON_SEM)) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&thread->suspended, WAIT_STATE_ENTER_SEM, WAIT_STATE_WAITING_ON_SEM)) {
|
||||
SDL_WaitSemaphore(thread->suspend_sem);
|
||||
}
|
||||
render_window(thread->index);
|
||||
|
@ -603,12 +603,12 @@ loop_threaded(void)
|
|||
if (suspend_when_occluded && event.type == SDL_EVENT_WINDOW_OCCLUDED) {
|
||||
tdata = GetThreadDataForWindow(event.window.windowID);
|
||||
if (tdata) {
|
||||
SDL_AtomicCompareAndSwap(&tdata->suspended, WAIT_STATE_GO, WAIT_STATE_ENTER_SEM);
|
||||
SDL_CompareAndSwapAtomicInt(&tdata->suspended, WAIT_STATE_GO, WAIT_STATE_ENTER_SEM);
|
||||
}
|
||||
} else if (suspend_when_occluded && event.type == SDL_EVENT_WINDOW_EXPOSED) {
|
||||
tdata = GetThreadDataForWindow(event.window.windowID);
|
||||
if (tdata) {
|
||||
if (SDL_AtomicSet(&tdata->suspended, WAIT_STATE_GO) == WAIT_STATE_WAITING_ON_SEM) {
|
||||
if (SDL_SetAtomicInt(&tdata->suspended, WAIT_STATE_GO) == WAIT_STATE_WAITING_ON_SEM) {
|
||||
SDL_SignalSemaphore(tdata->suspend_sem);
|
||||
}
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ loop_threaded(void)
|
|||
/* Stop the render thread when the window is closed */
|
||||
tdata->done = 1;
|
||||
if (tdata->thread) {
|
||||
SDL_AtomicSet(&tdata->suspended, WAIT_STATE_GO);
|
||||
SDL_SetAtomicInt(&tdata->suspended, WAIT_STATE_GO);
|
||||
SDL_SignalSemaphore(tdata->suspend_sem);
|
||||
SDL_WaitThread(tdata->thread, NULL);
|
||||
tdata->thread = NULL;
|
||||
|
@ -909,7 +909,7 @@ int main(int argc, char *argv[])
|
|||
/* Start a render thread for each window */
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
threads[i].index = i;
|
||||
SDL_AtomicSet(&threads[i].suspended, 0);
|
||||
SDL_SetAtomicInt(&threads[i].suspended, 0);
|
||||
threads[i].suspend_sem = SDL_CreateSemaphore(0);
|
||||
threads[i].thread = SDL_CreateThread(render_thread_fn, "RenderThread", &threads[i]);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ static void printid(void)
|
|||
static void terminate(int sig)
|
||||
{
|
||||
(void)signal(SIGINT, terminate);
|
||||
SDL_AtomicSet(&doterminate, 1);
|
||||
SDL_SetAtomicInt(&doterminate, 1);
|
||||
}
|
||||
|
||||
static void closemutex(int sig)
|
||||
|
@ -56,7 +56,7 @@ static void closemutex(int sig)
|
|||
SDL_ThreadID id = SDL_GetCurrentThreadID();
|
||||
int i;
|
||||
SDL_Log("Thread %" SDL_PRIu64 ": Cleaning up...\n", id == mainthread ? 0 : id);
|
||||
SDL_AtomicSet(&doterminate, 1);
|
||||
SDL_SetAtomicInt(&doterminate, 1);
|
||||
if (threads) {
|
||||
for (i = 0; i < nb_threads; ++i) {
|
||||
SDL_WaitThread(threads[i], NULL);
|
||||
|
@ -80,7 +80,7 @@ Run(void *data)
|
|||
(void)signal(SIGTERM, closemutex);
|
||||
}
|
||||
SDL_Log("Thread %" SDL_PRIu64 ": starting up", current_thread);
|
||||
while (!SDL_AtomicGet(&doterminate)) {
|
||||
while (!SDL_GetAtomicInt(&doterminate)) {
|
||||
SDL_Log("Thread %" SDL_PRIu64 ": ready to work\n", current_thread);
|
||||
SDL_LockMutex(mutex);
|
||||
SDL_Log("Thread %" SDL_PRIu64 ": start work!\n", current_thread);
|
||||
|
@ -91,7 +91,7 @@ Run(void *data)
|
|||
/* If this sleep isn't done, then threads may starve */
|
||||
SDL_Delay(10);
|
||||
}
|
||||
if (current_thread == mainthread && SDL_AtomicGet(&doterminate)) {
|
||||
if (current_thread == mainthread && SDL_GetAtomicInt(&doterminate)) {
|
||||
SDL_Log("Thread %" SDL_PRIu64 ": raising SIGTERM\n", current_thread);
|
||||
(void)raise(SIGTERM);
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
(void)atexit(SDL_Quit_Wrapper);
|
||||
|
||||
SDL_AtomicSet(&doterminate, 0);
|
||||
SDL_SetAtomicInt(&doterminate, 0);
|
||||
|
||||
mutex = SDL_CreateMutex();
|
||||
if (!mutex) {
|
||||
|
|
|
@ -54,7 +54,7 @@ static int SDLCALL
|
|||
ReaderRun(void *data)
|
||||
{
|
||||
SDL_Log("Reader Thread %" SDL_PRIu64 ": starting up", SDL_GetCurrentThreadID());
|
||||
while (!SDL_AtomicGet(&doterminate)) {
|
||||
while (!SDL_GetAtomicInt(&doterminate)) {
|
||||
DoWork(worktime);
|
||||
}
|
||||
SDL_Log("Reader Thread %" SDL_PRIu64 ": exiting!\n", SDL_GetCurrentThreadID());
|
||||
|
@ -71,7 +71,7 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&doterminate, 0);
|
||||
SDL_SetAtomicInt(&doterminate, 0);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
|
@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&doterminate, 0);
|
||||
SDL_SetAtomicInt(&doterminate, 0);
|
||||
|
||||
rwlock = SDL_CreateRWLock();
|
||||
if (!rwlock) {
|
||||
|
@ -157,11 +157,11 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
while (!SDL_AtomicGet(&doterminate) && (SDL_GetTicks() < ((Uint64) timeout))) {
|
||||
while (!SDL_GetAtomicInt(&doterminate) && (SDL_GetTicks() < ((Uint64) timeout))) {
|
||||
DoWork(writerworktime);
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&doterminate, 1);
|
||||
SDL_SetAtomicInt(&doterminate, 1);
|
||||
SDL_Log("Waiting on reader threads to terminate...");
|
||||
for (i = 0; i < nb_threads; ++i) {
|
||||
SDL_WaitThread(threads[i], NULL);
|
||||
|
|
|
@ -62,7 +62,7 @@ ThreadFunc(void *data)
|
|||
SDL_SetTLS(&tls, "baby thread", NULL);
|
||||
SDL_Log("Started thread %s: My thread id is %" SDL_PRIu64 ", thread data = %s\n",
|
||||
(char *)data, SDL_GetCurrentThreadID(), (const char *)SDL_GetTLS(&tls));
|
||||
while (SDL_AtomicGet(&alive)) {
|
||||
while (SDL_GetAtomicInt(&alive)) {
|
||||
SDL_Log("Thread '%s' is alive!\n", (char *)data);
|
||||
|
||||
if (testprio) {
|
||||
|
@ -83,7 +83,7 @@ killed(int sig)
|
|||
{
|
||||
SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
|
||||
SDL_Delay(5 * 1000);
|
||||
SDL_AtomicSet(&alive, 0);
|
||||
SDL_SetAtomicInt(&alive, 0);
|
||||
SDL_WaitThread(thread, NULL);
|
||||
quit(0);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|||
SDL_SetTLS(&tls, "main thread", NULL);
|
||||
SDL_Log("Main thread data initially: %s\n", (const char *)SDL_GetTLS(&tls));
|
||||
|
||||
SDL_AtomicSet(&alive, 1);
|
||||
SDL_SetAtomicInt(&alive, 1);
|
||||
thread = SDL_CreateThread(ThreadFunc, "One", "#1");
|
||||
if (!thread) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
|
||||
|
@ -141,12 +141,12 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
SDL_Delay(5 * 1000);
|
||||
SDL_Log("Waiting for thread #1\n");
|
||||
SDL_AtomicSet(&alive, 0);
|
||||
SDL_SetAtomicInt(&alive, 0);
|
||||
SDL_WaitThread(thread, NULL);
|
||||
|
||||
SDL_Log("Main thread data finally: %s\n", (const char *)SDL_GetTLS(&tls));
|
||||
|
||||
SDL_AtomicSet(&alive, 1);
|
||||
SDL_SetAtomicInt(&alive, 1);
|
||||
(void)signal(SIGTERM, killed);
|
||||
thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
|
||||
if (!thread) {
|
||||
|
|
|
@ -38,7 +38,7 @@ static int SDLCALL
|
|||
SubThreadFunc(void *data)
|
||||
{
|
||||
SDL_AtomicInt *flag = (SDL_AtomicInt *)data;
|
||||
while (!SDL_AtomicGet(flag)) {
|
||||
while (!SDL_GetAtomicInt(flag)) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
return 0;
|
||||
|
@ -57,18 +57,18 @@ ThreadFunc(void *data)
|
|||
for (i = 0; i < NUMTHREADS; i++) {
|
||||
char name[64];
|
||||
(void)SDL_snprintf(name, sizeof(name), "Child%d_%d", tid, i);
|
||||
SDL_AtomicSet(&flags[i], 0);
|
||||
SDL_SetAtomicInt(&flags[i], 0);
|
||||
sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]);
|
||||
}
|
||||
|
||||
SDL_Log("Thread '%d' waiting for signal\n", tid);
|
||||
while (SDL_AtomicGet(&time_for_threads_to_die[tid]) != 1) {
|
||||
while (SDL_GetAtomicInt(&time_for_threads_to_die[tid]) != 1) {
|
||||
; /* do nothing */
|
||||
}
|
||||
|
||||
SDL_Log("Thread '%d' sending signals to subthreads\n", tid);
|
||||
for (i = 0; i < NUMTHREADS; i++) {
|
||||
SDL_AtomicSet(&flags[i], 1);
|
||||
SDL_SetAtomicInt(&flags[i], 1);
|
||||
SDL_WaitThread(sub_threads[i], NULL);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ int main(int argc, char *argv[])
|
|||
for (i = 0; i < NUMTHREADS; i++) {
|
||||
char name[64];
|
||||
(void)SDL_snprintf(name, sizeof(name), "Parent%d", i);
|
||||
SDL_AtomicSet(&time_for_threads_to_die[i], 0);
|
||||
SDL_SetAtomicInt(&time_for_threads_to_die[i], 0);
|
||||
threads[i] = SDL_CreateThread(ThreadFunc, name, (void *)(uintptr_t)i);
|
||||
|
||||
if (threads[i] == NULL) {
|
||||
|
@ -109,7 +109,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
for (i = 0; i < NUMTHREADS; i++) {
|
||||
SDL_AtomicSet(&time_for_threads_to_die[i], 1);
|
||||
SDL_SetAtomicInt(&time_for_threads_to_die[i], 1);
|
||||
}
|
||||
|
||||
for (i = 0; i < NUMTHREADS; i++) {
|
||||
|
|
Loading…
Reference in New Issue