Avoid multiple list searches when destroying devices and contexts
This commit is contained in:
parent
0f782b385b
commit
5a15dc4ddf
34
Alc/ALc.c
34
Alc/ALc.c
@ -1612,17 +1612,17 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice)
|
||||
ALCdevice **list;
|
||||
|
||||
LockLists();
|
||||
if(!IsDevice(pDevice) || !pDevice->IsCaptureDevice)
|
||||
list = &g_pDeviceList;
|
||||
while(*list && *list != pDevice)
|
||||
list = &(*list)->next;
|
||||
|
||||
if(!*list || !(*list)->IsCaptureDevice)
|
||||
{
|
||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||
alcSetError(*list, ALC_INVALID_DEVICE);
|
||||
UnlockLists();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
list = &g_pDeviceList;
|
||||
while(*list != pDevice)
|
||||
list = &(*list)->next;
|
||||
|
||||
*list = (*list)->next;
|
||||
g_ulDeviceCount--;
|
||||
|
||||
@ -2187,17 +2187,17 @@ ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context)
|
||||
ALuint i;
|
||||
|
||||
LockLists();
|
||||
if(!IsContext(context))
|
||||
list = &g_pContextList;
|
||||
while(*list && *list != context)
|
||||
list = &(*list)->next;
|
||||
|
||||
if(!*list)
|
||||
{
|
||||
alcSetError(NULL, ALC_INVALID_CONTEXT);
|
||||
UnlockLists();
|
||||
return;
|
||||
}
|
||||
|
||||
list = &g_pContextList;
|
||||
while(*list != context)
|
||||
list = &(*list)->next;
|
||||
|
||||
*list = (*list)->next;
|
||||
g_ulContextCount--;
|
||||
|
||||
@ -2693,17 +2693,17 @@ ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *pDevice)
|
||||
ALCdevice **list;
|
||||
|
||||
LockLists();
|
||||
if(!IsDevice(pDevice) || pDevice->IsCaptureDevice)
|
||||
list = &g_pDeviceList;
|
||||
while(*list && *list != pDevice)
|
||||
list = &(*list)->next;
|
||||
|
||||
if(!*list || (*list)->IsCaptureDevice)
|
||||
{
|
||||
alcSetError(pDevice, ALC_INVALID_DEVICE);
|
||||
alcSetError(*list, ALC_INVALID_DEVICE);
|
||||
UnlockLists();
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
list = &g_pDeviceList;
|
||||
while(*list != pDevice)
|
||||
list = &(*list)->next;
|
||||
|
||||
*list = (*list)->next;
|
||||
g_ulDeviceCount--;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user