diff options
author | Chris Robinson <[email protected]> | 2009-08-15 09:39:18 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-08-15 09:39:18 -0700 |
commit | 510ccc7f1786bffd183f5a30c7e2e3f8e8026371 (patch) | |
tree | 8e4c33cc52d872ae50eb32debfcf6119c5791f1d /OpenAL32 | |
parent | 43067ed2b8d4ab9c3f46b8ee002d6c3f6480cc4f (diff) |
Store the effect and filter lists in the device
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alEffect.h | 6 | ||||
-rw-r--r-- | OpenAL32/Include/alFilter.h | 6 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 8 | ||||
-rw-r--r-- | OpenAL32/alEffect.c | 42 | ||||
-rw-r--r-- | OpenAL32/alFilter.c | 41 |
5 files changed, 54 insertions, 49 deletions
diff --git a/OpenAL32/Include/alEffect.h b/OpenAL32/Include/alEffect.h index 592eb541..59b81165 100644 --- a/OpenAL32/Include/alEffect.h +++ b/OpenAL32/Include/alEffect.h @@ -201,7 +201,7 @@ enum { }; extern ALboolean DisabledEffects[MAX_EFFECTS]; -typedef struct ALeffect_struct +typedef struct ALeffect { // Effect type (AL_EFFECT_NULL, ...) ALenum type; @@ -248,7 +248,7 @@ typedef struct ALeffect_struct // Index to itself ALuint effect; - struct ALeffect_struct *next; + struct ALeffect *next; } ALeffect; ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects); @@ -265,7 +265,7 @@ ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues); ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue); ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues); -ALvoid ReleaseALEffects(ALvoid); +ALvoid ReleaseALEffects(ALCdevice *device); #ifdef __cplusplus } diff --git a/OpenAL32/Include/alFilter.h b/OpenAL32/Include/alFilter.h index 0f00f029..86ada5ef 100644 --- a/OpenAL32/Include/alFilter.h +++ b/OpenAL32/Include/alFilter.h @@ -61,7 +61,7 @@ static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input) #define AL_LOWPASS_GAINHF 0x0002 -typedef struct ALfilter_struct +typedef struct ALfilter { // Filter type (AL_FILTER_NULL, ...) ALenum type; @@ -72,7 +72,7 @@ typedef struct ALfilter_struct // Index to itself ALuint filter; - struct ALfilter_struct *next; + struct ALfilter *next; } ALfilter; ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters); @@ -89,7 +89,7 @@ ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues); ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue); ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues); -ALvoid ReleaseALFilters(ALvoid); +ALvoid ReleaseALFilters(ALCdevice *device); #ifdef __cplusplus } diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index ccfb94ac..78128c90 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -193,6 +193,14 @@ struct ALCdevice_struct struct ALbuffer *Buffers; ALuint BufferCount; + // Linked List of Effects for this device + struct ALeffect *EffectList; + ALuint EffectCount; + + // Linked List of Filters for this device + struct ALfilter *FilterList; + ALuint FilterCount; + // Context created on this device ALCcontext *Context; diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c index f41c769e..7bf5b5ab 100644 --- a/OpenAL32/alEffect.c +++ b/OpenAL32/alEffect.c @@ -34,9 +34,6 @@ ALboolean DisabledEffects[MAX_EFFECTS]; -static ALeffect *g_EffectList; -static ALuint g_EffectCount; - static void InitEffectParams(ALeffect *effect, ALenum type); @@ -50,10 +47,12 @@ ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) if (n > 0) { + ALCdevice *device = Context->Device; + // Check that enough memory has been allocted in the 'effects' array for n Effects if (!IsBadWritePtr((void*)effects, n * sizeof(ALuint))) { - ALeffect **list = &g_EffectList; + ALeffect **list = &device->EffectList; while(*list) list = &(*list)->next; @@ -73,7 +72,7 @@ ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) (*list)->effect = effects[i]; InitEffectParams(*list, AL_EFFECT_NULL); - g_EffectCount++; + device->EffectCount++; i++; list = &(*list)->next; @@ -95,6 +94,8 @@ ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects) if (n >= 0) { + ALCdevice *device = Context->Device; + // Check that all effects are valid for (i = 0; i < n; i++) { @@ -118,7 +119,7 @@ ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects) ALEffect = ((ALeffect*)ALTHUNK_LOOKUPENTRY(effects[i])); // Remove Source from list of Sources - list = &g_EffectList; + list = &device->EffectList; while(*list && *list != ALEffect) list = &(*list)->next; @@ -129,7 +130,7 @@ ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects) memset(ALEffect, 0, sizeof(ALeffect)); free(ALEffect); - g_EffectCount--; + device->EffectCount--; } } } @@ -143,18 +144,18 @@ ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects) ALboolean AL_APIENTRY alIsEffect(ALuint effect) { ALCcontext *Context; - ALeffect **list; + ALeffect *list; Context = alcGetCurrentContext(); SuspendContext(Context); - list = &g_EffectList; - while(*list && (*list)->effect != effect) - list = &(*list)->next; + list = Context->Device->EffectList; + while(list && list->effect != effect) + list = list->next; ProcessContext(Context); - return ((*list || !effect) ? AL_TRUE : AL_FALSE); + return ((list || !effect) ? AL_TRUE : AL_FALSE); } ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue) @@ -1160,23 +1161,20 @@ ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues } -ALvoid ReleaseALEffects(ALvoid) +ALvoid ReleaseALEffects(ALCdevice *device) { -#ifdef _DEBUG - if(g_EffectCount > 0) - AL_PRINT("exit(): deleting %d Effect(s)\n", g_EffectCount); -#endif - - while(g_EffectList) + ALeffect *list = device->EffectList; + while(list) { - ALeffect *temp = g_EffectList; - g_EffectList = g_EffectList->next; + ALeffect *temp = list; + list = list->next; // Release effect structure memset(temp, 0, sizeof(ALeffect)); free(temp); } - g_EffectCount = 0; + device->EffectList = NULL; + device->EffectCount = 0; } diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c index b25a8093..9d32e7cf 100644 --- a/OpenAL32/alFilter.c +++ b/OpenAL32/alFilter.c @@ -29,8 +29,6 @@ #include "alThunk.h" #include "alError.h" -static ALfilter *g_FilterList; -static ALuint g_FilterCount; static void InitFilterParams(ALfilter *filter, ALenum type); @@ -45,10 +43,12 @@ ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) if (n > 0) { + ALCdevice *device = Context->Device; + // Check that enough memory has been allocted in the 'filters' array for n Filters if (!IsBadWritePtr((void*)filters, n * sizeof(ALuint))) { - ALfilter **list = &g_FilterList; + ALfilter **list = &device->FilterList; while(*list) list = &(*list)->next; @@ -68,7 +68,7 @@ ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) (*list)->filter = filters[i]; InitFilterParams(*list, AL_FILTER_NULL); - g_FilterCount++; + device->FilterCount++; i++; list = &(*list)->next; @@ -90,6 +90,8 @@ ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters) if (n >= 0) { + ALCdevice *device = Context->Device; + // Check that all filters are valid for (i = 0; i < n; i++) { @@ -113,7 +115,7 @@ ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters) ALFilter = ((ALfilter*)ALTHUNK_LOOKUPENTRY(filters[i])); // Remove Source from list of Sources - list = &g_FilterList; + list = &device->FilterList; while(*list && *list != ALFilter) list = &(*list)->next; @@ -124,7 +126,7 @@ ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters) memset(ALFilter, 0, sizeof(ALfilter)); free(ALFilter); - g_FilterCount--; + device->FilterCount--; } } } @@ -138,18 +140,18 @@ ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters) ALboolean AL_APIENTRY alIsFilter(ALuint filter) { ALCcontext *Context; - ALfilter **list; + ALfilter *list; Context = alcGetCurrentContext(); SuspendContext(Context); - list = &g_FilterList; - while(*list && (*list)->filter != filter) - list = &(*list)->next; + list = Context->Device->FilterList; + while(list && list->filter != filter) + list = list->next; ProcessContext(Context); - return ((*list || !filter) ? AL_TRUE : AL_FALSE); + return ((list || !filter) ? AL_TRUE : AL_FALSE); } ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue) @@ -397,23 +399,20 @@ ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues } -ALvoid ReleaseALFilters(ALvoid) +ALvoid ReleaseALFilters(ALCdevice *device) { -#ifdef _DEBUG - if(g_FilterCount > 0) - AL_PRINT("exit(): deleting %d Filter(s)\n", g_FilterCount); -#endif - - while(g_FilterList) + ALfilter *list = device->FilterList; + while(list) { - ALfilter *temp = g_FilterList; - g_FilterList = g_FilterList->next; + ALfilter *temp = list; + list = list->next; // Release filter structure memset(temp, 0, sizeof(ALfilter)); free(temp); } - g_FilterCount = 0; + device->FilterList = NULL; + device->FilterCount = 0; } |