From 323162c49f6c474c211b7f27a720300473f1e75f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 28 Jun 2017 21:15:30 -0700 Subject: Implement creating and destroying contexts --- router/alc.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'router') diff --git a/router/alc.c b/router/alc.c index 1f543308..03a42dff 100644 --- a/router/alc.c +++ b/router/alc.c @@ -375,7 +375,25 @@ ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device) ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrlist) { - return NULL; + ALCcontext *context; + ALint idx; + + if(!device || (idx=LookupPtrIntMapKey(&DeviceIfaceMap, device) < 0)) + { + ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_DEVICE); + return ALC_FALSE; + } + context = DriverList[idx].alcCreateContext(device, attrlist); + if(context) + { + if(InsertPtrIntMapEntry(&ContextIfaceMap, context, idx) != ALC_NO_ERROR) + { + DriverList[idx].alcDestroyContext(context); + context = NULL; + } + } + + return context; } ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) @@ -407,6 +425,16 @@ ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context) ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context) { + ALint idx; + + if(!context || (idx=LookupPtrIntMapKey(&ContextIfaceMap, context) < 0)) + { + ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_CONTEXT); + return; + } + + DriverList[idx].alcDestroyContext(context); + RemovePtrIntMapKey(&ContextIfaceMap, context); } ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void) -- cgit v1.2.3