diff options
author | Chris Robinson <[email protected]> | 2017-06-28 21:15:30 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-06-28 21:15:30 -0700 |
commit | 323162c49f6c474c211b7f27a720300473f1e75f (patch) | |
tree | 18a9501b56153a568f1c33ce3a8151967523461d /router | |
parent | ea4379c5b7d685c936569ec14a0f31d5ea173fd6 (diff) |
Implement creating and destroying contexts
Diffstat (limited to 'router')
-rw-r--r-- | router/alc.c | 30 |
1 files changed, 29 insertions, 1 deletions
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) |