aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenAL32/Include/alFilter.h22
-rw-r--r--OpenAL32/alFilter.c233
2 files changed, 175 insertions, 80 deletions
diff --git a/OpenAL32/Include/alFilter.h b/OpenAL32/Include/alFilter.h
index fc91bb16..7d1f7ec0 100644
--- a/OpenAL32/Include/alFilter.h
+++ b/OpenAL32/Include/alFilter.h
@@ -70,18 +70,36 @@ static __inline ALfloat lpFilter1PC(FILTER *iir, ALuint offset, ALfloat input)
ALfloat lpCoeffCalc(ALfloat g, ALfloat cw);
-typedef struct ALfilter
-{
+typedef struct ALfilter {
// Filter type (AL_FILTER_NULL, ...)
ALenum type;
ALfloat Gain;
ALfloat GainHF;
+ void (*SetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint val);
+ void (*SetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals);
+ void (*SetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val);
+ void (*SetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals);
+
+ void (*GetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *val);
+ void (*GetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals);
+ void (*GetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val);
+ void (*GetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals);
+
// Index to itself
ALuint filter;
} ALfilter;
+#define ALfilter_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v)))
+#define ALfilter_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v)))
+#define ALfilter_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v)))
+#define ALfilter_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v)))
+
+#define ALfilter_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v)))
+#define ALfilter_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v)))
+#define ALfilter_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v)))
+#define ALfilter_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v)))
ALvoid ReleaseALFilters(ALCdevice *device);
diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c
index bdb0b47d..3aef0154 100644
--- a/OpenAL32/alFilter.c
+++ b/OpenAL32/alFilter.c
@@ -157,15 +157,15 @@ AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue)
switch(param)
{
case AL_FILTER_TYPE:
- if(iValue == AL_FILTER_NULL ||
- iValue == AL_FILTER_LOWPASS)
+ if(iValue == AL_FILTER_NULL || iValue == AL_FILTER_LOWPASS)
InitFilterParams(ALFilter, iValue);
else
alSetError(Context, AL_INVALID_VALUE);
break;
default:
- alSetError(Context, AL_INVALID_ENUM);
+ /* Call the appropriate handler */
+ ALfilter_SetParami(ALFilter, Context, param, iValue);
break;
}
}
@@ -179,6 +179,7 @@ AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValue
{
ALCcontext *Context;
ALCdevice *Device;
+ ALfilter *ALFilter;
switch(param)
{
@@ -191,14 +192,10 @@ AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValue
if(!Context) return;
Device = Context->Device;
- if(LookupFilter(Device->FilterMap, filter) != NULL)
+ if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
{
- switch(param)
- {
- default:
- alSetError(Context, AL_INVALID_ENUM);
- break;
- }
+ /* Call the appropriate handler */
+ ALfilter_SetParamiv(ALFilter, Context, param, piValues);
}
else
alSetError(Context, AL_INVALID_NAME);
@@ -218,37 +215,8 @@ AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
{
- switch(ALFilter->type)
- {
- case AL_FILTER_LOWPASS:
- switch(param)
- {
- case AL_LOWPASS_GAIN:
- if(flValue >= AL_LOWPASS_MIN_GAIN &&
- flValue <= AL_LOWPASS_MAX_GAIN)
- ALFilter->Gain = flValue;
- else
- alSetError(Context, AL_INVALID_VALUE);
- break;
-
- case AL_LOWPASS_GAINHF:
- if(flValue >= AL_LOWPASS_MIN_GAINHF &&
- flValue <= AL_LOWPASS_MAX_GAINHF)
- ALFilter->GainHF = flValue;
- else
- alSetError(Context, AL_INVALID_VALUE);
- break;
-
- default:
- alSetError(Context, AL_INVALID_ENUM);
- break;
- }
- break;
-
- default:
- alSetError(Context, AL_INVALID_ENUM);
- break;
- }
+ /* Call the appropriate handler */
+ ALfilter_SetParamf(ALFilter, Context, param, flValue);
}
else
alSetError(Context, AL_INVALID_NAME);
@@ -258,8 +226,23 @@ AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue
AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflValues)
{
- /* There are currently no multi-value filter parameters */
- alFilterf(filter, param, pflValues[0]);
+ ALCcontext *Context;
+ ALCdevice *Device;
+ ALfilter *ALFilter;
+
+ Context = GetLockedContext();
+ if(!Context) return;
+
+ Device = Context->Device;
+ if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
+ {
+ /* Call the appropriate handler */
+ ALfilter_SetParamfv(ALFilter, Context, param, pflValues);
+ }
+ else
+ alSetError(Context, AL_INVALID_NAME);
+
+ UnlockContext(Context);
}
AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue)
@@ -281,7 +264,8 @@ AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piVal
break;
default:
- alSetError(Context, AL_INVALID_ENUM);
+ /* Call the appropriate handler */
+ ALfilter_GetParami(ALFilter, Context, param, piValue);
break;
}
}
@@ -295,6 +279,7 @@ AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piVa
{
ALCcontext *Context;
ALCdevice *Device;
+ ALfilter *ALFilter;
switch(param)
{
@@ -307,14 +292,10 @@ AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piVa
if(!Context) return;
Device = Context->Device;
- if(LookupFilter(Device->FilterMap, filter) != NULL)
+ if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
{
- switch(param)
- {
- default:
- alSetError(Context, AL_INVALID_ENUM);
- break;
- }
+ /* Call the appropriate handler */
+ ALfilter_GetParamiv(ALFilter, Context, param, piValues);
}
else
alSetError(Context, AL_INVALID_NAME);
@@ -334,29 +315,8 @@ AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pfl
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
{
- switch(ALFilter->type)
- {
- case AL_FILTER_LOWPASS:
- switch(param)
- {
- case AL_LOWPASS_GAIN:
- *pflValue = ALFilter->Gain;
- break;
-
- case AL_LOWPASS_GAINHF:
- *pflValue = ALFilter->GainHF;
- break;
-
- default:
- alSetError(Context, AL_INVALID_ENUM);
- break;
- }
- break;
-
- default:
- alSetError(Context, AL_INVALID_ENUM);
- break;
- }
+ /* Call the appropriate handler */
+ ALfilter_GetParamf(ALFilter, Context, param, pflValue);
}
else
alSetError(Context, AL_INVALID_NAME);
@@ -366,8 +326,23 @@ AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pfl
AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues)
{
- /* There are currently no multi-value filter parameters */
- alGetFilterf(filter, param, pflValues);
+ ALCcontext *Context;
+ ALCdevice *Device;
+ ALfilter *ALFilter;
+
+ Context = GetLockedContext();
+ if(!Context) return;
+
+ Device = Context->Device;
+ if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
+ {
+ /* Call the appropriate handler */
+ ALfilter_GetParamfv(ALFilter, Context, param, pflValues);
+ }
+ else
+ alSetError(Context, AL_INVALID_NAME);
+
+ UnlockContext(Context);
}
@@ -387,6 +362,85 @@ ALfloat lpCoeffCalc(ALfloat g, ALfloat cw)
return a;
}
+
+static void lp_SetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint val)
+{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
+static void lp_SetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals)
+{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
+static void lp_SetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val)
+{
+ switch(param)
+ {
+ case AL_LOWPASS_GAIN:
+ if(val >= AL_LOWPASS_MIN_GAIN && val <= AL_LOWPASS_MAX_GAIN)
+ filter->Gain = val;
+ else
+ alSetError(context, AL_INVALID_VALUE);
+ break;
+
+ case AL_LOWPASS_GAINHF:
+ if(val >= AL_LOWPASS_MIN_GAINHF && val <= AL_LOWPASS_MAX_GAINHF)
+ filter->GainHF = val;
+ else
+ alSetError(context, AL_INVALID_VALUE);
+ break;
+
+ default:
+ alSetError(context, AL_INVALID_ENUM);
+ break;
+ }
+}
+static void lp_SetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals)
+{
+ lp_SetParamf(filter, context, param, vals[0]);
+}
+
+static void lp_GetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint *val)
+{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
+static void lp_GetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals)
+{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
+static void lp_GetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val)
+{
+ switch(param)
+ {
+ case AL_LOWPASS_GAIN:
+ *val = filter->Gain;
+ break;
+
+ case AL_LOWPASS_GAINHF:
+ *val = filter->GainHF;
+ break;
+
+ default:
+ alSetError(context, AL_INVALID_ENUM);
+ break;
+ }
+}
+static void lp_GetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals)
+{
+ lp_GetParamf(filter, context, param, vals);
+}
+
+
+static void null_SetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint val)
+{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
+static void null_SetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals)
+{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
+static void null_SetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val)
+{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
+static void null_SetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals)
+{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
+
+static void null_GetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint *val)
+{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
+static void null_GetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals)
+{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
+static void null_GetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val)
+{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); }
+static void null_GetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals)
+{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); }
+
+
ALvoid ReleaseALFilters(ALCdevice *device)
{
ALsizei i;
@@ -407,6 +461,29 @@ static void InitFilterParams(ALfilter *filter, ALenum type)
{
filter->type = type;
- filter->Gain = AL_LOWPASS_DEFAULT_GAIN;
- filter->GainHF = AL_LOWPASS_DEFAULT_GAINHF;
+ if(type == AL_FILTER_LOWPASS)
+ {
+ filter->Gain = AL_LOWPASS_DEFAULT_GAIN;
+ filter->GainHF = AL_LOWPASS_DEFAULT_GAINHF;
+
+ filter->SetParami = lp_SetParami;
+ filter->SetParamiv = lp_SetParamiv;
+ filter->SetParamf = lp_SetParamf;
+ filter->SetParamfv = lp_SetParamfv;
+ filter->GetParami = lp_GetParami;
+ filter->GetParamiv = lp_GetParamiv;
+ filter->GetParamf = lp_GetParamf;
+ filter->GetParamfv = lp_GetParamfv;
+ }
+ else
+ {
+ filter->SetParami = null_SetParami;
+ filter->SetParamiv = null_SetParamiv;
+ filter->SetParamf = null_SetParamf;
+ filter->SetParamfv = null_SetParamfv;
+ filter->GetParami = null_GetParami;
+ filter->GetParamiv = null_GetParamiv;
+ filter->GetParamf = null_GetParamf;
+ filter->GetParamfv = null_GetParamfv;
+ }
}