aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-28 18:53:23 -0700
committerChris Robinson <[email protected]>2011-08-28 18:53:23 -0700
commit1d9f21f6dce971838e0cb148f3b92a9d7b512700 (patch)
treeff62c186705fd6fe2298527989756505d802a45b /Alc
parent0900c281a31df751d9a1faf832595558b74e5a92 (diff)
Avoid a global list of contexts
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index cd2234a4..34a54cfa 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -362,10 +362,6 @@ static CRITICAL_SECTION ListLock;
static ALCdevice *g_pDeviceList = NULL;
static ALCuint g_ulDeviceCount = 0;
-// Context List
-static ALCcontext *g_pContextList = NULL;
-static ALCuint g_ulContextCount = 0;
-
// Thread-local current context
static pthread_key_t LocalContext;
// Process-wide current context
@@ -1016,15 +1012,23 @@ static ALCboolean IsDevice(ALCdevice *pDevice)
Check pContext is a valid Context pointer
*/
-static ALCboolean IsContext(ALCcontext *pContext)
+static ALCboolean IsContext(ALCcontext *context)
{
- ALCcontext *pTempContext;
+ ALCdevice *tmp_dev;
- pTempContext = g_pContextList;
- while (pTempContext && pTempContext != pContext)
- pTempContext = pTempContext->next;
+ tmp_dev = g_pDeviceList;
+ while(tmp_dev)
+ {
+ ALuint i;
+ for(i = 0;i < tmp_dev->NumContexts;i++)
+ {
+ if(tmp_dev->Contexts[i] == context)
+ return ALC_TRUE;
+ }
+ tmp_dev = tmp_dev->next;
+ }
- return (pTempContext ? ALC_TRUE : ALC_FALSE);
+ return ALC_FALSE;
}
@@ -2081,12 +2085,8 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
ALContext->Device = device;
InitContext(ALContext);
- UnlockDevice(device);
-
- ALContext->next = g_pContextList;
- g_pContextList = ALContext;
- g_ulContextCount++;
+ UnlockDevice(device);
UnlockLists();
return ALContext;
@@ -2101,25 +2101,16 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin
ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context)
{
ALCdevice *Device;
- ALCcontext **list;
ALuint i;
LockLists();
- list = &g_pContextList;
- while(*list && *list != context)
- list = &(*list)->next;
-
- if(!*list)
+ Device = alcGetContextsDevice(context);
+ if(!Device)
{
- alcSetError(NULL, ALC_INVALID_CONTEXT);
UnlockLists();
return;
}
- *list = (*list)->next;
- g_ulContextCount--;
-
- Device = context->Device;
LockDevice(Device);
for(i = 0;i < Device->NumContexts;i++)
{