aboutsummaryrefslogtreecommitdiffstats
path: root/router
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-06-28 21:54:44 -0700
committerChris Robinson <[email protected]>2017-06-28 21:54:44 -0700
commita729007887d771ee927da1ef1bc832502e17b2a1 (patch)
tree26099530cff44742030596f99c89869a2c46bb94 /router
parent323162c49f6c474c211b7f27a720300473f1e75f (diff)
Implement setting a context current in the router
Diffstat (limited to 'router')
-rw-r--r--router/alc.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/router/alc.c b/router/alc.c
index 03a42dff..704aa146 100644
--- a/router/alc.c
+++ b/router/alc.c
@@ -398,7 +398,36 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
{
- return ALC_FALSE;
+ ALint idx = -1;
+
+ if(context)
+ {
+ idx = LookupPtrIntMapKey(&ContextIfaceMap, context);
+ if(idx < 0)
+ {
+ ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_CONTEXT);
+ return ALC_FALSE;
+ }
+ if(!DriverList[idx].alcMakeContextCurrent(context))
+ return ALC_FALSE;
+ }
+
+ /* Unset the context from the old driver if it's different from the new
+ * current one.
+ */
+ if(idx < 0)
+ {
+ DriverIface *oldiface = ATOMIC_EXCHANGE_PTR_SEQ(&CurrentCtxDriver, NULL);
+ if(oldiface) oldiface->alcMakeContextCurrent(NULL);
+ }
+ else
+ {
+ DriverIface *oldiface = ATOMIC_EXCHANGE_PTR_SEQ(&CurrentCtxDriver, &DriverList[idx]);
+ if(oldiface && oldiface != &DriverList[idx])
+ oldiface->alcMakeContextCurrent(NULL);
+ }
+
+ return ALC_TRUE;
}
ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context)
@@ -439,7 +468,8 @@ ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context)
ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void)
{
- return NULL;
+ DriverIface *iface = ATOMIC_LOAD_SEQ(&CurrentCtxDriver);
+ return iface ? iface->alcGetCurrentContext() : NULL;
}
ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context)