summaryrefslogtreecommitdiffstats
path: root/Alc/ALc.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-10 03:01:24 -0700
committerChris Robinson <[email protected]>2011-09-10 03:01:24 -0700
commitc35433ec7a0a1bad22ddbd347265e296adb700ef (patch)
tree1230ef24f578a65f0612c509f2399a90aac51b81 /Alc/ALc.c
parente8c9da012419f4fecd1a81463efd2d1f54d20b7f (diff)
Hold an extra reference on the device for each of its contexts
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r--Alc/ALc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 93d37853..565755a6 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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);