diff options
author | Chris Robinson <[email protected]> | 2014-05-14 02:47:07 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-05-14 02:47:07 -0700 |
commit | 1d2504d12e996a4c1e8fe9785901db9a9e3b4d7c (patch) | |
tree | 51895ba97192cee1fccab44a838e4fa43d81a984 /Alc | |
parent | 4454ae25c753388c529b937ae2ce0f47f06d16c4 (diff) |
Make RefCount a non-integer type
It should only be accessed through the appropriate functions to ensure proper
atomicity.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 16 | ||||
-rw-r--r-- | Alc/backends/winmm.c | 8 |
2 files changed, 12 insertions, 12 deletions
@@ -2024,14 +2024,14 @@ static ALCvoid FreeDevice(ALCdevice *device) void ALCdevice_IncRef(ALCdevice *device) { - RefCount ref; + uint ref; ref = IncrementRef(&device->ref); TRACEREF("%p increasing refcount to %u\n", device, ref); } void ALCdevice_DecRef(ALCdevice *device) { - RefCount ref; + uint ref; ref = DecrementRef(&device->ref); TRACEREF("%p decreasing refcount to %u\n", device, ref); if(ref == 0) FreeDevice(device); @@ -2189,14 +2189,14 @@ static void ReleaseContext(ALCcontext *context, ALCdevice *device) void ALCcontext_IncRef(ALCcontext *context) { - RefCount ref; + uint ref; ref = IncrementRef(&context->ref); TRACEREF("%p increasing refcount to %u\n", context, ref); } void ALCcontext_DecRef(ALCcontext *context) { - RefCount ref; + uint ref; ref = DecrementRef(&context->ref); TRACEREF("%p decreasing refcount to %u\n", context, ref); if(ref == 0) FreeContext(context); @@ -2855,7 +2855,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin ALContext = calloc(1, sizeof(ALCcontext)+sizeof(ALlistener)); if(ALContext) { - ALContext->ref = 1; + InitRef(&ALContext->ref, 1); ALContext->Listener = (ALlistener*)ALContext->_listener_mem; VECTOR_INIT(ALContext->ActiveAuxSlots); @@ -3052,7 +3052,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) } //Validate device - device->ref = 1; + InitRef(&device->ref, 1); device->Connected = ALC_TRUE; device->Type = Playback; device->LastError = ALC_NO_ERROR; @@ -3352,7 +3352,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, } //Validate device - device->ref = 1; + InitRef(&device->ref, 1); device->Connected = ALC_TRUE; device->Type = Capture; @@ -3518,7 +3518,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN } //Validate device - device->ref = 1; + InitRef(&device->ref, 1); device->Connected = ALC_TRUE; device->Type = Loopback; device->LastError = ALC_NO_ERROR; diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c index 2f01ffdf..624af37a 100644 --- a/Alc/backends/winmm.c +++ b/Alc/backends/winmm.c @@ -41,7 +41,7 @@ typedef struct { volatile ALboolean killNow; althrd_t thread; - volatile RefCount WaveBuffersCommitted; + RefCount WaveBuffersCommitted; WAVEHDR WaveBuffer[4]; union { @@ -194,7 +194,7 @@ FORCE_ALIGN static int PlaybackThreadProc(void *arg) if(data->killNow) { - if(data->WaveBuffersCommitted == 0) + if(ReadRef(&data->WaveBuffersCommitted) == 0) break; continue; } @@ -412,7 +412,7 @@ static ALCboolean WinMMStartPlayback(ALCdevice *device) if(althrd_create(&data->thread, PlaybackThreadProc, device) != althrd_success) return ALC_FALSE; - data->WaveBuffersCommitted = 0; + InitRef(&data->WaveBuffersCommitted, 0); // Create 4 Buffers BufferSize = device->UpdateSize*device->NumUpdates / 4; @@ -549,7 +549,7 @@ static ALCenum WinMMOpenCapture(ALCdevice *Device, const ALCchar *deviceName) if(!data->Ring) goto failure; - data->WaveBuffersCommitted = 0; + InitRef(&data->WaveBuffersCommitted, 0); // Create 4 Buffers of 50ms each BufferSize = data->Format.nAvgBytesPerSec / 20; |