diff options
author | Chris Robinson <[email protected]> | 2011-09-10 03:01:24 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-09-10 03:01:24 -0700 |
commit | c35433ec7a0a1bad22ddbd347265e296adb700ef (patch) | |
tree | 1230ef24f578a65f0612c509f2399a90aac51b81 /Alc | |
parent | e8c9da012419f4fecd1a81463efd2d1f54d20b7f (diff) |
Hold an extra reference on the device for each of its contexts
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1330,6 +1330,8 @@ ALCvoid UnlockDevice(ALCdevice *device) static ALCvoid FreeDevice(ALCdevice *device) { + TRACE("%p\n", device); + if(device->BufferMap.size > 0) { WARN("Deleting %d Buffer(s)\n", device->BufferMap.size); @@ -1362,6 +1364,13 @@ static ALCvoid FreeDevice(ALCdevice *device) free(device); } +void ALCdevice_IncRef(ALCdevice *device) +{ + RefCount ref; + ref = IncrementRef(&device->ref); + TRACE("%p increasing refcount to %u\n", device, ref); +} + void ALCdevice_DecRef(ALCdevice *device) { RefCount ref; @@ -1377,6 +1386,8 @@ void ALCdevice_DecRef(ALCdevice *device) */ static ALvoid InitContext(ALCcontext *pContext) { + ALCdevice_IncRef(pContext->Device); + //Initialise listener pContext->Listener.Gain = 1.0f; pContext->Listener.MetersPerUnit = 1.0f; @@ -1445,6 +1456,9 @@ static ALCvoid FreeContext(ALCcontext *context) context->ActiveEffectSlots = NULL; context->MaxActiveEffectSlots = 0; + ALCdevice_DecRef(context->Device); + context->Device = NULL; + //Invalidate context memset(context, 0, sizeof(ALCcontext)); free(context); |