diff options
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alThunk.h | 9 | ||||
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 2 | ||||
-rw-r--r-- | OpenAL32/alBuffer.c | 2 | ||||
-rw-r--r-- | OpenAL32/alEffect.c | 2 | ||||
-rw-r--r-- | OpenAL32/alFilter.c | 2 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 14 | ||||
-rw-r--r-- | OpenAL32/alThunk.c | 37 |
7 files changed, 23 insertions, 45 deletions
diff --git a/OpenAL32/Include/alThunk.h b/OpenAL32/Include/alThunk.h index b4dae22a..9514db4d 100644 --- a/OpenAL32/Include/alThunk.h +++ b/OpenAL32/Include/alThunk.h @@ -12,25 +12,22 @@ extern "C" { void alThunkInit(void); void alThunkExit(void); -ALenum alThunkAddEntry(ALvoid *ptr, ALuint *idx); +ALenum alThunkNewEntry(ALuint *idx); void alThunkRemoveEntry(ALuint index); -ALvoid *alThunkLookupEntry(ALuint index); #if (SIZEOF_VOIDP > SIZEOF_UINT) #define ALTHUNK_INIT() alThunkInit() #define ALTHUNK_EXIT() alThunkExit() -#define ALTHUNK_ADDENTRY(p,i) alThunkAddEntry(p,i) +#define ALTHUNK_NEWENTRY(p,i) alThunkNewEntry(i) #define ALTHUNK_REMOVEENTRY(i) alThunkRemoveEntry(i) -#define ALTHUNK_LOOKUPENTRY(i) alThunkLookupEntry(i) #else #define ALTHUNK_INIT() #define ALTHUNK_EXIT() -#define ALTHUNK_ADDENTRY(p,i) ((*(i) = (ALuint)p),AL_NO_ERROR) +#define ALTHUNK_NEWENTRY(p,i) ((*(i) = (ALuint)p),AL_NO_ERROR) #define ALTHUNK_REMOVEENTRY(i) ((ALvoid)i) -#define ALTHUNK_LOOKUPENTRY(i) ((ALvoid*)(i)) #endif // (SIZEOF_VOIDP > SIZEOF_INT) diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 2d8cf06f..0d67423e 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -68,7 +68,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo break; } - err = ALTHUNK_ADDENTRY(slot, &slot->effectslot); + err = ALTHUNK_NEWENTRY(slot, &slot->effectslot); if(err == AL_NO_ERROR) err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->effectslot, slot); if(err != AL_NO_ERROR) diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 267faad5..1f54752c 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -163,7 +163,7 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers) break; } - err = ALTHUNK_ADDENTRY(buffer, &buffer->buffer); + err = ALTHUNK_NEWENTRY(buffer, &buffer->buffer); if(err == AL_NO_ERROR) err = InsertUIntMapEntry(&device->BufferMap, buffer->buffer, buffer); if(err != AL_NO_ERROR) diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c index ecaa691e..84cb81e3 100644 --- a/OpenAL32/alEffect.c +++ b/OpenAL32/alEffect.c @@ -63,7 +63,7 @@ AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) break; } - err = ALTHUNK_ADDENTRY(effect, &effect->effect); + err = ALTHUNK_NEWENTRY(effect, &effect->effect); if(err == AL_NO_ERROR) err = InsertUIntMapEntry(&device->EffectMap, effect->effect, effect); if(err != AL_NO_ERROR) diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c index 5e73cbae..040014c2 100644 --- a/OpenAL32/alFilter.c +++ b/OpenAL32/alFilter.c @@ -59,7 +59,7 @@ AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) break; } - err = ALTHUNK_ADDENTRY(filter, &filter->filter); + err = ALTHUNK_NEWENTRY(filter, &filter->filter); if(err == AL_NO_ERROR) err = InsertUIntMapEntry(&device->FilterMap, filter->filter, filter); if(err != AL_NO_ERROR) diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 532d5178..6a6edfa0 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -85,7 +85,7 @@ AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources) break; } - err = ALTHUNK_ADDENTRY(source, &source->source); + err = ALTHUNK_NEWENTRY(source, &source->source); if(err == AL_NO_ERROR) err = InsertUIntMapEntry(&Context->SourceMap, source->source, source); if(err != AL_NO_ERROR) @@ -1376,7 +1376,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) for(i = 0;i < n;i++) { - Source = (ALsource*)ALTHUNK_LOOKUPENTRY(sources[i]); + Source = LookupSource(Context->SourceMap, sources[i]); if(Context->DeferUpdates) Source->new_state = AL_PLAYING; else SetSourceState(Source, Context, AL_PLAYING); } @@ -1422,7 +1422,7 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources) for(i = 0;i < n;i++) { - Source = (ALsource*)ALTHUNK_LOOKUPENTRY(sources[i]); + Source = LookupSource(Context->SourceMap, sources[i]); if(Context->DeferUpdates) Source->new_state = AL_PAUSED; else SetSourceState(Source, Context, AL_PAUSED); } @@ -1468,7 +1468,7 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources) for(i = 0;i < n;i++) { - Source = (ALsource*)ALTHUNK_LOOKUPENTRY(sources[i]); + Source = LookupSource(Context->SourceMap, sources[i]); if(Context->DeferUpdates) Source->new_state = AL_STOPPED; else SetSourceState(Source, Context, AL_STOPPED); } @@ -1514,7 +1514,7 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources) for(i = 0;i < n;i++) { - Source = (ALsource*)ALTHUNK_LOOKUPENTRY(sources[i]); + Source = LookupSource(Context->SourceMap, sources[i]); if(Context->DeferUpdates) Source->new_state = AL_INITIAL; else SetSourceState(Source, Context, AL_INITIAL); } @@ -1616,7 +1616,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A // Change Source Type Source->lSourceType = AL_STREAMING; - buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffers[0]); + buffer = LookupBuffer(device->BufferMap, buffers[0]); // All buffers are valid - so add them to the list BufferListStart = malloc(sizeof(ALbufferlistitem)); @@ -1631,7 +1631,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A for(i = 1;i < n;i++) { - buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffers[i]); + buffer = LookupBuffer(device->BufferMap, buffers[i]); BufferList->next = malloc(sizeof(ALbufferlistitem)); BufferList->next->buffer = buffer; diff --git a/OpenAL32/alThunk.c b/OpenAL32/alThunk.c index e4e99a2c..bb843c3e 100644 --- a/OpenAL32/alThunk.c +++ b/OpenAL32/alThunk.c @@ -25,12 +25,8 @@ #include "alMain.h" #include "alThunk.h" -typedef struct { - ALvoid *ptr; - ALboolean InUse; -} ThunkEntry; -static ThunkEntry *g_ThunkArray; +static ALboolean *g_ThunkArray; static ALuint g_ThunkArraySize; static CRITICAL_SECTION g_ThunkLock; @@ -39,7 +35,7 @@ void alThunkInit(void) { InitializeCriticalSection(&g_ThunkLock); g_ThunkArraySize = 1; - g_ThunkArray = calloc(1, g_ThunkArraySize * sizeof(ThunkEntry)); + g_ThunkArray = calloc(1, g_ThunkArraySize * sizeof(*g_ThunkArray)); } void alThunkExit(void) @@ -50,7 +46,7 @@ void alThunkExit(void) DeleteCriticalSection(&g_ThunkLock); } -ALenum alThunkAddEntry(ALvoid *ptr, ALuint *idx) +ALenum alThunkNewEntry(ALuint *idx) { ALuint index; @@ -58,28 +54,27 @@ ALenum alThunkAddEntry(ALvoid *ptr, ALuint *idx) for(index = 0;index < g_ThunkArraySize;index++) { - if(g_ThunkArray[index].InUse == AL_FALSE) + if(g_ThunkArray[index] == AL_FALSE) break; } if(index == g_ThunkArraySize) { - ThunkEntry *NewList; + ALboolean *NewList; - NewList = realloc(g_ThunkArray, g_ThunkArraySize*2 * sizeof(ThunkEntry)); + NewList = realloc(g_ThunkArray, g_ThunkArraySize*2 * sizeof(*g_ThunkArray)); if(!NewList) { LeaveCriticalSection(&g_ThunkLock); ERR("Realloc failed to increase to %u enties!\n", g_ThunkArraySize*2); return AL_OUT_OF_MEMORY; } - memset(&NewList[g_ThunkArraySize], 0, g_ThunkArraySize*sizeof(ThunkEntry)); + memset(&NewList[g_ThunkArraySize], 0, g_ThunkArraySize*sizeof(*g_ThunkArray)); g_ThunkArraySize *= 2; g_ThunkArray = NewList; } - g_ThunkArray[index].ptr = ptr; - g_ThunkArray[index].InUse = AL_TRUE; + g_ThunkArray[index] = AL_TRUE; *idx = index+1; LeaveCriticalSection(&g_ThunkLock); @@ -92,21 +87,7 @@ void alThunkRemoveEntry(ALuint index) EnterCriticalSection(&g_ThunkLock); if(index > 0 && index <= g_ThunkArraySize) - g_ThunkArray[index-1].InUse = AL_FALSE; + g_ThunkArray[index-1] = AL_FALSE; LeaveCriticalSection(&g_ThunkLock); } - -ALvoid *alThunkLookupEntry(ALuint index) -{ - ALvoid *ptr = NULL; - - EnterCriticalSection(&g_ThunkLock); - - if(index > 0 && index <= g_ThunkArraySize) - ptr = g_ThunkArray[index-1].ptr; - - LeaveCriticalSection(&g_ThunkLock); - - return ptr; -} |