Always use the thunk functions to get object IDs
This commit is contained in:
parent
c1f435cc18
commit
199df253ca
@ -484,7 +484,7 @@ static void alc_init(void)
|
||||
|
||||
tls_create(&LocalContext);
|
||||
InitializeCriticalSection(&ListLock);
|
||||
ALTHUNK_INIT();
|
||||
ThunkInit();
|
||||
}
|
||||
|
||||
static void alc_deinit_safe(void)
|
||||
@ -492,7 +492,8 @@ static void alc_deinit_safe(void)
|
||||
ReleaseALC(ALC_FALSE);
|
||||
|
||||
FreeALConfig();
|
||||
ALTHUNK_EXIT();
|
||||
|
||||
ThunkExit();
|
||||
DeleteCriticalSection(&ListLock);
|
||||
tls_delete(LocalContext);
|
||||
|
||||
|
@ -1,39 +1,20 @@
|
||||
#ifndef _AL_THUNK_H_
|
||||
#define _AL_THUNK_H_
|
||||
#ifndef ALTHUNK_H
|
||||
#define ALTHUNK_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "AL/al.h"
|
||||
#include "AL/alc.h"
|
||||
#include "alMain.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void alThunkInit(void);
|
||||
void alThunkExit(void);
|
||||
ALenum alThunkNewEntry(ALuint *idx);
|
||||
void alThunkRemoveEntry(ALuint index);
|
||||
|
||||
#if (SIZEOF_VOIDP > SIZEOF_UINT)
|
||||
|
||||
#define ALTHUNK_INIT() alThunkInit()
|
||||
#define ALTHUNK_EXIT() alThunkExit()
|
||||
#define ALTHUNK_NEWENTRY(p,i) alThunkNewEntry(i)
|
||||
#define ALTHUNK_REMOVEENTRY(i) alThunkRemoveEntry(i)
|
||||
|
||||
#else
|
||||
|
||||
#define ALTHUNK_INIT()
|
||||
#define ALTHUNK_EXIT()
|
||||
#define ALTHUNK_NEWENTRY(p,i) ((*(i) = (ALuint)p),AL_NO_ERROR)
|
||||
#define ALTHUNK_REMOVEENTRY(i) ((ALvoid)i)
|
||||
|
||||
#endif // (SIZEOF_VOIDP > SIZEOF_INT)
|
||||
void ThunkInit(void);
|
||||
void ThunkExit(void);
|
||||
ALenum NewThunkEntry(ALuint *index);
|
||||
void FreeThunkEntry(ALuint index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_AL_THUNK_H_
|
||||
#endif //ALTHUNK_H
|
||||
|
||||
|
@ -68,12 +68,12 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
|
||||
break;
|
||||
}
|
||||
|
||||
err = ALTHUNK_NEWENTRY(slot, &slot->effectslot);
|
||||
err = NewThunkEntry(&slot->effectslot);
|
||||
if(err == AL_NO_ERROR)
|
||||
err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->effectslot, slot);
|
||||
if(err != AL_NO_ERROR)
|
||||
{
|
||||
ALTHUNK_REMOVEENTRY(slot->effectslot);
|
||||
FreeThunkEntry(slot->effectslot);
|
||||
ALEffect_Destroy(slot->EffectState);
|
||||
free(slot);
|
||||
|
||||
@ -146,7 +146,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effect
|
||||
ALEffect_Destroy(EffectSlot->EffectState);
|
||||
|
||||
RemoveUIntMapKey(&Context->EffectSlotMap, EffectSlot->effectslot);
|
||||
ALTHUNK_REMOVEENTRY(EffectSlot->effectslot);
|
||||
FreeThunkEntry(EffectSlot->effectslot);
|
||||
|
||||
memset(EffectSlot, 0, sizeof(ALeffectslot));
|
||||
free(EffectSlot);
|
||||
@ -533,7 +533,7 @@ ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context)
|
||||
// Release effectslot structure
|
||||
ALEffect_Destroy(temp->EffectState);
|
||||
|
||||
ALTHUNK_REMOVEENTRY(temp->effectslot);
|
||||
FreeThunkEntry(temp->effectslot);
|
||||
memset(temp, 0, sizeof(ALeffectslot));
|
||||
free(temp);
|
||||
}
|
||||
|
@ -163,12 +163,12 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers)
|
||||
break;
|
||||
}
|
||||
|
||||
err = ALTHUNK_NEWENTRY(buffer, &buffer->buffer);
|
||||
err = NewThunkEntry(&buffer->buffer);
|
||||
if(err == AL_NO_ERROR)
|
||||
err = InsertUIntMapEntry(&device->BufferMap, buffer->buffer, buffer);
|
||||
if(err != AL_NO_ERROR)
|
||||
{
|
||||
ALTHUNK_REMOVEENTRY(buffer->buffer);
|
||||
FreeThunkEntry(buffer->buffer);
|
||||
memset(buffer, 0, sizeof(ALbuffer));
|
||||
free(buffer);
|
||||
|
||||
@ -245,7 +245,7 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
|
||||
|
||||
/* Release buffer structure */
|
||||
RemoveUIntMapKey(&device->BufferMap, ALBuf->buffer);
|
||||
ALTHUNK_REMOVEENTRY(ALBuf->buffer);
|
||||
FreeThunkEntry(ALBuf->buffer);
|
||||
|
||||
memset(ALBuf, 0, sizeof(ALbuffer));
|
||||
free(ALBuf);
|
||||
@ -2204,7 +2204,7 @@ ALvoid ReleaseALBuffers(ALCdevice *device)
|
||||
|
||||
free(temp->data);
|
||||
|
||||
ALTHUNK_REMOVEENTRY(temp->buffer);
|
||||
FreeThunkEntry(temp->buffer);
|
||||
memset(temp, 0, sizeof(ALbuffer));
|
||||
free(temp);
|
||||
}
|
||||
|
@ -63,12 +63,12 @@ AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
|
||||
break;
|
||||
}
|
||||
|
||||
err = ALTHUNK_NEWENTRY(effect, &effect->effect);
|
||||
err = NewThunkEntry(&effect->effect);
|
||||
if(err == AL_NO_ERROR)
|
||||
err = InsertUIntMapEntry(&device->EffectMap, effect->effect, effect);
|
||||
if(err != AL_NO_ERROR)
|
||||
{
|
||||
ALTHUNK_REMOVEENTRY(effect->effect);
|
||||
FreeThunkEntry(effect->effect);
|
||||
memset(effect, 0, sizeof(ALeffect));
|
||||
free(effect);
|
||||
|
||||
@ -128,7 +128,7 @@ AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects)
|
||||
continue;
|
||||
|
||||
RemoveUIntMapKey(&device->EffectMap, ALEffect->effect);
|
||||
ALTHUNK_REMOVEENTRY(ALEffect->effect);
|
||||
FreeThunkEntry(ALEffect->effect);
|
||||
|
||||
memset(ALEffect, 0, sizeof(ALeffect));
|
||||
free(ALEffect);
|
||||
@ -1076,7 +1076,7 @@ ALvoid ReleaseALEffects(ALCdevice *device)
|
||||
device->EffectMap.array[i].value = NULL;
|
||||
|
||||
// Release effect structure
|
||||
ALTHUNK_REMOVEENTRY(temp->effect);
|
||||
FreeThunkEntry(temp->effect);
|
||||
memset(temp, 0, sizeof(ALeffect));
|
||||
free(temp);
|
||||
}
|
||||
|
@ -59,12 +59,12 @@ AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
|
||||
break;
|
||||
}
|
||||
|
||||
err = ALTHUNK_NEWENTRY(filter, &filter->filter);
|
||||
err = NewThunkEntry(&filter->filter);
|
||||
if(err == AL_NO_ERROR)
|
||||
err = InsertUIntMapEntry(&device->FilterMap, filter->filter, filter);
|
||||
if(err != AL_NO_ERROR)
|
||||
{
|
||||
ALTHUNK_REMOVEENTRY(filter->filter);
|
||||
FreeThunkEntry(filter->filter);
|
||||
memset(filter, 0, sizeof(ALfilter));
|
||||
free(filter);
|
||||
|
||||
@ -124,7 +124,7 @@ AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters)
|
||||
continue;
|
||||
|
||||
RemoveUIntMapKey(&device->FilterMap, ALFilter->filter);
|
||||
ALTHUNK_REMOVEENTRY(ALFilter->filter);
|
||||
FreeThunkEntry(ALFilter->filter);
|
||||
|
||||
memset(ALFilter, 0, sizeof(ALfilter));
|
||||
free(ALFilter);
|
||||
@ -404,7 +404,7 @@ ALvoid ReleaseALFilters(ALCdevice *device)
|
||||
device->FilterMap.array[i].value = NULL;
|
||||
|
||||
// Release filter structure
|
||||
ALTHUNK_REMOVEENTRY(temp->filter);
|
||||
FreeThunkEntry(temp->filter);
|
||||
memset(temp, 0, sizeof(ALfilter));
|
||||
free(temp);
|
||||
}
|
||||
|
@ -85,12 +85,12 @@ AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources)
|
||||
break;
|
||||
}
|
||||
|
||||
err = ALTHUNK_NEWENTRY(source, &source->source);
|
||||
err = NewThunkEntry(&source->source);
|
||||
if(err == AL_NO_ERROR)
|
||||
err = InsertUIntMapEntry(&Context->SourceMap, source->source, source);
|
||||
if(err != AL_NO_ERROR)
|
||||
{
|
||||
ALTHUNK_REMOVEENTRY(source->source);
|
||||
FreeThunkEntry(source->source);
|
||||
memset(source, 0, sizeof(ALsource));
|
||||
free(source);
|
||||
|
||||
@ -175,7 +175,7 @@ AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
|
||||
|
||||
// Remove Source from list of Sources
|
||||
RemoveUIntMapKey(&Context->SourceMap, Source->source);
|
||||
ALTHUNK_REMOVEENTRY(Source->source);
|
||||
FreeThunkEntry(Source->source);
|
||||
|
||||
memset(Source,0,sizeof(ALsource));
|
||||
free(Source);
|
||||
@ -2165,7 +2165,7 @@ ALvoid ReleaseALSources(ALCcontext *Context)
|
||||
}
|
||||
|
||||
// Release source structure
|
||||
ALTHUNK_REMOVEENTRY(temp->source);
|
||||
FreeThunkEntry(temp->source);
|
||||
memset(temp, 0, sizeof(ALsource));
|
||||
free(temp);
|
||||
}
|
||||
|
@ -31,14 +31,14 @@ static ALuint g_ThunkArraySize;
|
||||
|
||||
static CRITICAL_SECTION g_ThunkLock;
|
||||
|
||||
void alThunkInit(void)
|
||||
void ThunkInit(void)
|
||||
{
|
||||
InitializeCriticalSection(&g_ThunkLock);
|
||||
g_ThunkArraySize = 1;
|
||||
g_ThunkArray = calloc(1, g_ThunkArraySize * sizeof(*g_ThunkArray));
|
||||
}
|
||||
|
||||
void alThunkExit(void)
|
||||
void ThunkExit(void)
|
||||
{
|
||||
free(g_ThunkArray);
|
||||
g_ThunkArray = NULL;
|
||||
@ -46,7 +46,7 @@ void alThunkExit(void)
|
||||
DeleteCriticalSection(&g_ThunkLock);
|
||||
}
|
||||
|
||||
ALenum alThunkNewEntry(ALuint *idx)
|
||||
ALenum NewThunkEntry(ALuint *idx)
|
||||
{
|
||||
ALuint index;
|
||||
|
||||
@ -82,7 +82,7 @@ ALenum alThunkNewEntry(ALuint *idx)
|
||||
return AL_NO_ERROR;
|
||||
}
|
||||
|
||||
void alThunkRemoveEntry(ALuint index)
|
||||
void FreeThunkEntry(ALuint index)
|
||||
{
|
||||
EnterCriticalSection(&g_ThunkLock);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user