Merge branch 'master' of git://repo.or.cz/openal-soft

This commit is contained in:
Aaron Lindsay 2011-10-03 21:22:55 -04:00
commit 5e77ab78a2
28 changed files with 914 additions and 477 deletions

View File

@ -376,8 +376,8 @@ static volatile ALCenum g_eLastNullDeviceError = ALC_NO_ERROR;
// Default context extensions
static const ALchar alExtList[] =
"AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 "
"AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW "
"AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 "
"AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW "
"AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model "
"AL_LOKI_quadriphonic AL_SOFTX_buffer_samples AL_SOFT_buffer_sub_data "
"AL_SOFTX_deferred_updates AL_SOFT_loop_points "
@ -396,12 +396,6 @@ enum LogLevel LogLevel = LogWarning;
enum LogLevel LogLevel = LogError;
#endif
// Cone scalar
ALdouble ConeScale = 0.5;
// Localized Z scalar for mono sources
ALdouble ZScale = 1.0;
/* Flag to trap ALC device errors */
static ALCboolean TrapALCError = ALC_FALSE;
@ -499,11 +493,11 @@ static void alc_init(void)
str = getenv("__ALSOFT_HALF_ANGLE_CONES");
if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1))
ConeScale = 1.0;
ConeScale = 1.0f;
str = getenv("__ALSOFT_REVERSE_Z");
if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1))
ZScale = -1.0;
ZScale = -1.0f;
str = getenv("__ALSOFT_TRAP_ERROR");
if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1))
@ -1010,7 +1004,7 @@ static void alcSetError(ALCdevice *device, ALCenum errorCode)
if(IsDebuggerPresent())
DebugBreak();
#elif defined(SIGTRAP)
kill(getpid(), SIGTRAP);
raise(SIGTRAP);
#endif
}
@ -1029,6 +1023,7 @@ static void alcSetError(ALCdevice *device, ALCenum errorCode)
static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
{
ALCcontext *context;
int oldMode;
ALuint i;
// Check for attributes
@ -1205,6 +1200,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
}
TRACE("Stereo duplication %s\n", (device->Flags&DEVICE_DUPLICATE_STEREO)?"enabled":"disabled");
oldMode = SetMixerFPUMode();
context = device->ContextList;
while(context)
{
@ -1250,6 +1246,7 @@ static ALCboolean UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
context = context->next;
}
RestoreFPUMode(oldMode);
UnlockDevice(device);
return ALC_TRUE;

View File

@ -37,6 +37,13 @@
#include "bs2b.h"
/* Cone scalar */
ALfloat ConeScale = 0.5f;
/* Localized Z scalar for mono sources */
ALfloat ZScale = 1.0f;
static __inline ALvoid aluCrossproduct(const ALfloat *inVector1, const ALfloat *inVector2, ALfloat *outVector)
{
outVector[0] = inVector1[1]*inVector2[2] - inVector1[2]*inVector2[1];
@ -161,7 +168,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALSource->Params.Step = maxstep<<FRACTIONBITS;
else
{
ALSource->Params.Step = Pitch*FRACTIONONE;
ALSource->Params.Step = fastf2i(Pitch*FRACTIONONE);
if(ALSource->Params.Step == 0)
ALSource->Params.Step = 1;
}
@ -211,8 +218,8 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
DryGain *= aluSqrt(2.0f/4.0f);
for(c = 0;c < 2;c++)
{
pos = aluCart2LUTpos(cos(angles_Rear[c] * (M_PI/180.0)),
sin(angles_Rear[c] * (M_PI/180.0)));
pos = aluCart2LUTpos(aluCos(F_PI/180.0f * angles_Rear[c]),
aluSin(F_PI/180.0f * angles_Rear[c]));
SpeakerGain = Device->PanningLUT[pos];
for(i = 0;i < (ALint)Device->NumChan;i++)
@ -284,7 +291,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
/* Get the static HRIR coefficients and delays for this
* channel. */
GetLerpedHrtfCoeffs(ALContext->Device->Hrtf,
0.0, angles[c] * (M_PI/180.0),
0.0f, F_PI/180.0f * angles[c],
DryGain*ListenerGain,
ALSource->Params.HrtfCoeffs[c],
ALSource->Params.HrtfDelay[c]);
@ -301,8 +308,8 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
SrcMatrix[c][LFE] += DryGain * ListenerGain;
continue;
}
pos = aluCart2LUTpos(cos(angles[c] * (M_PI/180.0)),
sin(angles[c] * (M_PI/180.0)));
pos = aluCart2LUTpos(aluCos(F_PI/180.0f * angles[c]),
aluSin(F_PI/180.0f * angles[c]));
SpeakerGain = Device->PanningLUT[pos];
for(i = 0;i < (ALint)Device->NumChan;i++)
@ -321,7 +328,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
/* Update filter coefficients. Calculations based on the I3DL2
* spec. */
cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / Frequency);
cw = aluCos(F_PI*2.0f * LOWPASSFREQREF / Frequency);
/* We use two chained one-pole filters, so we need to take the
* square root of the squared gain, which is the same as the base
@ -572,13 +579,30 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
AirAbsorptionFactor*EffectiveDist);
}
//3. Apply directional soundcones
Angle = aluAcos(aluDotproduct(Direction,SourceToListener)) * (180.0/M_PI);
if(WetGainAuto)
{
/* Apply a decay-time transformation to the wet path, based on the
* attenuation of the dry path.
*
* Using the approximate (effective) source to listener distance, the
* initial decay of the reverb effect is calculated and applied to the
* wet path.
*/
for(i = 0;i < NumSends;i++)
{
if(DecayDistance[i] > 0.0f)
WetGain[i] *= aluPow(0.001f /* -60dB */,
EffectiveDist / DecayDistance[i]);
}
}
/* Calculate directional soundcones */
Angle = aluAcos(aluDotproduct(Direction,SourceToListener)) * (180.0f/F_PI);
if(Angle >= InnerAngle && Angle <= OuterAngle)
{
ALfloat scale = (Angle-InnerAngle) / (OuterAngle-InnerAngle);
ConeVolume = lerp(1.0, ALSource->flOuterGain, scale);
ConeHF = lerp(1.0, ALSource->OuterGainHF, scale);
ConeVolume = lerp(1.0f, ALSource->flOuterGain, scale);
ConeHF = lerp(1.0f, ALSource->OuterGainHF, scale);
}
else if(Angle > OuterAngle)
{
@ -619,23 +643,6 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
WetGainHF[i] *= ALSource->Send[i].WetGainHF;
}
if(WetGainAuto)
{
/* Apply a decay-time transformation to the wet path, based on the
* attenuation of the dry path.
*
* Using the approximate (effective) source to listener distance, the
* initial decay of the reverb effect is calculated and applied to the
* wet path.
*/
for(i = 0;i < NumSends;i++)
{
if(DecayDistance[i] > 0.0f)
WetGain[i] *= aluPow(0.001f /* -60dB */,
EffectiveDist / DecayDistance[i]);
}
}
// Calculate Velocity
if(DopplerFactor != 0.0f)
{
@ -676,7 +683,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALSource->Params.Step = maxstep<<FRACTIONBITS;
else
{
ALSource->Params.Step = Pitch*FRACTIONONE;
ALSource->Params.Step = fastf2i(Pitch*FRACTIONONE);
if(ALSource->Params.Step == 0)
ALSource->Params.Step = 1;
}
@ -709,8 +716,8 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
// Calculate elevation and azimuth only when the source is not at
// the listener. This prevents +0 and -0 Z from producing
// inconsistent panning.
ev = asin(Position[1]);
az = atan2(Position[0], -Position[2]*ZScale);
ev = aluAsin(Position[1]);
az = aluAtan2(Position[0], -Position[2]*ZScale);
}
// Check to see if the HRIR is already moving.
@ -772,7 +779,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
DirGain = aluSqrt(Position[0]*Position[0] + Position[2]*Position[2]);
// elevation adjustment for directional gain. this sucks, but
// has low complexity
AmbientGain = aluSqrt(1.0/Device->NumChan);
AmbientGain = aluSqrt(1.0f/Device->NumChan);
for(i = 0;i < MAXCHANNELS;i++)
{
ALuint i2;
@ -790,7 +797,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALSource->Params.Send[i].WetGain = WetGain[i];
/* Update filter coefficients. */
cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / Frequency);
cw = aluCos(F_PI*2.0f * LOWPASSFREQREF / Frequency);
ALSource->Params.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw);
for(i = 0;i < NumSends;i++)
@ -807,7 +814,7 @@ static __inline ALshort aluF2S(ALfloat val)
{
if(val > 1.0f) return 32767;
if(val < -1.0f) return -32768;
return (ALint)(val*32767.0f);
return fastf2i(val*32767.0f);
}
static __inline ALushort aluF2US(ALfloat val)
{ return aluF2S(val)+32768; }
@ -945,15 +952,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
int fpuState;
ALuint i, c;
#if defined(HAVE_FESETROUND)
fpuState = fegetround();
fesetround(FE_TOWARDZERO);
#elif defined(HAVE__CONTROLFP)
fpuState = _controlfp(0, 0);
(void)_controlfp(_RC_CHOP, _MCW_RC);
#else
(void)fpuState;
#endif
fpuState = SetMixerFPUMode();
while(size > 0)
{
@ -1000,7 +999,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
for(c = 0;c < SamplesToDo;c++)
{
(*slot)->WetBuffer[c] += (*slot)->ClickRemoval[0];
(*slot)->ClickRemoval[0] -= (*slot)->ClickRemoval[0] / 256.0f;
(*slot)->ClickRemoval[0] -= (*slot)->ClickRemoval[0] * (1.0f/256.0f);
}
(*slot)->ClickRemoval[0] += (*slot)->PendingClicks[0];
(*slot)->PendingClicks[0] = 0.0f;
@ -1027,7 +1026,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
for(i = 0;i < SamplesToDo;i++)
{
device->DryBuffer[i][FRONT_CENTER] += device->ClickRemoval[FRONT_CENTER];
device->ClickRemoval[FRONT_CENTER] -= device->ClickRemoval[FRONT_CENTER] / 256.0f;
device->ClickRemoval[FRONT_CENTER] -= device->ClickRemoval[FRONT_CENTER] * (1.0f/256.0f);
}
device->ClickRemoval[FRONT_CENTER] += device->PendingClicks[FRONT_CENTER];
device->PendingClicks[FRONT_CENTER] = 0.0f;
@ -1040,7 +1039,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
for(c = 0;c < 2;c++)
{
device->DryBuffer[i][c] += device->ClickRemoval[c];
device->ClickRemoval[c] -= device->ClickRemoval[c] / 256.0f;
device->ClickRemoval[c] -= device->ClickRemoval[c] * (1.0f/256.0f);
}
}
for(c = 0;c < 2;c++)
@ -1056,7 +1055,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
for(c = 0;c < MAXCHANNELS;c++)
{
device->DryBuffer[i][c] += device->ClickRemoval[c];
device->ClickRemoval[c] -= device->ClickRemoval[c] / 256.0f;
device->ClickRemoval[c] -= device->ClickRemoval[c] * (1.0f/256.0f);
}
}
for(c = 0;c < MAXCHANNELS;c++)
@ -1091,11 +1090,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
size -= SamplesToDo;
}
#if defined(HAVE_FESETROUND)
fesetround(fpuState);
#elif defined(HAVE__CONTROLFP)
_controlfp(fpuState, _MCW_RC);
#endif
RestoreFPUMode(fpuState);
}

View File

@ -73,8 +73,8 @@ static ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
// Use the next power of 2 for the buffer length, so the tap offsets can be
// wrapped using a mask instead of a modulo
maxlen = (ALuint)(AL_ECHO_MAX_DELAY * Device->Frequency) + 1;
maxlen += (ALuint)(AL_ECHO_MAX_LRDELAY * Device->Frequency) + 1;
maxlen = fastf2u(AL_ECHO_MAX_DELAY * Device->Frequency) + 1;
maxlen += fastf2u(AL_ECHO_MAX_LRDELAY * Device->Frequency) + 1;
maxlen = NextPowerOf2(maxlen);
if(maxlen != state->BufferLength)
@ -101,8 +101,8 @@ static ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeff
ALfloat lrpan, cw, g, gain;
ALuint i;
state->Tap[0].delay = (ALuint)(Slot->effect.Echo.Delay * frequency) + 1;
state->Tap[1].delay = (ALuint)(Slot->effect.Echo.LRDelay * frequency);
state->Tap[0].delay = fastf2u(Slot->effect.Echo.Delay * frequency) + 1;
state->Tap[1].delay = fastf2u(Slot->effect.Echo.LRDelay * frequency);
state->Tap[1].delay += state->Tap[0].delay;
lrpan = Slot->effect.Echo.Spread*0.5f + 0.5f;
@ -111,7 +111,7 @@ static ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeff
state->FeedGain = Slot->effect.Echo.Feedback;
cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / frequency);
cw = aluCos(F_PI*2.0f * LOWPASSFREQREF / frequency);
g = 1.0f - Slot->effect.Echo.Damping;
state->iirFilter.coeff = lpCoeffCalc(g, cw);

View File

@ -50,21 +50,22 @@ typedef struct ALmodulatorState {
} ALmodulatorState;
#define WAVEFORM_FRACBITS 16
#define WAVEFORM_FRACMASK ((1<<WAVEFORM_FRACBITS)-1)
#define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
static __inline ALdouble Sin(ALuint index)
static __inline ALfloat Sin(ALuint index)
{
return sin(index * (M_PI*2.0 / (1<<WAVEFORM_FRACBITS)));
return aluSin(index * (F_PI*2.0f / WAVEFORM_FRACONE));
}
static __inline ALdouble Saw(ALuint index)
static __inline ALfloat Saw(ALuint index)
{
return index*(2.0/(1<<WAVEFORM_FRACBITS)) - 1.0;
return index*(2.0f/WAVEFORM_FRACONE) - 1.0f;
}
static __inline ALdouble Square(ALuint index)
static __inline ALfloat Square(ALuint index)
{
return (index&(1<<(WAVEFORM_FRACBITS-1))) ? -1.0 : 1.0;
return ((index>>(WAVEFORM_FRACBITS-1))&1)*2.0f - 1.0f;
}
@ -146,13 +147,12 @@ static ALvoid ModulatorUpdate(ALeffectState *effect, ALCcontext *Context, const
else if(Slot->effect.Modulator.Waveform == AL_RING_MODULATOR_SQUARE)
state->Waveform = SQUARE;
state->step = Slot->effect.Modulator.Frequency*(1<<WAVEFORM_FRACBITS) /
Device->Frequency;
if(!state->step)
state->step = 1;
state->step = fastf2u(Slot->effect.Modulator.Frequency*WAVEFORM_FRACONE /
Device->Frequency);
if(state->step == 0) state->step = 1;
cw = cos(2.0*M_PI * Slot->effect.Modulator.HighPassCutoff /
Device->Frequency);
cw = aluCos(F_PI*2.0f * Slot->effect.Modulator.HighPassCutoff /
Device->Frequency);
a = (2.0f-cw) - aluSqrt(aluPow(2.0f-cw, 2.0f) - 1.0f);
state->iirFilter.coeff = a;
@ -199,8 +199,8 @@ ALeffectState *ModulatorCreate(void)
state->state.Update = ModulatorUpdate;
state->state.Process = ModulatorProcess;
state->index = 0.0f;
state->step = 1.0f;
state->index = 0;
state->step = 1;
state->iirFilter.coeff = 0.0f;
state->iirFilter.history[0] = 0.0f;

View File

@ -48,85 +48,109 @@ typedef struct ALverbState {
// fragmentation and management code.
ALfloat *SampleBuffer;
ALuint TotalSamples;
// Master effect low-pass filter (2 chained 1-pole filters).
FILTER LpFilter;
ALfloat LpHistory[2];
struct {
// Modulator delay line.
DelayLine Delay;
// The vibrato time is tracked with an index over a modulus-wrapped
// range (in samples).
ALuint Index;
ALuint Range;
// The depth of frequency change (also in samples) and its filter.
ALfloat Depth;
ALfloat Coeff;
ALfloat Filter;
} Mod;
// Initial effect delay.
DelayLine Delay;
// The tap points for the initial delay. First tap goes to early
// reflections, the last to late reverb.
ALuint DelayTap[2];
struct {
// Output gain for early reflections.
ALfloat Gain;
// Early reflections are done with 4 delay lines.
ALfloat Coeff[4];
DelayLine Delay[4];
ALuint Offset[4];
// The gain for each output channel based on 3D panning (only for the
// EAX path).
ALfloat PanGain[MAXCHANNELS];
} Early;
// Decorrelator delay line.
DelayLine Decorrelator;
// There are actually 4 decorrelator taps, but the first occurs at the
// initial sample.
ALuint DecoTap[3];
struct {
// Output gain for late reverb.
ALfloat Gain;
// Attenuation to compensate for the modal density and decay rate of
// the late lines.
ALfloat DensityGain;
// The feed-back and feed-forward all-pass coefficient.
ALfloat ApFeedCoeff;
// Mixing matrix coefficient.
ALfloat MixCoeff;
// Late reverb has 4 parallel all-pass filters.
ALfloat ApCoeff[4];
DelayLine ApDelay[4];
ALuint ApOffset[4];
// In addition to 4 cyclical delay lines.
ALfloat Coeff[4];
DelayLine Delay[4];
ALuint Offset[4];
// The cyclical delay lines are 1-pole low-pass filtered.
ALfloat LpCoeff[4];
ALfloat LpSample[4];
// The gain for each output channel based on 3D panning (only for the
// EAX path).
ALfloat PanGain[MAXCHANNELS];
} Late;
struct {
// Attenuation to compensate for the modal density and decay rate of
// the echo line.
ALfloat DensityGain;
// Echo delay and all-pass lines.
DelayLine Delay;
DelayLine ApDelay;
ALfloat Coeff;
ALfloat ApFeedCoeff;
ALfloat ApCoeff;
ALuint Offset;
ALuint ApOffset;
// The echo line is 1-pole low-pass filtered.
ALfloat LpCoeff;
ALfloat LpSample;
// Echo mixing coefficients.
ALfloat MixCoeff[2];
} Echo;
// The current read offset for all delay lines.
ALuint Offset;
@ -237,7 +261,7 @@ static __inline ALfloat EAXModulation(ALverbState *State, ALfloat in)
// Calculate the sinus rythm (dependent on modulation time and the
// sampling rate). The center of the sinus is moved to reduce the delay
// of the effect when the time or depth are low.
sinus = 1.0f - cos(2.0f * M_PI * State->Mod.Index / State->Mod.Range);
sinus = 1.0f - aluCos(F_PI*2.0f * State->Mod.Index / State->Mod.Range);
// The depth determines the range over which to read the input samples
// from, so it must be filtered to reduce the distortion caused by even
@ -247,7 +271,7 @@ static __inline ALfloat EAXModulation(ALverbState *State, ALfloat in)
// Calculate the read offset and fraction between it and the next sample.
frac = (1.0f + (State->Mod.Filter * sinus));
offset = (ALuint)frac;
offset = fastf2u(frac);
frac -= offset;
// Get the two samples crossed by the offset, and feed the delay line
@ -610,7 +634,7 @@ static ALuint CalcLineLength(ALfloat length, ALintptrEXT offset, ALuint frequenc
// All line lengths are powers of 2, calculated from their lengths, with
// an additional sample in case of rounding errors.
samples = NextPowerOf2((ALuint)(length * frequency) + 1);
samples = NextPowerOf2(fastf2u(length * frequency) + 1);
// All lines share a single sample buffer.
Delay->Mask = samples - 1;
Delay->Line = (ALfloat*)offset;
@ -733,15 +757,15 @@ static ALboolean ReverbDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
// so their offsets only need to be calculated once.
for(index = 0;index < 4;index++)
{
State->Early.Offset[index] = (ALuint)(EARLY_LINE_LENGTH[index] *
State->Early.Offset[index] = fastf2u(EARLY_LINE_LENGTH[index] *
frequency);
State->Late.ApOffset[index] = fastf2u(ALLPASS_LINE_LENGTH[index] *
frequency);
State->Late.ApOffset[index] = (ALuint)(ALLPASS_LINE_LENGTH[index] *
frequency);
}
// The echo all-pass filter line length is static, so its offset only
// needs to be calculated once.
State->Echo.ApOffset = (ALuint)(ECHO_ALLPASS_LENGTH * frequency);
State->Echo.ApOffset = fastf2u(ECHO_ALLPASS_LENGTH * frequency);
return AL_TRUE;
}
@ -757,14 +781,14 @@ static __inline ALfloat CalcDecayCoeff(ALfloat length, ALfloat decayTime)
// reaches -60 dB.
static __inline ALfloat CalcDecayLength(ALfloat coeff, ALfloat decayTime)
{
return log10(coeff) * decayTime / -3.0f/*log10(0.001)*/;
return aluLog10(coeff) * decayTime / aluLog10(0.001f)/*-60 dB*/;
}
// Calculate the high frequency parameter for the I3DL2 coefficient
// calculation.
static __inline ALfloat CalcI3DL2HFreq(ALfloat hfRef, ALuint frequency)
{
return cos(2.0f * M_PI * hfRef / frequency);
return aluCos(F_PI*2.0f * hfRef / frequency);
}
// Calculate an attenuation to be applied to the input of any echo models to
@ -794,12 +818,12 @@ static __inline ALvoid CalcMatrixCoeffs(ALfloat diffusion, ALfloat *x, ALfloat *
// The matrix is of order 4, so n is sqrt (4 - 1).
n = aluSqrt(3.0f);
t = diffusion * atan(n);
t = diffusion * aluAtan(n);
// Calculate the first mixing matrix coefficient.
*x = cos(t);
*x = aluCos(t);
// Calculate the second mixing matrix coefficient.
*y = sin(t) / n;
*y = aluSin(t) / n;
}
// Calculate the limited HF ratio for use with the late reverb low-pass
@ -852,7 +876,7 @@ static __inline ALfloat CalcDampingCoeff(ALfloat hfRatio, ALfloat length, ALfloa
// downswing will sound stronger than the upswing.
static ALvoid UpdateModulator(ALfloat modTime, ALfloat modDepth, ALuint frequency, ALverbState *State)
{
ALfloat length;
ALuint range;
/* Modulation is calculated in two parts.
*
@ -862,15 +886,10 @@ static ALvoid UpdateModulator(ALfloat modTime, ALfloat modDepth, ALuint frequenc
* minimum (1 sample) and when the timing changes, the index is rescaled
* to the new range (to keep the sinus consistent).
*/
length = modTime * frequency;
if (length >= 1.0f) {
State->Mod.Index = (ALuint)(State->Mod.Index * length /
State->Mod.Range);
State->Mod.Range = (ALuint)length;
} else {
State->Mod.Index = 0;
State->Mod.Range = 1;
}
range = maxu(fastf2u(modTime*frequency), 1);
State->Mod.Index = (ALuint)(State->Mod.Index * (ALuint64)range /
State->Mod.Range);
State->Mod.Range = range;
/* The modulation depth effects the amount of frequency change over the
* range of the sinus. It needs to be scaled by the modulation time so
@ -888,8 +907,8 @@ static ALvoid UpdateModulator(ALfloat modTime, ALfloat modDepth, ALuint frequenc
static ALvoid UpdateDelayLine(ALfloat earlyDelay, ALfloat lateDelay, ALuint frequency, ALverbState *State)
{
// Calculate the initial delay taps.
State->DelayTap[0] = (ALuint)(earlyDelay * frequency);
State->DelayTap[1] = (ALuint)((earlyDelay + lateDelay) * frequency);
State->DelayTap[0] = fastf2u(earlyDelay * frequency);
State->DelayTap[1] = fastf2u((earlyDelay + lateDelay) * frequency);
}
// Update the early reflections gain and line coefficients.
@ -926,7 +945,7 @@ static ALvoid UpdateDecorrelator(ALfloat density, ALuint frequency, ALverbState
{
length = (DECO_FRACTION * aluPow(DECO_MULTIPLIER, (ALfloat)index)) *
LATE_LINE_LENGTH[0] * (1.0f + (density * LATE_LINE_MULTIPLIER));
State->DecoTap[index] = (ALuint)(length * frequency);
State->DecoTap[index] = fastf2u(length * frequency);
}
}
@ -971,7 +990,7 @@ static ALvoid UpdateLateLines(ALfloat reverbGain, ALfloat lateGain, ALfloat xMix
LATE_LINE_MULTIPLIER));
// Calculate the delay offset for each cyclical delay line.
State->Late.Offset[index] = (ALuint)(length * frequency);
State->Late.Offset[index] = fastf2u(length * frequency);
// Calculate the gain (coefficient) for each cyclical line.
State->Late.Coeff[index] = CalcDecayCoeff(length, decayTime);
@ -992,7 +1011,7 @@ static ALvoid UpdateLateLines(ALfloat reverbGain, ALfloat lateGain, ALfloat xMix
static ALvoid UpdateEchoLine(ALfloat reverbGain, ALfloat lateGain, ALfloat echoTime, ALfloat decayTime, ALfloat diffusion, ALfloat echoDepth, ALfloat hfRatio, ALfloat cw, ALuint frequency, ALverbState *State)
{
// Update the offset and coefficient for the echo delay line.
State->Echo.Offset = (ALuint)(echoTime * frequency);
State->Echo.Offset = fastf2u(echoTime * frequency);
// Calculate the decay coefficient for the echo line.
State->Echo.Coeff = CalcDecayCoeff(echoTime, decayTime);
@ -1112,7 +1131,7 @@ static ALvoid ReverbUpdate(ALeffectState *effect, ALCcontext *Context, const ALe
// Calculate the master low-pass filter (from the master effect HF gain).
if(isEAX) cw = CalcI3DL2HFreq(Slot->effect.Reverb.HFReference, frequency);
else cw = CalcI3DL2HFreq(LOWPASSFREQCUTOFF, frequency);
else cw = CalcI3DL2HFreq(LOWPASSFREQREF, frequency);
// This is done with 2 chained 1-pole filters, so no need to square g.
State->LpFilter.coeff = lpCoeffCalc(Slot->effect.Reverb.GainHF, cw);

View File

@ -482,7 +482,7 @@ static HRESULT DoReset(ALCdevice *device)
}
static DWORD CALLBACK MessageProc(void *ptr)
static DWORD CALLBACK MMDevApiMsgProc(void *ptr)
{
ThreadRequest *req = ptr;
IMMDeviceEnumerator *Enumerator;
@ -621,7 +621,7 @@ static BOOL MMDevApiLoad(void)
ERR("Failed to create event: %lu\n", GetLastError());
else
{
ThreadHdl = CreateThread(NULL, 0, MessageProc, &req, 0, &ThreadID);
ThreadHdl = CreateThread(NULL, 0, MMDevApiMsgProc, &req, 0, &ThreadID);
if(ThreadHdl != NULL)
InitResult = WaitForResponse(&req);
CloseHandle(req.FinishedEvt);

View File

@ -112,7 +112,7 @@ static void init(struct bs2b *bs2b)
bs2b->a0_hi = 1.0 - G_hi * (1.0 - x);
bs2b->a1_hi = -x;
bs2b->gain = 1.0 / (1.0 - G_hi + G_lo);
bs2b->gain = 1.0f / (float)(1.0 - G_hi + G_lo);
} /* init */
/* Exported functions.
@ -180,8 +180,8 @@ void bs2b_cross_feed(struct bs2b *bs2b, float *sample)
bs2b->last_sample.asis[1] = sample[1];
/* Crossfeed */
sample[0] = bs2b->last_sample.hi[0] + bs2b->last_sample.lo[1];
sample[1] = bs2b->last_sample.hi[1] + bs2b->last_sample.lo[0];
sample[0] = (float)(bs2b->last_sample.hi[0] + bs2b->last_sample.lo[1]);
sample[1] = (float)(bs2b->last_sample.hi[1] + bs2b->last_sample.lo[0]);
/* Bass boost cause allpass attenuation */
sample[0] *= bs2b->gain;

View File

@ -207,7 +207,7 @@ void *GetSymbol(void *handle, const char *name)
sym = dlsym(handle, name);
if((err=dlerror()) != NULL)
{
ERR("Failed to load %s: %s\n", name, err);
WARN("Failed to load %s: %s\n", name, err);
sym = NULL;
}
return sym;

View File

@ -71,8 +71,8 @@ static ALuint NumLoadedHrtfs = 0;
// interpolation factor between 0.0 and 1.0.
static void CalcEvIndices(ALfloat ev, ALuint *evidx, ALfloat *evmu)
{
ev = (M_PI/2.0f + ev) * (ELEV_COUNT-1) / M_PI;
evidx[0] = (ALuint)ev;
ev = (F_PI_2 + ev) * (ELEV_COUNT-1) / F_PI;
evidx[0] = fastf2u(ev);
evidx[1] = minu(evidx[0] + 1, ELEV_COUNT-1);
*evmu = ev - evidx[0];
}
@ -82,10 +82,10 @@ static void CalcEvIndices(ALfloat ev, ALuint *evidx, ALfloat *evmu)
// interpolation factor between 0.0 and 1.0.
static void CalcAzIndices(ALuint evidx, ALfloat az, ALuint *azidx, ALfloat *azmu)
{
az = (M_PI*2.0f + az) * azCount[evidx] / (M_PI*2.0f);
azidx[0] = (ALuint)az % azCount[evidx];
az = (F_PI*2.0f + az) * azCount[evidx] / (F_PI*2.0f);
azidx[0] = fastf2u(az) % azCount[evidx];
azidx[1] = (azidx[0] + 1) % azCount[evidx];
*azmu = az - floor(az);
*azmu = az - aluFloor(az);
}
// Calculates the normalized HRTF transition factor (delta) from the changes
@ -99,7 +99,7 @@ ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3],
// Calculate the normalized dB gain change.
newGain = maxf(newGain, 0.0001f);
oldGain = maxf(oldGain, 0.0001f);
gainChange = aluFabs(log10(newGain / oldGain) / log10(0.0001f));
gainChange = aluFabs(aluLog10(newGain / oldGain) / aluLog10(0.0001f));
// Calculate the normalized listener to source angle change when there is
// enough gain to notice it.
@ -111,7 +111,7 @@ ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3],
if(newdir[0]-olddir[0] || newdir[1]-olddir[1] || newdir[2]-olddir[2])
angleChange = aluAcos(olddir[0]*newdir[0] +
olddir[1]*newdir[1] +
olddir[2]*newdir[2]) / M_PI;
olddir[2]*newdir[2]) / F_PI;
}
@ -161,15 +161,15 @@ void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azi
// coefficients if gain is too low.
if(gain > 0.0001f)
{
ALdouble scale = gain * (1.0/32767.0);
gain *= 1.0f/32767.0f;
for(i = 0;i < HRIR_LENGTH;i++)
{
coeffs[i][0] = lerp(lerp(Hrtf->coeffs[lidx[0]][i], Hrtf->coeffs[lidx[1]][i], mu[0]),
lerp(Hrtf->coeffs[lidx[2]][i], Hrtf->coeffs[lidx[3]][i], mu[1]),
mu[2]) * scale;
mu[2]) * gain;
coeffs[i][1] = lerp(lerp(Hrtf->coeffs[ridx[0]][i], Hrtf->coeffs[ridx[1]][i], mu[0]),
lerp(Hrtf->coeffs[ridx[2]][i], Hrtf->coeffs[ridx[3]][i], mu[1]),
mu[2]) * scale;
mu[2]) * gain;
}
}
else
@ -182,12 +182,12 @@ void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azi
}
// Calculate the HRIR delays using linear interpolation.
delays[0] = (ALuint)(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]),
lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]),
mu[2]) * 65536.0f);
delays[1] = (ALuint)(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]),
lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]),
mu[2]) * 65536.0f);
delays[0] = fastf2u(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]),
lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]),
mu[2]) * 65536.0f);
delays[1] = fastf2u(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]),
lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]),
mu[2]) * 65536.0f);
}
// Calculates the moving HRIR target coefficients, target delays, and
@ -231,7 +231,7 @@ ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat a
ridx[3] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[1]) % azCount[evidx[1]]);
// Calculate the stepping parameters.
delta = maxf(floor(delta*(Hrtf->sampleRate*0.015f) + 0.5), 1.0f);
delta = maxf(aluFloor(delta*(Hrtf->sampleRate*0.015f) + 0.5f), 1.0f);
step = 1.0f / delta;
// Calculate the normalized and attenuated target HRIR coefficients using
@ -241,7 +241,7 @@ ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat a
// coefficients.
if(gain > 0.0001f)
{
ALdouble scale = gain * (1.0/32767.0);
gain *= 1.0f/32767.0f;
for(i = 0;i < HRIR_LENGTH;i++)
{
left = coeffs[i][0] - (coeffStep[i][0] * counter);
@ -249,10 +249,10 @@ ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat a
coeffs[i][0] = lerp(lerp(Hrtf->coeffs[lidx[0]][i], Hrtf->coeffs[lidx[1]][i], mu[0]),
lerp(Hrtf->coeffs[lidx[2]][i], Hrtf->coeffs[lidx[3]][i], mu[1]),
mu[2]) * scale;
mu[2]) * gain;
coeffs[i][1] = lerp(lerp(Hrtf->coeffs[ridx[0]][i], Hrtf->coeffs[ridx[1]][i], mu[0]),
lerp(Hrtf->coeffs[ridx[2]][i], Hrtf->coeffs[ridx[3]][i], mu[1]),
mu[2]) * scale;
mu[2]) * gain;
coeffStep[i][0] = step * (coeffs[i][0] - left);
coeffStep[i][1] = step * (coeffs[i][1] - right);
@ -276,23 +276,23 @@ ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat a
// Calculate the HRIR delays using linear interpolation. Then calculate
// the delay stepping values using the target and previous running
// delays.
left = delays[0] - (delayStep[0] * counter);
right = delays[1] - (delayStep[1] * counter);
left = (ALfloat)(delays[0] - (delayStep[0] * counter));
right = (ALfloat)(delays[1] - (delayStep[1] * counter));
delays[0] = (ALuint)(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]),
lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]),
mu[2]) * 65536.0f);
delays[1] = (ALuint)(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]),
lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]),
mu[2]) * 65536.0f);
delays[0] = fastf2u(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]),
lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]),
mu[2]) * 65536.0f);
delays[1] = fastf2u(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]),
lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]),
mu[2]) * 65536.0f);
delayStep[0] = (ALint)(step * (delays[0] - left));
delayStep[1] = (ALint)(step * (delays[1] - right));
delayStep[0] = fastf2i(step * (delays[0] - left));
delayStep[1] = fastf2i(step * (delays[1] - right));
// The stepping count is the number of samples necessary for the HRIR to
// complete its transition. The mixer will only apply stepping for this
// many samples.
return (ALuint)delta;
return fastf2u(delta);
}
const struct Hrtf *GetHrtf(ALCdevice *device)

View File

@ -37,29 +37,29 @@
#include "bs2b.h"
static __inline ALdouble point32(const ALfloat *vals, ALint step, ALint frac)
static __inline ALfloat point32(const ALfloat *vals, ALint step, ALint frac)
{ return vals[0]; (void)step; (void)frac; }
static __inline ALdouble lerp32(const ALfloat *vals, ALint step, ALint frac)
{ return lerp(vals[0], vals[step], frac * (1.0/FRACTIONONE)); }
static __inline ALdouble cubic32(const ALfloat *vals, ALint step, ALint frac)
static __inline ALfloat lerp32(const ALfloat *vals, ALint step, ALint frac)
{ return lerp(vals[0], vals[step], frac * (1.0f/FRACTIONONE)); }
static __inline ALfloat cubic32(const ALfloat *vals, ALint step, ALint frac)
{ return cubic(vals[-step], vals[0], vals[step], vals[step+step],
frac * (1.0/FRACTIONONE)); }
frac * (1.0f/FRACTIONONE)); }
static __inline ALdouble point16(const ALshort *vals, ALint step, ALint frac)
{ return vals[0] * (1.0/32767.0); (void)step; (void)frac; }
static __inline ALdouble lerp16(const ALshort *vals, ALint step, ALint frac)
{ return lerp(vals[0], vals[step], frac * (1.0/FRACTIONONE)) * (1.0/32767.0); }
static __inline ALdouble cubic16(const ALshort *vals, ALint step, ALint frac)
static __inline ALfloat point16(const ALshort *vals, ALint step, ALint frac)
{ return vals[0] * (1.0f/32767.0f); (void)step; (void)frac; }
static __inline ALfloat lerp16(const ALshort *vals, ALint step, ALint frac)
{ return lerp(vals[0], vals[step], frac * (1.0f/FRACTIONONE)) * (1.0f/32767.0f); }
static __inline ALfloat cubic16(const ALshort *vals, ALint step, ALint frac)
{ return cubic(vals[-step], vals[0], vals[step], vals[step+step],
frac * (1.0/FRACTIONONE)) * (1.0/32767.0); }
frac * (1.0f/FRACTIONONE)) * (1.0f/32767.0f); }
static __inline ALdouble point8(const ALbyte *vals, ALint step, ALint frac)
{ return vals[0] * (1.0/127.0); (void)step; (void)frac; }
static __inline ALdouble lerp8(const ALbyte *vals, ALint step, ALint frac)
{ return lerp(vals[0], vals[step], frac * (1.0/FRACTIONONE)) * (1.0/127.0); }
static __inline ALdouble cubic8(const ALbyte *vals, ALint step, ALint frac)
static __inline ALfloat point8(const ALbyte *vals, ALint step, ALint frac)
{ return vals[0] * (1.0f/127.0f); (void)step; (void)frac; }
static __inline ALfloat lerp8(const ALbyte *vals, ALint step, ALint frac)
{ return lerp(vals[0], vals[step], frac * (1.0f/FRACTIONONE)) * (1.0f/127.0f); }
static __inline ALfloat cubic8(const ALbyte *vals, ALint step, ALint frac)
{ return cubic(vals[-step], vals[0], vals[step], vals[step+step],
frac * (1.0/FRACTIONONE)) * (1.0/127.0); }
frac * (1.0f/FRACTIONONE)) * (1.0f/127.0f); }
#ifdef __GNUC__
#define LIKELY(x) __builtin_expect(!!(x), 1)
@ -338,9 +338,9 @@ static void Mix_##T##_##sampler(ALsource *Source, ALCdevice *Device, \
const T *RESTRICT data = srcdata; \
ALfloat (*DryBuffer)[MAXCHANNELS]; \
ALfloat *ClickRemoval, *PendingClicks; \
ALuint pos, frac; \
ALfloat DrySend[MAXCHANNELS][MAXCHANNELS]; \
ALfloat DrySend[MAXCHANNELS]; \
FILTER *DryFilter; \
ALuint pos, frac; \
ALuint BufferIdx; \
ALuint increment; \
ALuint i, out, c; \
@ -352,17 +352,15 @@ static void Mix_##T##_##sampler(ALsource *Source, ALCdevice *Device, \
ClickRemoval = Device->ClickRemoval; \
PendingClicks = Device->PendingClicks; \
DryFilter = &Source->Params.iirFilter; \
for(i = 0;i < NumChannels;i++) \
{ \
for(c = 0;c < MAXCHANNELS;c++) \
DrySend[i][c] = Source->Params.DryGains[i][c]; \
} \
\
pos = 0; \
frac = *DataPosFrac; \
\
for(i = 0;i < NumChannels;i++) \
{ \
for(c = 0;c < MAXCHANNELS;c++) \
DrySend[c] = Source->Params.DryGains[i][c]; \
\
pos = 0; \
frac = *DataPosFrac; \
\
@ -372,7 +370,7 @@ static void Mix_##T##_##sampler(ALsource *Source, ALCdevice *Device, \
\
value = lpFilter2PC(DryFilter, i, value); \
for(c = 0;c < MAXCHANNELS;c++) \
ClickRemoval[c] -= value*DrySend[i][c]; \
ClickRemoval[c] -= value*DrySend[c]; \
} \
for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \
{ \
@ -380,7 +378,7 @@ static void Mix_##T##_##sampler(ALsource *Source, ALCdevice *Device, \
\
value = lpFilter2P(DryFilter, i, value); \
for(c = 0;c < MAXCHANNELS;c++) \
DryBuffer[OutPos][c] += value*DrySend[i][c]; \
DryBuffer[OutPos][c] += value*DrySend[c]; \
\
frac += increment; \
pos += frac>>FRACTIONBITS; \
@ -393,7 +391,7 @@ static void Mix_##T##_##sampler(ALsource *Source, ALCdevice *Device, \
\
value = lpFilter2PC(DryFilter, i, value); \
for(c = 0;c < MAXCHANNELS;c++) \
PendingClicks[c] += value*DrySend[i][c]; \
PendingClicks[c] += value*DrySend[c]; \
} \
OutPos -= BufferSize; \
} \
@ -592,7 +590,8 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
DataSize64 += BufferPadding+BufferPrePadding;
DataSize64 *= FrameSize;
BufferSize = ((DataSize64 > STACK_DATA_SIZE) ? STACK_DATA_SIZE : DataSize64);
BufferSize = (ALuint)((DataSize64 > STACK_DATA_SIZE) ?
STACK_DATA_SIZE : DataSize64);
BufferSize -= BufferSize%FrameSize;
if(Source->lSourceType == AL_STATIC)
@ -796,7 +795,6 @@ ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
if(Looping && Source->lSourceType == AL_STATIC)
{
BufferListItem = Source->queue;
DataPosInt = ((DataPosInt-LoopStart)%(LoopEnd-LoopStart)) + LoopStart;
break;
}

View File

@ -102,7 +102,7 @@ static void SetSpeakerArrangement(const char *name, ALfloat SpeakerAngle[MAXCHAN
{
long angle = strtol(sep, NULL, 10);
if(angle >= -180 && angle <= 180)
SpeakerAngle[i] = angle * M_PI/180.0f;
SpeakerAngle[i] = angle * F_PI/180.0f;
else
ERR("Invalid angle for speaker \"%s\": %ld\n", confkey, angle);
break;
@ -144,10 +144,10 @@ static ALfloat aluLUTpos2Angle(ALint pos)
if(pos < QUADRANT_NUM)
return aluAtan((ALfloat)pos / (ALfloat)(QUADRANT_NUM - pos));
if(pos < 2 * QUADRANT_NUM)
return M_PI_2 + aluAtan((ALfloat)(pos - QUADRANT_NUM) / (ALfloat)(2 * QUADRANT_NUM - pos));
return F_PI_2 + aluAtan((ALfloat)(pos - QUADRANT_NUM) / (ALfloat)(2 * QUADRANT_NUM - pos));
if(pos < 3 * QUADRANT_NUM)
return aluAtan((ALfloat)(pos - 2 * QUADRANT_NUM) / (ALfloat)(3 * QUADRANT_NUM - pos)) - M_PI;
return aluAtan((ALfloat)(pos - 3 * QUADRANT_NUM) / (ALfloat)(4 * QUADRANT_NUM - pos)) - M_PI_2;
return aluAtan((ALfloat)(pos - 2 * QUADRANT_NUM) / (ALfloat)(3 * QUADRANT_NUM - pos)) - F_PI;
return aluAtan((ALfloat)(pos - 3 * QUADRANT_NUM) / (ALfloat)(4 * QUADRANT_NUM - pos)) - F_PI_2;
}
ALint aluCart2LUTpos(ALfloat re, ALfloat im)
@ -157,9 +157,9 @@ ALint aluCart2LUTpos(ALfloat re, ALfloat im)
if(denom > 0.0f)
pos = (ALint)(QUADRANT_NUM*aluFabs(im) / denom + 0.5);
if(re < 0.0)
if(re < 0.0f)
pos = 2 * QUADRANT_NUM - pos;
if(im < 0.0)
if(im < 0.0f)
pos = LUT_NUM - pos;
return pos%LUT_NUM;
}
@ -178,15 +178,15 @@ ALvoid aluInitPanning(ALCdevice *Device)
case DevFmtMono:
Device->NumChan = 1;
Speaker2Chan[0] = FRONT_CENTER;
SpeakerAngle[0] = 0.0f * M_PI/180.0f;
SpeakerAngle[0] = F_PI/180.0f * 0.0f;
break;
case DevFmtStereo:
Device->NumChan = 2;
Speaker2Chan[0] = FRONT_LEFT;
Speaker2Chan[1] = FRONT_RIGHT;
SpeakerAngle[0] = -90.0f * M_PI/180.0f;
SpeakerAngle[1] = 90.0f * M_PI/180.0f;
SpeakerAngle[0] = F_PI/180.0f * -90.0f;
SpeakerAngle[1] = F_PI/180.0f * 90.0f;
SetSpeakerArrangement("layout_STEREO", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@ -196,10 +196,10 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[1] = FRONT_LEFT;
Speaker2Chan[2] = FRONT_RIGHT;
Speaker2Chan[3] = BACK_RIGHT;
SpeakerAngle[0] = -135.0f * M_PI/180.0f;
SpeakerAngle[1] = -45.0f * M_PI/180.0f;
SpeakerAngle[2] = 45.0f * M_PI/180.0f;
SpeakerAngle[3] = 135.0f * M_PI/180.0f;
SpeakerAngle[0] = F_PI/180.0f * -135.0f;
SpeakerAngle[1] = F_PI/180.0f * -45.0f;
SpeakerAngle[2] = F_PI/180.0f * 45.0f;
SpeakerAngle[3] = F_PI/180.0f * 135.0f;
SetSpeakerArrangement("layout_QUAD", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@ -210,11 +210,11 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[2] = FRONT_CENTER;
Speaker2Chan[3] = FRONT_RIGHT;
Speaker2Chan[4] = BACK_RIGHT;
SpeakerAngle[0] = -110.0f * M_PI/180.0f;
SpeakerAngle[1] = -30.0f * M_PI/180.0f;
SpeakerAngle[2] = 0.0f * M_PI/180.0f;
SpeakerAngle[3] = 30.0f * M_PI/180.0f;
SpeakerAngle[4] = 110.0f * M_PI/180.0f;
SpeakerAngle[0] = F_PI/180.0f * -110.0f;
SpeakerAngle[1] = F_PI/180.0f * -30.0f;
SpeakerAngle[2] = F_PI/180.0f * 0.0f;
SpeakerAngle[3] = F_PI/180.0f * 30.0f;
SpeakerAngle[4] = F_PI/180.0f * 110.0f;
SetSpeakerArrangement("layout_51CHN", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@ -225,11 +225,11 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[2] = FRONT_CENTER;
Speaker2Chan[3] = FRONT_RIGHT;
Speaker2Chan[4] = SIDE_RIGHT;
SpeakerAngle[0] = -90.0f * M_PI/180.0f;
SpeakerAngle[1] = -30.0f * M_PI/180.0f;
SpeakerAngle[2] = 0.0f * M_PI/180.0f;
SpeakerAngle[3] = 30.0f * M_PI/180.0f;
SpeakerAngle[4] = 90.0f * M_PI/180.0f;
SpeakerAngle[0] = F_PI/180.0f * -90.0f;
SpeakerAngle[1] = F_PI/180.0f * -30.0f;
SpeakerAngle[2] = F_PI/180.0f * 0.0f;
SpeakerAngle[3] = F_PI/180.0f * 30.0f;
SpeakerAngle[4] = F_PI/180.0f * 90.0f;
SetSpeakerArrangement("layout_51SIDECHN", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@ -241,12 +241,12 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[3] = FRONT_RIGHT;
Speaker2Chan[4] = SIDE_RIGHT;
Speaker2Chan[5] = BACK_CENTER;
SpeakerAngle[0] = -90.0f * M_PI/180.0f;
SpeakerAngle[1] = -30.0f * M_PI/180.0f;
SpeakerAngle[2] = 0.0f * M_PI/180.0f;
SpeakerAngle[3] = 30.0f * M_PI/180.0f;
SpeakerAngle[4] = 90.0f * M_PI/180.0f;
SpeakerAngle[5] = 180.0f * M_PI/180.0f;
SpeakerAngle[0] = F_PI/180.0f * -90.0f;
SpeakerAngle[1] = F_PI/180.0f * -30.0f;
SpeakerAngle[2] = F_PI/180.0f * 0.0f;
SpeakerAngle[3] = F_PI/180.0f * 30.0f;
SpeakerAngle[4] = F_PI/180.0f * 90.0f;
SpeakerAngle[5] = F_PI/180.0f * 180.0f;
SetSpeakerArrangement("layout_61CHN", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
@ -259,13 +259,13 @@ ALvoid aluInitPanning(ALCdevice *Device)
Speaker2Chan[4] = FRONT_RIGHT;
Speaker2Chan[5] = SIDE_RIGHT;
Speaker2Chan[6] = BACK_RIGHT;
SpeakerAngle[0] = -150.0f * M_PI/180.0f;
SpeakerAngle[1] = -90.0f * M_PI/180.0f;
SpeakerAngle[2] = -30.0f * M_PI/180.0f;
SpeakerAngle[3] = 0.0f * M_PI/180.0f;
SpeakerAngle[4] = 30.0f * M_PI/180.0f;
SpeakerAngle[5] = 90.0f * M_PI/180.0f;
SpeakerAngle[6] = 150.0f * M_PI/180.0f;
SpeakerAngle[0] = F_PI/180.0f * -150.0f;
SpeakerAngle[1] = F_PI/180.0f * -90.0f;
SpeakerAngle[2] = F_PI/180.0f * -30.0f;
SpeakerAngle[3] = F_PI/180.0f * 0.0f;
SpeakerAngle[4] = F_PI/180.0f * 30.0f;
SpeakerAngle[5] = F_PI/180.0f * 90.0f;
SpeakerAngle[6] = F_PI/180.0f * 150.0f;
SetSpeakerArrangement("layout_71CHN", SpeakerAngle, Speaker2Chan, Device->NumChan);
break;
}
@ -293,10 +293,10 @@ ALvoid aluInitPanning(ALCdevice *Device)
if(Theta >= SpeakerAngle[s] && Theta < SpeakerAngle[s+1])
{
/* source between speaker s and speaker s+1 */
Alpha = M_PI_2 * (Theta-SpeakerAngle[s]) /
Alpha = F_PI_2 * (Theta-SpeakerAngle[s]) /
(SpeakerAngle[s+1]-SpeakerAngle[s]);
PanningLUT[Speaker2Chan[s]] = cos(Alpha);
PanningLUT[Speaker2Chan[s+1]] = sin(Alpha);
PanningLUT[Speaker2Chan[s]] = aluCos(Alpha);
PanningLUT[Speaker2Chan[s+1]] = aluSin(Alpha);
break;
}
}
@ -304,11 +304,11 @@ ALvoid aluInitPanning(ALCdevice *Device)
{
/* source between last and first speaker */
if(Theta < SpeakerAngle[0])
Theta += 2.0f * M_PI;
Alpha = M_PI_2 * (Theta-SpeakerAngle[s]) /
(2.0f * M_PI + SpeakerAngle[0]-SpeakerAngle[s]);
PanningLUT[Speaker2Chan[s]] = cos(Alpha);
PanningLUT[Speaker2Chan[0]] = sin(Alpha);
Theta += F_PI*2.0f;
Alpha = F_PI_2 * (Theta-SpeakerAngle[s]) /
(F_PI*2.0f + SpeakerAngle[0]-SpeakerAngle[s]);
PanningLUT[Speaker2Chan[s]] = aluCos(Alpha);
PanningLUT[Speaker2Chan[0]] = aluSin(Alpha);
}
}
}

View File

@ -184,7 +184,8 @@ IF(WIN32)
ENDIF()
ELSE()
SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror")
# Yes GCC, really don't accept visibility modes you don't support
SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
@ -198,13 +199,15 @@ ELSE()
ENDIF()
ENDIF()
CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
ADD_DEFINITIONS(-fvisibility=internal)
ELSE()
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
ADD_DEFINITIONS(-fvisibility=hidden)
IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
ADD_DEFINITIONS(-fvisibility=internal)
ELSE()
CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH)
IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
ADD_DEFINITIONS(-fvisibility=hidden)
ENDIF()
ENDIF()
ENDIF()
@ -215,6 +218,7 @@ CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(pri
int main() {return 0;}" HAVE_GCC_FORMAT)
CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H)
CHECK_INCLUDE_FILE(fpu_control.h HAVE_FPU_CONTROL_H)
CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H)
CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H)
CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H)
@ -223,17 +227,30 @@ IF(NOT HAVE_GUIDDEF_H)
ENDIF()
CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H)
CHECK_LIBRARY_EXISTS(m powf "" HAVE_POWF)
CHECK_LIBRARY_EXISTS(m sqrtf "" HAVE_SQRTF)
CHECK_LIBRARY_EXISTS(m acosf "" HAVE_ACOSF)
CHECK_LIBRARY_EXISTS(m atanf "" HAVE_ATANF)
CHECK_LIBRARY_EXISTS(m fabsf "" HAVE_FABSF)
IF(HAVE_FENV_H)
CHECK_LIBRARY_EXISTS(m fesetround "" HAVE_FESETROUND)
ENDIF()
IF(HAVE_SQRTF OR HAVE_ACOSF OR HAVE_ATANF OR HAVE_FABSF OR HAVE_FESETROUND)
# Some systems need libm for some of the following math functions to work
CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM)
IF(HAVE_LIBM)
SET(EXTRA_LIBS m ${EXTRA_LIBS})
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m)
ENDIF()
CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF)
CHECK_SYMBOL_EXISTS(sqrtf math.h HAVE_SQRTF)
CHECK_SYMBOL_EXISTS(cosf math.h HAVE_COSF)
CHECK_SYMBOL_EXISTS(sinf math.h HAVE_SINF)
CHECK_SYMBOL_EXISTS(acosf math.h HAVE_ACOSF)
CHECK_SYMBOL_EXISTS(asinf math.h HAVE_ASINF)
CHECK_SYMBOL_EXISTS(atanf math.h HAVE_ATANF)
CHECK_SYMBOL_EXISTS(atan2f math.h HAVE_ATAN2F)
CHECK_SYMBOL_EXISTS(fabsf math.h HAVE_FABSF)
CHECK_SYMBOL_EXISTS(log10f math.h HAVE_LOG10F)
CHECK_SYMBOL_EXISTS(floorf math.h HAVE_FLOORF)
IF(HAVE_FENV_H)
CHECK_SYMBOL_EXISTS(fesetround fenv.h HAVE_FESETROUND)
ENDIF()
CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF)
CHECK_FUNCTION_EXISTS(_controlfp HAVE__CONTROLFP)

View File

@ -18,6 +18,7 @@ enum UserFmtType {
UserFmtFloat = AL_FLOAT,
UserFmtDouble = AL_DOUBLE,
UserFmtMulaw = AL_MULAW,
UserFmtAlaw = AL_ALAW,
UserFmtIMA4 = AL_IMA4,
UserFmtByte3 = AL_BYTE3,
UserFmtUByte3 = AL_UNSIGNED_BYTE3,
@ -71,13 +72,13 @@ typedef struct ALbuffer
ALsizei size;
ALsizei Frequency;
ALenum Format;
enum FmtChannels FmtChannels;
enum FmtType FmtType;
enum UserFmtChannels OriginalChannels;
enum UserFmtType OriginalType;
ALsizei OriginalSize;
ALsizei OriginalAlign;
ALsizei OriginalSize;
ALsizei LoopStart;
ALsizei LoopEnd;

View File

@ -9,6 +9,10 @@
#include <fenv.h>
#endif
#ifdef HAVE_FPU_CONTROL_H
#include <fpu_control.h>
#endif
#include "AL/al.h"
#include "AL/alc.h"
#include "AL/alext.h"
@ -59,7 +63,8 @@ ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffe
#define AL_BYTE3 0x1408
#define AL_UNSIGNED_BYTE3 0x1409
#define AL_MULAW 0x1410
#define AL_IMA4 0x1411
#define AL_ALAW 0x1411
#define AL_IMA4 0x1412
/* Channel configurations */
#define AL_MONO 0x1500
@ -93,19 +98,25 @@ ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffe
#define AL_7POINT1_16 0x1211
#define AL_7POINT1_32F 0x1212
/* Buffer attributes */
#define AL_INTERNAL_FORMAT 0x2008
#define AL_BYTE_LENGTH 0x2009
#define AL_SAMPLE_LENGTH 0x200A
#define AL_SEC_LENGTH 0x200B
typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*);
typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*);
typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*);
typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum);
#ifdef AL_ALEXT_PROTOTYPES
AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
ALuint samplerate, ALenum internalformat, ALsizei frames,
ALuint samplerate, ALenum internalformat, ALsizei samples,
ALenum channels, ALenum type, const ALvoid *data);
AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer,
ALsizei offset, ALsizei frames,
ALsizei offset, ALsizei samples,
ALenum channels, ALenum type, const ALvoid *data);
AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer,
ALsizei offset, ALsizei frames,
ALsizei offset, ALsizei samples,
ALenum channels, ALenum type, ALvoid *data);
AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format);
#endif
@ -239,6 +250,76 @@ static __inline ALboolean CompExchangePtr(void *volatile*ptr, void *oldval, void
return __sync_bool_compare_and_swap(ptr, oldval, newval);
}
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
static __inline int xaddl(volatile int *dest, int incr)
{
int ret;
__asm__ __volatile__("lock; xaddl %0,(%1)"
: "=r" (ret)
: "r" (dest), "0" (incr)
: "memory");
return ret;
}
typedef int RefCount;
static __inline RefCount IncrementRef(volatile RefCount *ptr)
{ return xaddl(ptr, 1)+1; }
static __inline RefCount DecrementRef(volatile RefCount *ptr)
{ return xaddl(ptr, -1)-1; }
static __inline int ExchangeInt(volatile int *dest, int newval)
{
int ret;
__asm__ __volatile__("lock; xchgl %0,(%1)"
: "=r" (ret)
: "r" (dest), "0" (newval)
: "memory");
return ret;
}
static __inline ALboolean CompExchangeInt(volatile int *dest, int oldval, int newval)
{
int ret;
__asm__ __volatile__("lock; cmpxchgl %2,(%1)"
: "=a" (ret)
: "r" (dest), "r" (newval), "0" (oldval)
: "memory");
return ret == oldval;
}
static __inline void *ExchangePtr(void *volatile*dest, void *newval)
{
void *ret;
__asm__ __volatile__(
#ifdef __i386__
"lock; xchgl %0,(%1)"
#else
"lock; xchgq %0,(%1)"
#endif
: "=r" (ret)
: "r" (dest), "0" (newval)
: "memory"
);
return ret;
}
static __inline ALboolean CompExchangePtr(void *volatile*dest, void *oldval, void *newval)
{
void *ret;
__asm__ __volatile__(
#ifdef __i386__
"lock; cmpxchgl %2,(%1)"
#else
"lock; cmpxchgq %2,(%1)"
#endif
: "=a" (ret)
: "r" (dest), "r" (newval), "0" (oldval)
: "memory"
);
return ret == oldval;
}
#elif defined(_WIN32)
typedef LONG RefCount;
@ -370,9 +451,9 @@ extern "C" {
#define DEFAULT_OUTPUT_RATE (44100)
#define SPEEDOFSOUNDMETRESPERSEC (343.3f)
#define AIRABSORBGAINHF (0.99426) /* -0.05dB */
#define AIRABSORBGAINHF (0.99426f) /* -0.05dB */
#define LOWPASSFREQCUTOFF (5000)
#define LOWPASSFREQREF (5000)
struct Hrtf;
@ -395,6 +476,30 @@ static __inline ALuint NextPowerOf2(ALuint value)
return powerOf2;
}
/* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero
* mode. */
static __inline ALint fastf2i(ALfloat f)
{
ALint i;
#if defined(_MSC_VER) && !defined(_WIN64)
__asm fld f
__asm fistp i
#elif defined(__GNUC__)
__asm__ __volatile__("flds %1\n\t"
"fistpl %0\n\t"
: "=m" (i)
: "m" (f));
#else
i = (ALint)f;
#endif
return i;
}
/* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero
* mode. */
static __inline ALuint fastf2u(ALfloat f)
{ return fastf2i(f); }
enum DevProbe {
DEVICE_PROBE,
@ -600,6 +705,14 @@ struct ALCdevice_struct
// Specifies if the device is currently running
#define DEVICE_RUNNING (1<<31)
#define LookupBuffer(m, k) ((struct ALbuffer*)LookupUIntMapKey(&(m)->BufferMap, (k)))
#define LookupEffect(m, k) ((struct ALeffect*)LookupUIntMapKey(&(m)->EffectMap, (k)))
#define LookupFilter(m, k) ((struct ALfilter*)LookupUIntMapKey(&(m)->FilterMap, (k)))
#define RemoveBuffer(m, k) ((struct ALbuffer*)PopUIntMapValue(&(m)->BufferMap, (k)))
#define RemoveEffect(m, k) ((struct ALeffect*)PopUIntMapValue(&(m)->EffectMap, (k)))
#define RemoveFilter(m, k) ((struct ALfilter*)PopUIntMapValue(&(m)->FilterMap, (k)))
struct ALCcontext_struct
{
volatile RefCount ref;
@ -635,6 +748,11 @@ struct ALCcontext_struct
ALCcontext *volatile next;
};
#define LookupSource(m, k) ((struct ALsource*)LookupUIntMapKey(&(m)->SourceMap, (k)))
#define LookupEffectSlot(m, k) ((struct ALeffectslot*)LookupUIntMapKey(&(m)->EffectSlotMap, (k)))
#define RemoveSource(m, k) ((struct ALsource*)PopUIntMapValue(&(m)->SourceMap, (k)))
#define RemoveEffectSlot(m, k) ((struct ALeffectslot*)PopUIntMapValue(&(m)->EffectSlotMap, (k)))
ALCcontext *GetContextRef(void);
void ALCcontext_IncRef(ALCcontext *context);
@ -721,9 +839,6 @@ extern enum LogLevel LogLevel;
} while(0)
extern ALdouble ConeScale;
extern ALdouble ZScale;
extern ALint RTPrioLevel;
#ifdef __cplusplus

View File

@ -14,10 +14,9 @@
#include <ieeefp.h>
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#endif
#define F_PI (3.14159265358979323846f) /* pi */
#define F_PI_2 (1.57079632679489661923f) /* pi/2 */
#ifdef HAVE_POWF
#define aluPow(x,y) (powf((x),(y)))
@ -31,24 +30,60 @@
#define aluSqrt(x) ((ALfloat)sqrt((double)(x)))
#endif
#ifdef HAVE_COSF
#define aluCos(x) (cosf((x)))
#else
#define aluCos(x) ((ALfloat)cos((double)(x)))
#endif
#ifdef HAVE_SINF
#define aluSin(x) (sinf((x)))
#else
#define aluSin(x) ((ALfloat)sin((double)(x)))
#endif
#ifdef HAVE_ACOSF
#define aluAcos(x) (acosf((x)))
#else
#define aluAcos(x) ((ALfloat)acos((double)(x)))
#endif
#ifdef HAVE_ASINF
#define aluAsin(x) (asinf((x)))
#else
#define aluAsin(x) ((ALfloat)asin((double)(x)))
#endif
#ifdef HAVE_ATANF
#define aluAtan(x) (atanf((x)))
#else
#define aluAtan(x) ((ALfloat)atan((double)(x)))
#endif
#ifdef HAVE_ATAN2F
#define aluAtan2(x,y) (atan2f((x),(y)))
#else
#define aluAtan2(x,y) ((ALfloat)atan2((double)(x),(double)(y)))
#endif
#ifdef HAVE_FABSF
#define aluFabs(x) (fabsf((x)))
#else
#define aluFabs(x) ((ALfloat)fabs((double)(x)))
#endif
#ifdef HAVE_LOG10F
#define aluLog10(x) (log10f((x)))
#else
#define aluLog10(x) ((ALfloat)log10((double)(x)))
#endif
#ifdef HAVE_FLOORF
#define aluFloor(x) (floorf((x)))
#else
#define aluFloor(x) ((ALfloat)floor((double)(x)))
#endif
#define QUADRANT_NUM 128
#define LUT_NUM (4 * QUADRANT_NUM)
@ -141,21 +176,57 @@ static __inline ALint clampi(ALint val, ALint min, ALint max)
{ return mini(max, maxi(min, val)); }
static __inline ALdouble lerp(ALdouble val1, ALdouble val2, ALdouble mu)
static __inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu)
{
return val1 + (val2-val1)*mu;
}
static __inline ALdouble cubic(ALdouble val0, ALdouble val1, ALdouble val2, ALdouble val3, ALdouble mu)
static __inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu)
{
ALdouble mu2 = mu*mu;
ALdouble a0 = -0.5*val0 + 1.5*val1 + -1.5*val2 + 0.5*val3;
ALdouble a1 = val0 + -2.5*val1 + 2.0*val2 + -0.5*val3;
ALdouble a2 = -0.5*val0 + 0.5*val2;
ALdouble a3 = val1;
ALfloat mu2 = mu*mu;
ALfloat a0 = -0.5f*val0 + 1.5f*val1 + -1.5f*val2 + 0.5f*val3;
ALfloat a1 = val0 + -2.5f*val1 + 2.0f*val2 + -0.5f*val3;
ALfloat a2 = -0.5f*val0 + 0.5f*val2;
ALfloat a3 = val1;
return a0*mu*mu2 + a1*mu2 + a2*mu + a3;
}
static __inline int SetMixerFPUMode(void)
{
#if defined(_FPU_GETCW) && defined(_FPU_SETCW)
fpu_control_t fpuState, newState;
_FPU_GETCW(fpuState);
newState = fpuState&~(_FPU_EXTENDED|_FPU_DOUBLE|_FPU_SINGLE |
_FPU_RC_NEAREST|_FPU_RC_DOWN|_FPU_RC_UP|_FPU_RC_ZERO);
newState |= _FPU_SINGLE | _FPU_RC_ZERO;
_FPU_SETCW(newState);
#else
int fpuState;
#if defined(HAVE__CONTROLFP)
fpuState = _controlfp(0, 0);
(void)_controlfp(_RC_CHOP|_PC_24, _MCW_RC|_MCW_PC);
#elif defined(HAVE_FESETROUND)
fpuState = fegetround();
fesetround(FE_TOWARDZERO);
#endif
#endif
return fpuState;
}
static __inline void RestoreFPUMode(int state)
{
#if defined(_FPU_GETCW) && defined(_FPU_SETCW)
fpu_control_t fpuState = state;
_FPU_SETCW(fpuState);
#elif defined(HAVE__CONTROLFP)
_controlfp(state, _MCW_RC|_MCW_PC);
#elif defined(HAVE_FESETROUND)
fesetround(state);
#endif
}
ALvoid aluInitPanning(ALCdevice *Device);
ALint aluCart2LUTpos(ALfloat re, ALfloat im);
@ -170,6 +241,9 @@ ALvoid MixSource(struct ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size);
ALvoid aluHandleDisconnect(ALCdevice *device);
extern ALfloat ConeScale;
extern ALfloat ZScale;
#ifdef __cplusplus
}
#endif

View File

@ -60,7 +60,7 @@ struct bs2b {
double b1_hi;
/* Global gain against overloading */
double gain;
float gain;
/* Buffer of last filtered sample.
* [0] - first channel, [1] - second channel

View File

@ -36,9 +36,6 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, AL
static ALenum ResizeEffectSlotArray(ALCcontext *Context, ALsizei count);
static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *val);
#define LookupEffectSlot(m, k) ((ALeffectslot*)LookupUIntMapKey(&(m), (k)))
#define RemoveEffectSlot(m, k) ((ALeffectslot*)PopUIntMapValue(&(m), (k)))
#define LookupEffect(m, k) ((ALeffect*)LookupUIntMapKey(&(m), (k)))
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
{
@ -115,7 +112,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots)
{
ALCcontext *Context;
ALeffectslot *EffectSlot;
@ -131,7 +128,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effect
// Check that all effectslots are valid
for(i = 0;i < n;i++)
{
if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslots[i])) == NULL)
if((EffectSlot=LookupEffectSlot(Context, effectslots[i])) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
n = 0;
@ -149,7 +146,7 @@ AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effect
for(i = 0;i < n;i++)
{
// Recheck that the effectslot is valid, because there could be duplicated names
if((EffectSlot=RemoveEffectSlot(Context->EffectSlotMap, effectslots[i])) == NULL)
if((EffectSlot=RemoveEffectSlot(Context, effectslots[i])) == NULL)
continue;
FreeThunkEntry(EffectSlot->effectslot);
@ -172,8 +169,7 @@ AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot)
Context = GetContextRef();
if(!Context) return AL_FALSE;
result = (LookupEffectSlot(Context->EffectSlotMap, effectslot) ?
AL_TRUE : AL_FALSE);
result = (LookupEffectSlot(Context, effectslot) ? AL_TRUE : AL_FALSE);
ALCcontext_DecRef(Context);
@ -190,7 +186,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
if(!Context) return;
Device = Context->Device;
if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslot)) != NULL)
if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL)
{
switch(param)
{
@ -198,7 +194,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
ALeffect *effect = NULL;
if(iValue == 0 ||
(effect=LookupEffect(Device->EffectMap, iValue)) != NULL)
(effect=LookupEffect(Device, iValue)) != NULL)
{
InitializeEffect(Context, EffectSlot, effect);
Context->UpdateSources = AL_TRUE;
@ -228,7 +224,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues)
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues)
{
ALCcontext *Context;
@ -243,7 +239,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum para
Context = GetContextRef();
if(!Context) return;
if(LookupEffectSlot(Context->EffectSlotMap, effectslot) != NULL)
if(LookupEffectSlot(Context, effectslot) != NULL)
{
switch(param)
{
@ -266,7 +262,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param
Context = GetContextRef();
if(!Context) return;
if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslot)) != NULL)
if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL)
{
switch(param)
{
@ -291,7 +287,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues)
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues)
{
ALCcontext *Context;
@ -305,7 +301,7 @@ AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum para
Context = GetContextRef();
if(!Context) return;
if(LookupEffectSlot(Context->EffectSlotMap, effectslot) != NULL)
if(LookupEffectSlot(Context, effectslot) != NULL)
{
switch(param)
{
@ -328,7 +324,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum pa
Context = GetContextRef();
if(!Context) return;
if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslot)) != NULL)
if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL)
{
switch(param)
{
@ -366,7 +362,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum p
Context = GetContextRef();
if(!Context) return;
if(LookupEffectSlot(Context->EffectSlotMap, effectslot) != NULL)
if(LookupEffectSlot(Context, effectslot) != NULL)
{
switch(param)
{
@ -389,7 +385,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum pa
Context = GetContextRef();
if(!Context) return;
if((EffectSlot=LookupEffectSlot(Context->EffectSlotMap, effectslot)) != NULL)
if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL)
{
switch(param)
{
@ -422,7 +418,7 @@ AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum p
Context = GetContextRef();
if(!Context) return;
if(LookupEffectSlot(Context->EffectSlotMap, effectslot) != NULL)
if(LookupEffectSlot(Context, effectslot) != NULL)
{
switch(param)
{
@ -564,6 +560,9 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, AL
if(State)
{
int oldMode;
oldMode = SetMixerFPUMode();
if(ALeffectState_DeviceUpdate(State, Context->Device) == AL_FALSE)
{
UnlockContext(Context);
@ -584,6 +583,8 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *EffectSlot, AL
ALeffectState_Update(EffectSlot->EffectState, Context, EffectSlot);
UnlockContext(Context);
RestoreFPUMode(oldMode);
ALeffectState_Destroy(State);
State = NULL;
}

View File

@ -40,9 +40,6 @@ static ALboolean IsValidChannels(ALenum channels);
static ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans, enum UserFmtType *type);
static ALboolean DecomposeFormat(ALenum format, enum FmtChannels *chans, enum FmtType *type);
#define LookupBuffer(m, k) ((ALbuffer*)LookupUIntMapKey(&(m), (k)))
#define RemoveBuffer(m, k) ((ALbuffer*)PopUIntMapValue(&(m), (k)))
/*
* Global Variables
@ -113,8 +110,7 @@ static const ALshort muLawDecompressionTable[256] = {
/* Values used when encoding a muLaw sample */
static const int muLawBias = 0x84;
static const int muLawClip = 32635;
static const char muLawCompressTable[256] =
{
static const char muLawCompressTable[256] = {
0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
@ -134,6 +130,57 @@ static const char muLawCompressTable[256] =
};
/* A quick'n'dirty lookup table to decode an aLaw-encoded byte sample into a
* signed 16-bit sample */
static const ALshort aLawDecompressionTable[256] = {
-5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
-7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
-2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
-3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
-22016,-20992,-24064,-23040,-17920,-16896,-19968,-18944,
-30208,-29184,-32256,-31232,-26112,-25088,-28160,-27136,
-11008,-10496,-12032,-11520, -8960, -8448, -9984, -9472,
-15104,-14592,-16128,-15616,-13056,-12544,-14080,-13568,
-344, -328, -376, -360, -280, -264, -312, -296,
-472, -456, -504, -488, -408, -392, -440, -424,
-88, -72, -120, -104, -24, -8, -56, -40,
-216, -200, -248, -232, -152, -136, -184, -168,
-1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
-1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
-688, -656, -752, -720, -560, -528, -624, -592,
-944, -912, -1008, -976, -816, -784, -880, -848,
5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
344, 328, 376, 360, 280, 264, 312, 296,
472, 456, 504, 488, 408, 392, 440, 424,
88, 72, 120, 104, 24, 8, 56, 40,
216, 200, 248, 232, 152, 136, 184, 168,
1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
688, 656, 752, 720, 560, 528, 624, 592,
944, 912, 1008, 976, 816, 784, 880, 848
};
/* Values used when encoding an aLaw sample */
static const int aLawClip = 32635;
static const char aLawCompressTable[128] = {
1,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
};
/*
* alGenBuffers(ALsizei n, ALuint *buffers)
*
@ -217,7 +264,7 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
continue;
/* Check for valid Buffer ID */
if((ALBuf=LookupBuffer(device->BufferMap, buffers[i])) == NULL)
if((ALBuf=LookupBuffer(device, buffers[i])) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
n = 0;
@ -234,7 +281,7 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers)
for(i = 0;i < n;i++)
{
if((ALBuf=RemoveBuffer(device->BufferMap, buffers[i])) == NULL)
if((ALBuf=RemoveBuffer(device, buffers[i])) == NULL)
continue;
FreeThunkEntry(ALBuf->buffer);
@ -263,7 +310,7 @@ AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer)
Context = GetContextRef();
if(!Context) return AL_FALSE;
result = ((!buffer || LookupBuffer(Context->Device->BufferMap, buffer)) ?
result = ((!buffer || LookupBuffer(Context->Device, buffer)) ?
AL_TRUE : AL_FALSE);
ALCcontext_DecRef(Context);
@ -290,7 +337,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid
if(!Context) return;
device = Context->Device;
if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
if((ALBuf=LookupBuffer(device, buffer)) == NULL)
alSetError(Context, AL_INVALID_NAME);
else if(size < 0 || freq < 0)
alSetError(Context, AL_INVALID_VALUE);
@ -340,6 +387,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid
} break;
case UserFmtMulaw:
case UserFmtAlaw:
case UserFmtIMA4: {
/* Here is where things vary:
* nVidia and Apple use 64+1 sample frames per block -> block_size=36 bytes per channel
@ -390,7 +438,7 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const
if(!Context) return;
device = Context->Device;
if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
if((ALBuf=LookupBuffer(device, buffer)) == NULL)
alSetError(Context, AL_INVALID_NAME);
else if(length < 0 || offset < 0 || (length > 0 && data == NULL))
alSetError(Context, AL_INVALID_VALUE);
@ -398,13 +446,21 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const
alSetError(Context, AL_INVALID_ENUM);
else
{
ALuint original_align;
WriteLock(&ALBuf->lock);
original_align = ((ALBuf->OriginalType == UserFmtIMA4) ?
(ChannelsFromUserFmt(ALBuf->OriginalChannels)*36) :
FrameSizeFromUserFmt(ALBuf->OriginalChannels,
ALBuf->OriginalType));
if(SrcChannels != ALBuf->OriginalChannels || SrcType != ALBuf->OriginalType)
alSetError(Context, AL_INVALID_ENUM);
else if(offset > ALBuf->OriginalSize ||
length > ALBuf->OriginalSize-offset ||
(offset%ALBuf->OriginalAlign) != 0 ||
(length%ALBuf->OriginalAlign) != 0)
(offset%original_align) != 0 ||
(length%original_align) != 0)
alSetError(Context, AL_INVALID_VALUE);
else
{
@ -416,7 +472,7 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const
offset /= 36;
offset *= 65;
offset *= Bytes;
length /= ALBuf->OriginalAlign;
length /= original_align;
}
else
{
@ -437,7 +493,7 @@ AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const
AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
ALuint samplerate, ALenum internalformat, ALsizei frames,
ALuint samplerate, ALenum internalformat, ALsizei samples,
ALenum channels, ALenum type, const ALvoid *data)
{
ALCcontext *Context;
@ -449,9 +505,9 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
if(!Context) return;
device = Context->Device;
if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
if((ALBuf=LookupBuffer(device, buffer)) == NULL)
alSetError(Context, AL_INVALID_NAME);
else if(frames < 0 || samplerate == 0)
else if(samples < 0 || samplerate == 0)
alSetError(Context, AL_INVALID_VALUE);
else if(IsValidType(type) == AL_FALSE || IsValidChannels(channels) == AL_FALSE)
alSetError(Context, AL_INVALID_ENUM);
@ -460,11 +516,11 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
err = AL_NO_ERROR;
if(type == UserFmtIMA4)
{
if((frames%65) == 0) frames /= 65;
if((samples%65) == 0) samples /= 65;
else err = AL_INVALID_VALUE;
}
if(err == AL_NO_ERROR)
err = LoadData(ALBuf, samplerate, internalformat, frames,
err = LoadData(ALBuf, samplerate, internalformat, samples,
channels, type, data, AL_FALSE);
if(err != AL_NO_ERROR)
alSetError(Context, err);
@ -474,7 +530,7 @@ AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer,
}
AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer,
ALsizei offset, ALsizei frames,
ALsizei offset, ALsizei samples,
ALenum channels, ALenum type, const ALvoid *data)
{
ALCcontext *Context;
@ -485,35 +541,35 @@ AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer,
if(!Context) return;
device = Context->Device;
if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
if((ALBuf=LookupBuffer(device, buffer)) == NULL)
alSetError(Context, AL_INVALID_NAME);
else if(frames < 0 || offset < 0 || (frames > 0 && data == NULL))
else if(samples < 0 || offset < 0 || (samples > 0 && data == NULL))
alSetError(Context, AL_INVALID_VALUE);
else if(IsValidType(type) == AL_FALSE)
alSetError(Context, AL_INVALID_ENUM);
else
{
ALuint FrameSize;
ALuint FrameCount;
ALsizei FrameCount;
WriteLock(&ALBuf->lock);
FrameSize = FrameSizeFromFmt(ALBuf->FmtChannels, ALBuf->FmtType);
FrameCount = ALBuf->size / FrameSize;
if(channels != (ALenum)ALBuf->FmtChannels)
alSetError(Context, AL_INVALID_ENUM);
else if((ALuint)offset > FrameCount || (ALuint)frames > FrameCount-offset)
else if(offset > FrameCount || samples > FrameCount-offset)
alSetError(Context, AL_INVALID_VALUE);
else if(type == UserFmtIMA4 && (frames%65) != 0)
else if(type == UserFmtIMA4 && (samples%65) != 0)
alSetError(Context, AL_INVALID_VALUE);
else
{
/* offset -> byte offset */
offset *= FrameSize;
/* frames -> IMA4 block count */
if(type == UserFmtIMA4) frames /= 65;
/* samples -> IMA4 block count */
if(type == UserFmtIMA4) samples /= 65;
ConvertData(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType,
data, type,
ChannelsFromFmt(ALBuf->FmtChannels), frames);
ChannelsFromFmt(ALBuf->FmtChannels), samples);
}
WriteUnlock(&ALBuf->lock);
}
@ -522,7 +578,7 @@ AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer,
}
AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer,
ALsizei offset, ALsizei frames,
ALsizei offset, ALsizei samples,
ALenum channels, ALenum type, ALvoid *data)
{
ALCcontext *Context;
@ -533,35 +589,35 @@ AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer,
if(!Context) return;
device = Context->Device;
if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
if((ALBuf=LookupBuffer(device, buffer)) == NULL)
alSetError(Context, AL_INVALID_NAME);
else if(frames < 0 || offset < 0 || (frames > 0 && data == NULL))
else if(samples < 0 || offset < 0 || (samples > 0 && data == NULL))
alSetError(Context, AL_INVALID_VALUE);
else if(IsValidType(type) == AL_FALSE)
alSetError(Context, AL_INVALID_ENUM);
else
{
ALuint FrameSize;
ALuint FrameCount;
ALsizei FrameCount;
ReadLock(&ALBuf->lock);
FrameSize = FrameSizeFromFmt(ALBuf->FmtChannels, ALBuf->FmtType);
FrameCount = ALBuf->size / FrameSize;
if(channels != (ALenum)ALBuf->FmtChannels)
alSetError(Context, AL_INVALID_ENUM);
else if((ALuint)offset > FrameCount || (ALuint)frames > FrameCount-offset)
else if(offset > FrameCount || samples > FrameCount-offset)
alSetError(Context, AL_INVALID_VALUE);
else if(type == UserFmtIMA4 && (frames%65) != 0)
else if(type == UserFmtIMA4 && (samples%65) != 0)
alSetError(Context, AL_INVALID_VALUE);
else
{
/* offset -> byte offset */
offset *= FrameSize;
/* frames -> IMA4 block count */
if(type == UserFmtIMA4) frames /= 65;
/* samples -> IMA4 block count */
if(type == UserFmtIMA4) samples /= 65;
ConvertData(data, type,
&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType,
ChannelsFromFmt(ALBuf->FmtChannels), frames);
ChannelsFromFmt(ALBuf->FmtChannels), samples);
}
ReadUnlock(&ALBuf->lock);
}
@ -598,7 +654,7 @@ AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue)
if(!pContext) return;
device = pContext->Device;
if(LookupBuffer(device->BufferMap, buffer) == NULL)
if(LookupBuffer(device, buffer) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -627,7 +683,7 @@ AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum eParam, ALfloat flValue
if(!pContext) return;
device = pContext->Device;
if(LookupBuffer(device->BufferMap, buffer) == NULL)
if(LookupBuffer(device, buffer) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -654,7 +710,7 @@ AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum eParam, const ALfloat*
device = pContext->Device;
if(!flValues)
alSetError(pContext, AL_INVALID_VALUE);
else if(LookupBuffer(device->BufferMap, buffer) == NULL)
else if(LookupBuffer(device, buffer) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -681,7 +737,7 @@ AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum eParam, ALint lValue)
if(!pContext) return;
device = pContext->Device;
if(LookupBuffer(device->BufferMap, buffer) == NULL)
if(LookupBuffer(device, buffer) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -710,7 +766,7 @@ AL_API void AL_APIENTRY alBuffer3i( ALuint buffer, ALenum eParam, ALint lValue1,
if(!pContext) return;
device = pContext->Device;
if(LookupBuffer(device->BufferMap, buffer) == NULL)
if(LookupBuffer(device, buffer) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -738,7 +794,7 @@ AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum eParam, const ALint* pl
device = pContext->Device;
if(!plValues)
alSetError(pContext, AL_INVALID_VALUE);
else if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
else if((ALBuf=LookupBuffer(device, buffer)) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -780,6 +836,7 @@ AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pf
{
ALCcontext *pContext;
ALCdevice *device;
ALbuffer *pBuffer;
pContext = GetContextRef();
if(!pContext) return;
@ -787,12 +844,23 @@ AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pf
device = pContext->Device;
if(!pflValue)
alSetError(pContext, AL_INVALID_VALUE);
else if(LookupBuffer(device->BufferMap, buffer) == NULL)
else if((pBuffer=LookupBuffer(device, buffer)) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
switch(eParam)
{
case AL_SEC_LENGTH:
ReadLock(&pBuffer->lock);
if(pBuffer->size != 0)
*pflValue = (pBuffer->size /
FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType)) /
(ALfloat)pBuffer->Frequency;
else
*pflValue = 0.0f;
ReadUnlock(&pBuffer->lock);
break;
default:
alSetError(pContext, AL_INVALID_ENUM);
break;
@ -814,7 +882,7 @@ AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum eParam, ALfloat* pfl
device = pContext->Device;
if(!pflValue1 || !pflValue2 || !pflValue3)
alSetError(pContext, AL_INVALID_VALUE);
else if(LookupBuffer(device->BufferMap, buffer) == NULL)
else if(LookupBuffer(device, buffer) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -835,13 +903,20 @@ AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum eParam, ALfloat* pfl
ALCcontext *pContext;
ALCdevice *device;
switch(eParam)
{
case AL_SEC_LENGTH:
alGetBufferf(buffer, eParam, pflValues);
return;
}
pContext = GetContextRef();
if(!pContext) return;
device = pContext->Device;
if(!pflValues)
alSetError(pContext, AL_INVALID_VALUE);
else if(LookupBuffer(device->BufferMap, buffer) == NULL)
else if(LookupBuffer(device, buffer) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -869,7 +944,7 @@ AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plVa
device = pContext->Device;
if(!plValue)
alSetError(pContext, AL_INVALID_VALUE);
else if((pBuffer=LookupBuffer(device->BufferMap, buffer)) == NULL)
else if((pBuffer=LookupBuffer(device, buffer)) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -891,6 +966,24 @@ AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plVa
*plValue = pBuffer->size;
break;
case AL_INTERNAL_FORMAT:
*plValue = pBuffer->Format;
break;
case AL_BYTE_LENGTH:
*plValue = pBuffer->OriginalSize;
break;
case AL_SAMPLE_LENGTH:
ReadLock(&pBuffer->lock);
if(pBuffer->size != 0)
*plValue = pBuffer->size /
FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType);
else
*plValue = 0;
ReadUnlock(&pBuffer->lock);
break;
default:
alSetError(pContext, AL_INVALID_ENUM);
break;
@ -912,7 +1005,7 @@ AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum eParam, ALint* plVal
device = pContext->Device;
if(!plValue1 || !plValue2 || !plValue3)
alSetError(pContext, AL_INVALID_VALUE);
else if(LookupBuffer(device->BufferMap, buffer) == NULL)
else if(LookupBuffer(device, buffer) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -940,6 +1033,9 @@ AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plVal
case AL_BITS:
case AL_CHANNELS:
case AL_SIZE:
case AL_INTERNAL_FORMAT:
case AL_BYTE_LENGTH:
case AL_SAMPLE_LENGTH:
alGetBufferi(buffer, eParam, plValues);
return;
}
@ -950,7 +1046,7 @@ AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plVal
device = pContext->Device;
if(!plValues)
alSetError(pContext, AL_INVALID_VALUE);
else if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
else if((ALBuf=LookupBuffer(device, buffer)) == NULL)
alSetError(pContext, AL_INVALID_NAME);
else
{
@ -974,6 +1070,7 @@ AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plVal
typedef ALubyte ALmulaw;
typedef ALubyte ALalaw;
typedef ALubyte ALima4;
typedef struct {
ALbyte b[3];
@ -1007,6 +1104,35 @@ static ALmulaw EncodeMuLaw(ALshort val)
return ~(sign | (exp<<4) | mant);
}
static __inline ALshort DecodeALaw(ALalaw val)
{ return aLawDecompressionTable[val]; }
static ALalaw EncodeALaw(ALshort val)
{
ALint mant, exp, sign;
sign = ((~val) >> 8) & 0x80;
if(!sign)
{
val = maxi(val, -32767);
val = -val;
}
val = mini(val, aLawClip);
if(val >= 256)
{
exp = aLawCompressTable[(val>>8) & 0x7f];
mant = (val >> (exp+3)) & 0x0f;
}
else
{
exp = 0;
mant = val >> 4;
}
return ((exp<<4) | mant) ^ (sign^0x55);
}
static void DecodeIMA4Block(ALshort *dst, const ALima4 *src, ALint numchans)
{
ALint sample[MAXCHANNELS], index[MAXCHANNELS];
@ -1199,6 +1325,8 @@ static __inline ALbyte Conv_ALbyte_ALdouble(ALdouble val)
}
static __inline ALbyte Conv_ALbyte_ALmulaw(ALmulaw val)
{ return Conv_ALbyte_ALshort(DecodeMuLaw(val)); }
static __inline ALbyte Conv_ALbyte_ALalaw(ALalaw val)
{ return Conv_ALbyte_ALshort(DecodeALaw(val)); }
static __inline ALbyte Conv_ALbyte_ALbyte3(ALbyte3 val)
{ return DecodeByte3(val)>>16; }
static __inline ALbyte Conv_ALbyte_ALubyte3(ALubyte3 val)
@ -1230,6 +1358,8 @@ static __inline ALubyte Conv_ALubyte_ALdouble(ALdouble val)
}
static __inline ALubyte Conv_ALubyte_ALmulaw(ALmulaw val)
{ return Conv_ALubyte_ALshort(DecodeMuLaw(val)); }
static __inline ALubyte Conv_ALubyte_ALalaw(ALalaw val)
{ return Conv_ALubyte_ALshort(DecodeALaw(val)); }
static __inline ALubyte Conv_ALubyte_ALbyte3(ALbyte3 val)
{ return (DecodeByte3(val)>>16)+128; }
static __inline ALubyte Conv_ALubyte_ALubyte3(ALubyte3 val)
@ -1261,6 +1391,8 @@ static __inline ALshort Conv_ALshort_ALdouble(ALdouble val)
}
static __inline ALshort Conv_ALshort_ALmulaw(ALmulaw val)
{ return Conv_ALshort_ALshort(DecodeMuLaw(val)); }
static __inline ALshort Conv_ALshort_ALalaw(ALalaw val)
{ return Conv_ALshort_ALshort(DecodeALaw(val)); }
static __inline ALshort Conv_ALshort_ALbyte3(ALbyte3 val)
{ return DecodeByte3(val)>>8; }
static __inline ALshort Conv_ALshort_ALubyte3(ALubyte3 val)
@ -1292,6 +1424,8 @@ static __inline ALushort Conv_ALushort_ALdouble(ALdouble val)
}
static __inline ALushort Conv_ALushort_ALmulaw(ALmulaw val)
{ return Conv_ALushort_ALshort(DecodeMuLaw(val)); }
static __inline ALushort Conv_ALushort_ALalaw(ALalaw val)
{ return Conv_ALushort_ALshort(DecodeALaw(val)); }
static __inline ALushort Conv_ALushort_ALbyte3(ALbyte3 val)
{ return (DecodeByte3(val)>>8)+32768; }
static __inline ALushort Conv_ALushort_ALubyte3(ALubyte3 val)
@ -1323,6 +1457,8 @@ static __inline ALint Conv_ALint_ALdouble(ALdouble val)
}
static __inline ALint Conv_ALint_ALmulaw(ALmulaw val)
{ return Conv_ALint_ALshort(DecodeMuLaw(val)); }
static __inline ALint Conv_ALint_ALalaw(ALalaw val)
{ return Conv_ALint_ALshort(DecodeALaw(val)); }
static __inline ALint Conv_ALint_ALbyte3(ALbyte3 val)
{ return DecodeByte3(val)<<8; }
static __inline ALint Conv_ALint_ALubyte3(ALubyte3 val)
@ -1354,6 +1490,8 @@ static __inline ALuint Conv_ALuint_ALdouble(ALdouble val)
}
static __inline ALuint Conv_ALuint_ALmulaw(ALmulaw val)
{ return Conv_ALuint_ALshort(DecodeMuLaw(val)); }
static __inline ALuint Conv_ALuint_ALalaw(ALalaw val)
{ return Conv_ALuint_ALshort(DecodeALaw(val)); }
static __inline ALuint Conv_ALuint_ALbyte3(ALbyte3 val)
{ return (DecodeByte3(val)+8388608)<<8; }
static __inline ALuint Conv_ALuint_ALubyte3(ALubyte3 val)
@ -1368,19 +1506,21 @@ static __inline ALfloat Conv_ALfloat_ALshort(ALshort val)
static __inline ALfloat Conv_ALfloat_ALushort(ALushort val)
{ return (val-32768) * (1.0f/32767.0f); }
static __inline ALfloat Conv_ALfloat_ALint(ALint val)
{ return val * (1.0/2147483647.0); }
{ return (ALfloat)(val * (1.0/2147483647.0)); }
static __inline ALfloat Conv_ALfloat_ALuint(ALuint val)
{ return (ALint)(val-2147483648u) * (1.0/2147483647.0); }
{ return (ALfloat)((ALint)(val-2147483648u) * (1.0/2147483647.0)); }
static __inline ALfloat Conv_ALfloat_ALfloat(ALfloat val)
{ return (val==val) ? val : 0.0f; }
static __inline ALfloat Conv_ALfloat_ALdouble(ALdouble val)
{ return (val==val) ? val : 0.0; }
{ return (val==val) ? (ALfloat)val : 0.0f; }
static __inline ALfloat Conv_ALfloat_ALmulaw(ALmulaw val)
{ return Conv_ALfloat_ALshort(DecodeMuLaw(val)); }
static __inline ALfloat Conv_ALfloat_ALalaw(ALalaw val)
{ return Conv_ALfloat_ALshort(DecodeALaw(val)); }
static __inline ALfloat Conv_ALfloat_ALbyte3(ALbyte3 val)
{ return DecodeByte3(val) * (1.0/8388607.0); }
{ return (ALfloat)(DecodeByte3(val) * (1.0/8388607.0)); }
static __inline ALfloat Conv_ALfloat_ALubyte3(ALubyte3 val)
{ return (DecodeUByte3(val)-8388608) * (1.0/8388607.0); }
{ return (ALfloat)((DecodeUByte3(val)-8388608) * (1.0/8388607.0)); }
static __inline ALdouble Conv_ALdouble_ALbyte(ALbyte val)
{ return val * (1.0/127.0); }
@ -1400,6 +1540,8 @@ static __inline ALdouble Conv_ALdouble_ALdouble(ALdouble val)
{ return (val==val) ? val : 0.0; }
static __inline ALdouble Conv_ALdouble_ALmulaw(ALmulaw val)
{ return Conv_ALdouble_ALshort(DecodeMuLaw(val)); }
static __inline ALdouble Conv_ALdouble_ALalaw(ALalaw val)
{ return Conv_ALdouble_ALshort(DecodeALaw(val)); }
static __inline ALdouble Conv_ALdouble_ALbyte3(ALbyte3 val)
{ return DecodeByte3(val) * (1.0/8388607.0); }
static __inline ALdouble Conv_ALdouble_ALubyte3(ALubyte3 val)
@ -1419,6 +1561,27 @@ DECL_TEMPLATE(ALfloat)
DECL_TEMPLATE(ALdouble)
static __inline ALmulaw Conv_ALmulaw_ALmulaw(ALmulaw val)
{ return val; }
DECL_TEMPLATE(ALalaw)
DECL_TEMPLATE(ALbyte3)
DECL_TEMPLATE(ALubyte3)
#undef DECL_TEMPLATE
#define DECL_TEMPLATE(T) \
static __inline ALalaw Conv_ALalaw_##T(T val) \
{ return EncodeALaw(Conv_ALshort_##T(val)); }
DECL_TEMPLATE(ALbyte)
DECL_TEMPLATE(ALubyte)
DECL_TEMPLATE(ALshort)
DECL_TEMPLATE(ALushort)
DECL_TEMPLATE(ALint)
DECL_TEMPLATE(ALuint)
DECL_TEMPLATE(ALfloat)
DECL_TEMPLATE(ALdouble)
DECL_TEMPLATE(ALmulaw)
static __inline ALalaw Conv_ALalaw_ALalaw(ALalaw val)
{ return val; }
DECL_TEMPLATE(ALbyte3)
DECL_TEMPLATE(ALubyte3)
@ -1437,6 +1600,7 @@ DECL_TEMPLATE(ALuint)
DECL_TEMPLATE(ALfloat)
DECL_TEMPLATE(ALdouble)
DECL_TEMPLATE(ALmulaw)
DECL_TEMPLATE(ALalaw)
static __inline ALbyte3 Conv_ALbyte3_ALbyte3(ALbyte3 val)
{ return val; }
DECL_TEMPLATE(ALubyte3)
@ -1456,6 +1620,7 @@ DECL_TEMPLATE(ALuint)
DECL_TEMPLATE(ALfloat)
DECL_TEMPLATE(ALdouble)
DECL_TEMPLATE(ALmulaw)
DECL_TEMPLATE(ALalaw)
DECL_TEMPLATE(ALbyte3)
static __inline ALubyte3 Conv_ALubyte3_ALubyte3(ALubyte3 val)
{ return val; }
@ -1484,6 +1649,7 @@ DECL_TEMPLATE(ALbyte, ALuint)
DECL_TEMPLATE(ALbyte, ALfloat)
DECL_TEMPLATE(ALbyte, ALdouble)
DECL_TEMPLATE(ALbyte, ALmulaw)
DECL_TEMPLATE(ALbyte, ALalaw)
DECL_TEMPLATE(ALbyte, ALbyte3)
DECL_TEMPLATE(ALbyte, ALubyte3)
@ -1496,6 +1662,7 @@ DECL_TEMPLATE(ALubyte, ALuint)
DECL_TEMPLATE(ALubyte, ALfloat)
DECL_TEMPLATE(ALubyte, ALdouble)
DECL_TEMPLATE(ALubyte, ALmulaw)
DECL_TEMPLATE(ALubyte, ALalaw)
DECL_TEMPLATE(ALubyte, ALbyte3)
DECL_TEMPLATE(ALubyte, ALubyte3)
@ -1508,6 +1675,7 @@ DECL_TEMPLATE(ALshort, ALuint)
DECL_TEMPLATE(ALshort, ALfloat)
DECL_TEMPLATE(ALshort, ALdouble)
DECL_TEMPLATE(ALshort, ALmulaw)
DECL_TEMPLATE(ALshort, ALalaw)
DECL_TEMPLATE(ALshort, ALbyte3)
DECL_TEMPLATE(ALshort, ALubyte3)
@ -1520,6 +1688,7 @@ DECL_TEMPLATE(ALushort, ALuint)
DECL_TEMPLATE(ALushort, ALfloat)
DECL_TEMPLATE(ALushort, ALdouble)
DECL_TEMPLATE(ALushort, ALmulaw)
DECL_TEMPLATE(ALushort, ALalaw)
DECL_TEMPLATE(ALushort, ALbyte3)
DECL_TEMPLATE(ALushort, ALubyte3)
@ -1532,6 +1701,7 @@ DECL_TEMPLATE(ALint, ALuint)
DECL_TEMPLATE(ALint, ALfloat)
DECL_TEMPLATE(ALint, ALdouble)
DECL_TEMPLATE(ALint, ALmulaw)
DECL_TEMPLATE(ALint, ALalaw)
DECL_TEMPLATE(ALint, ALbyte3)
DECL_TEMPLATE(ALint, ALubyte3)
@ -1544,6 +1714,7 @@ DECL_TEMPLATE(ALuint, ALuint)
DECL_TEMPLATE(ALuint, ALfloat)
DECL_TEMPLATE(ALuint, ALdouble)
DECL_TEMPLATE(ALuint, ALmulaw)
DECL_TEMPLATE(ALuint, ALalaw)
DECL_TEMPLATE(ALuint, ALbyte3)
DECL_TEMPLATE(ALuint, ALubyte3)
@ -1556,6 +1727,7 @@ DECL_TEMPLATE(ALfloat, ALuint)
DECL_TEMPLATE(ALfloat, ALfloat)
DECL_TEMPLATE(ALfloat, ALdouble)
DECL_TEMPLATE(ALfloat, ALmulaw)
DECL_TEMPLATE(ALfloat, ALalaw)
DECL_TEMPLATE(ALfloat, ALbyte3)
DECL_TEMPLATE(ALfloat, ALubyte3)
@ -1568,6 +1740,7 @@ DECL_TEMPLATE(ALdouble, ALuint)
DECL_TEMPLATE(ALdouble, ALfloat)
DECL_TEMPLATE(ALdouble, ALdouble)
DECL_TEMPLATE(ALdouble, ALmulaw)
DECL_TEMPLATE(ALdouble, ALalaw)
DECL_TEMPLATE(ALdouble, ALbyte3)
DECL_TEMPLATE(ALdouble, ALubyte3)
@ -1580,9 +1753,23 @@ DECL_TEMPLATE(ALmulaw, ALuint)
DECL_TEMPLATE(ALmulaw, ALfloat)
DECL_TEMPLATE(ALmulaw, ALdouble)
DECL_TEMPLATE(ALmulaw, ALmulaw)
DECL_TEMPLATE(ALmulaw, ALalaw)
DECL_TEMPLATE(ALmulaw, ALbyte3)
DECL_TEMPLATE(ALmulaw, ALubyte3)
DECL_TEMPLATE(ALalaw, ALbyte)
DECL_TEMPLATE(ALalaw, ALubyte)
DECL_TEMPLATE(ALalaw, ALshort)
DECL_TEMPLATE(ALalaw, ALushort)
DECL_TEMPLATE(ALalaw, ALint)
DECL_TEMPLATE(ALalaw, ALuint)
DECL_TEMPLATE(ALalaw, ALfloat)
DECL_TEMPLATE(ALalaw, ALdouble)
DECL_TEMPLATE(ALalaw, ALmulaw)
DECL_TEMPLATE(ALalaw, ALalaw)
DECL_TEMPLATE(ALalaw, ALbyte3)
DECL_TEMPLATE(ALalaw, ALubyte3)
DECL_TEMPLATE(ALbyte3, ALbyte)
DECL_TEMPLATE(ALbyte3, ALubyte)
DECL_TEMPLATE(ALbyte3, ALshort)
@ -1592,6 +1779,7 @@ DECL_TEMPLATE(ALbyte3, ALuint)
DECL_TEMPLATE(ALbyte3, ALfloat)
DECL_TEMPLATE(ALbyte3, ALdouble)
DECL_TEMPLATE(ALbyte3, ALmulaw)
DECL_TEMPLATE(ALbyte3, ALalaw)
DECL_TEMPLATE(ALbyte3, ALbyte3)
DECL_TEMPLATE(ALbyte3, ALubyte3)
@ -1604,6 +1792,7 @@ DECL_TEMPLATE(ALubyte3, ALuint)
DECL_TEMPLATE(ALubyte3, ALfloat)
DECL_TEMPLATE(ALubyte3, ALdouble)
DECL_TEMPLATE(ALubyte3, ALmulaw)
DECL_TEMPLATE(ALubyte3, ALalaw)
DECL_TEMPLATE(ALubyte3, ALbyte3)
DECL_TEMPLATE(ALubyte3, ALubyte3)
@ -1633,6 +1822,7 @@ DECL_TEMPLATE(ALuint)
DECL_TEMPLATE(ALfloat)
DECL_TEMPLATE(ALdouble)
DECL_TEMPLATE(ALmulaw)
DECL_TEMPLATE(ALalaw)
DECL_TEMPLATE(ALbyte3)
DECL_TEMPLATE(ALubyte3)
@ -1664,6 +1854,7 @@ DECL_TEMPLATE(ALuint)
DECL_TEMPLATE(ALfloat)
DECL_TEMPLATE(ALdouble)
DECL_TEMPLATE(ALmulaw)
DECL_TEMPLATE(ALalaw)
static void Convert_ALima4_ALima4(ALima4 *dst, const ALima4 *src,
ALuint numchans, ALuint numblocks)
{ memcpy(dst, src, numblocks*36*numchans); }
@ -1705,6 +1896,9 @@ static void Convert_##T(T *dst, const ALvoid *src, enum UserFmtType srcType, \
case UserFmtMulaw: \
Convert_##T##_ALmulaw(dst, src, numchans, len); \
break; \
case UserFmtAlaw: \
Convert_##T##_ALalaw(dst, src, numchans, len); \
break; \
case UserFmtIMA4: \
Convert_##T##_ALima4(dst, src, numchans, len); \
break; \
@ -1726,6 +1920,7 @@ DECL_TEMPLATE(ALuint)
DECL_TEMPLATE(ALfloat)
DECL_TEMPLATE(ALdouble)
DECL_TEMPLATE(ALmulaw)
DECL_TEMPLATE(ALalaw)
DECL_TEMPLATE(ALima4)
DECL_TEMPLATE(ALbyte3)
DECL_TEMPLATE(ALubyte3)
@ -1764,6 +1959,9 @@ static void ConvertData(ALvoid *dst, enum UserFmtType dstType, const ALvoid *src
case UserFmtMulaw:
Convert_ALmulaw(dst, src, srcType, numchans, len);
break;
case UserFmtAlaw:
Convert_ALalaw(dst, src, srcType, numchans, len);
break;
case UserFmtIMA4:
Convert_ALima4(dst, src, srcType, numchans, len);
break;
@ -1823,14 +2021,14 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f
return AL_OUT_OF_MEMORY;
}
temp = realloc(ALBuf->data, newsize);
temp = realloc(ALBuf->data, (size_t)newsize);
if(!temp && newsize)
{
WriteUnlock(&ALBuf->lock);
return AL_OUT_OF_MEMORY;
}
ALBuf->data = temp;
ALBuf->size = newsize;
ALBuf->size = (ALsizei)newsize;
if(data != NULL)
ConvertData(ALBuf->data, DstType, data, SrcType, NewChannels, frames);
@ -1840,7 +2038,6 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f
ALBuf->OriginalChannels = SrcChannels;
ALBuf->OriginalType = SrcType;
ALBuf->OriginalSize = frames * 36 * OrigChannels;
ALBuf->OriginalAlign = 36 * OrigChannels;
}
}
else
@ -1857,14 +2054,14 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f
return AL_OUT_OF_MEMORY;
}
temp = realloc(ALBuf->data, newsize);
temp = realloc(ALBuf->data, (size_t)newsize);
if(!temp && newsize)
{
WriteUnlock(&ALBuf->lock);
return AL_OUT_OF_MEMORY;
}
ALBuf->data = temp;
ALBuf->size = newsize;
ALBuf->size = (ALsizei)newsize;
if(data != NULL)
ConvertData(ALBuf->data, DstType, data, SrcType, NewChannels, frames);
@ -1874,7 +2071,6 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f
ALBuf->OriginalChannels = SrcChannels;
ALBuf->OriginalType = SrcType;
ALBuf->OriginalSize = frames * OrigBytes * OrigChannels;
ALBuf->OriginalAlign = OrigBytes * OrigChannels;
}
}
@ -1883,14 +2079,14 @@ static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei f
ALBuf->OriginalChannels = DstChannels;
ALBuf->OriginalType = DstType;
ALBuf->OriginalSize = frames * NewBytes * NewChannels;
ALBuf->OriginalAlign = NewBytes * NewChannels;
}
ALBuf->Frequency = freq;
ALBuf->FmtChannels = DstChannels;
ALBuf->FmtType = DstType;
ALBuf->Format = NewFormat;
ALBuf->LoopStart = 0;
ALBuf->LoopEnd = newsize / NewChannels / NewBytes;
ALBuf->LoopEnd = (ALsizei)(newsize / NewChannels / NewBytes);
WriteUnlock(&ALBuf->lock);
return AL_NO_ERROR;
@ -1912,6 +2108,7 @@ ALuint BytesFromUserFmt(enum UserFmtType type)
case UserFmtByte3: return sizeof(ALbyte3);
case UserFmtUByte3: return sizeof(ALubyte3);
case UserFmtMulaw: return sizeof(ALubyte);
case UserFmtAlaw: return sizeof(ALubyte);
case UserFmtIMA4: break; /* not handled here */
}
return 0;
@ -1944,6 +2141,7 @@ static ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans,
{ AL_FORMAT_MONO_DOUBLE_EXT, UserFmtMono, UserFmtDouble },
{ AL_FORMAT_MONO_IMA4, UserFmtMono, UserFmtIMA4 },
{ AL_FORMAT_MONO_MULAW, UserFmtMono, UserFmtMulaw },
{ AL_FORMAT_MONO_ALAW_EXT, UserFmtMono, UserFmtAlaw },
{ AL_FORMAT_STEREO8, UserFmtStereo, UserFmtUByte },
{ AL_FORMAT_STEREO16, UserFmtStereo, UserFmtShort },
@ -1951,6 +2149,7 @@ static ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans,
{ AL_FORMAT_STEREO_DOUBLE_EXT, UserFmtStereo, UserFmtDouble },
{ AL_FORMAT_STEREO_IMA4, UserFmtStereo, UserFmtIMA4 },
{ AL_FORMAT_STEREO_MULAW, UserFmtStereo, UserFmtMulaw },
{ AL_FORMAT_STEREO_ALAW_EXT, UserFmtStereo, UserFmtAlaw },
{ AL_FORMAT_REAR8, UserFmtRear, UserFmtUByte },
{ AL_FORMAT_REAR16, UserFmtRear, UserFmtShort },
@ -2086,6 +2285,7 @@ static ALboolean IsValidType(ALenum type)
case AL_FLOAT:
case AL_DOUBLE:
case AL_MULAW:
case AL_ALAW:
case AL_IMA4:
case AL_BYTE3:
case AL_UNSIGNED_BYTE3:

View File

@ -36,8 +36,6 @@ ALboolean DisabledEffects[MAX_EFFECTS];
static void InitEffectParams(ALeffect *effect, ALenum type);
#define LookupEffect(m, k) ((ALeffect*)LookupUIntMapKey(&(m), (k)))
#define RemoveEffect(m, k) ((ALeffect*)PopUIntMapValue(&(m), (k)))
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
{
@ -86,7 +84,7 @@ AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects)
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects)
AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects)
{
ALCcontext *Context;
ALCdevice *device;
@ -107,7 +105,7 @@ AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects)
if(!effects[i])
continue;
if(LookupEffect(device->EffectMap, effects[i]) == NULL)
if(LookupEffect(device, effects[i]) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
n = 0;
@ -118,7 +116,7 @@ AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects)
for(i = 0;i < n;i++)
{
// Recheck that the effect is valid, because there could be duplicated names
if((ALEffect=RemoveEffect(device->EffectMap, effects[i])) == NULL)
if((ALEffect=RemoveEffect(device, effects[i])) == NULL)
continue;
FreeThunkEntry(ALEffect->effect);
@ -138,7 +136,7 @@ AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect)
Context = GetContextRef();
if(!Context) return AL_FALSE;
result = ((!effect || LookupEffect(Context->Device->EffectMap, effect)) ?
result = ((!effect || LookupEffect(Context->Device, effect)) ?
AL_TRUE : AL_FALSE);
ALCcontext_DecRef(Context);
@ -156,7 +154,7 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
if(!Context) return;
Device = Context->Device;
if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
if((ALEffect=LookupEffect(Device, effect)) != NULL)
{
if(param == AL_EFFECT_TYPE)
{
@ -186,7 +184,7 @@ AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue)
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues)
AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues)
{
ALCcontext *Context;
ALCdevice *Device;
@ -196,7 +194,7 @@ AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValue
if(!Context) return;
Device = Context->Device;
if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
if((ALEffect=LookupEffect(Device, effect)) != NULL)
{
/* Call the appropriate handler */
ALeffect_SetParamiv(ALEffect, Context, param, piValues);
@ -217,7 +215,7 @@ AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue
if(!Context) return;
Device = Context->Device;
if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
if((ALEffect=LookupEffect(Device, effect)) != NULL)
{
/* Call the appropriate handler */
ALeffect_SetParamf(ALEffect, Context, param, flValue);
@ -228,7 +226,7 @@ AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflValues)
AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues)
{
ALCcontext *Context;
ALCdevice *Device;
@ -238,7 +236,7 @@ AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflVa
if(!Context) return;
Device = Context->Device;
if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
if((ALEffect=LookupEffect(Device, effect)) != NULL)
{
/* Call the appropriate handler */
ALeffect_SetParamfv(ALEffect, Context, param, pflValues);
@ -259,7 +257,7 @@ AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piVal
if(!Context) return;
Device = Context->Device;
if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
if((ALEffect=LookupEffect(Device, effect)) != NULL)
{
if(param == AL_EFFECT_TYPE)
{
@ -287,7 +285,7 @@ AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piVa
if(!Context) return;
Device = Context->Device;
if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
if((ALEffect=LookupEffect(Device, effect)) != NULL)
{
/* Call the appropriate handler */
ALeffect_GetParamiv(ALEffect, Context, param, piValues);
@ -308,7 +306,7 @@ AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pfl
if(!Context) return;
Device = Context->Device;
if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
if((ALEffect=LookupEffect(Device, effect)) != NULL)
{
/* Call the appropriate handler */
ALeffect_GetParamf(ALEffect, Context, param, pflValue);
@ -329,7 +327,7 @@ AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pf
if(!Context) return;
Device = Context->Device;
if((ALEffect=LookupEffect(Device->EffectMap, effect)) != NULL)
if((ALEffect=LookupEffect(Device, effect)) != NULL)
{
/* Call the appropriate handler */
ALeffect_GetParamfv(ALEffect, Context, param, pflValues);
@ -1003,43 +1001,6 @@ static void echo_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param,
}
static void mod_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val)
{
switch(param)
{
case AL_RING_MODULATOR_FREQUENCY:
if(val >= AL_RING_MODULATOR_MIN_FREQUENCY &&
val <= AL_RING_MODULATOR_MAX_FREQUENCY)
effect->Modulator.Frequency = val;
else
alSetError(context, AL_INVALID_VALUE);
break;
case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
if(val >= AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF &&
val <= AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF)
effect->Modulator.HighPassCutoff = val;
else
alSetError(context, AL_INVALID_VALUE);
break;
case AL_RING_MODULATOR_WAVEFORM:
if(val >= AL_RING_MODULATOR_MIN_WAVEFORM &&
val <= AL_RING_MODULATOR_MAX_WAVEFORM)
effect->Modulator.Waveform = val;
else
alSetError(context, AL_INVALID_VALUE);
break;
default:
alSetError(context, AL_INVALID_ENUM);
break;
}
}
static void mod_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals)
{
mod_SetParami(effect, context, param, vals[0]);
}
static void mod_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val)
{
switch(param)
@ -1069,6 +1030,32 @@ static void mod_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param,
{
mod_SetParamf(effect, context, param, vals[0]);
}
static void mod_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val)
{
switch(param)
{
case AL_RING_MODULATOR_FREQUENCY:
case AL_RING_MODULATOR_HIGHPASS_CUTOFF:
mod_SetParamf(effect, context, param, (ALfloat)val);
break;
case AL_RING_MODULATOR_WAVEFORM:
if(val >= AL_RING_MODULATOR_MIN_WAVEFORM &&
val <= AL_RING_MODULATOR_MAX_WAVEFORM)
effect->Modulator.Waveform = val;
else
alSetError(context, AL_INVALID_VALUE);
break;
default:
alSetError(context, AL_INVALID_ENUM);
break;
}
}
static void mod_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals)
{
mod_SetParami(effect, context, param, vals[0]);
}
static void mod_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val)
{

View File

@ -52,7 +52,7 @@ ALvoid alSetError(ALCcontext *Context, ALenum errorCode)
if(IsDebuggerPresent())
DebugBreak();
#elif defined(SIGTRAP)
kill(getpid(), SIGTRAP);
raise(SIGTRAP);
#endif
}
CompExchangeInt(&Context->LastError, AL_NO_ERROR, errorCode);

View File

@ -127,14 +127,16 @@ static const ALenums enumeration[] = {
{ "AL_FORMAT_REAR16", AL_FORMAT_REAR16 },
{ "AL_FORMAT_REAR32", AL_FORMAT_REAR32 },
{ "AL_FORMAT_MONO_MULAW", AL_FORMAT_MONO_MULAW },
{ "AL_FORMAT_MONO_MULAW_EXT", AL_FORMAT_MONO_MULAW },
{ "AL_FORMAT_MONO_MULAW_EXT", AL_FORMAT_MONO_MULAW_EXT },
{ "AL_FORMAT_STEREO_MULAW", AL_FORMAT_STEREO_MULAW },
{ "AL_FORMAT_STEREO_MULAW_EXT", AL_FORMAT_STEREO_MULAW },
{ "AL_FORMAT_STEREO_MULAW_EXT", AL_FORMAT_STEREO_MULAW_EXT },
{ "AL_FORMAT_QUAD_MULAW", AL_FORMAT_QUAD_MULAW },
{ "AL_FORMAT_51CHN_MULAW", AL_FORMAT_51CHN_MULAW },
{ "AL_FORMAT_61CHN_MULAW", AL_FORMAT_61CHN_MULAW },
{ "AL_FORMAT_71CHN_MULAW", AL_FORMAT_71CHN_MULAW },
{ "AL_FORMAT_REAR_MULAW", AL_FORMAT_REAR_MULAW },
{ "AL_FORMAT_MONO_ALAW_EXT", AL_FORMAT_MONO_ALAW_EXT },
{ "AL_FORMAT_STEREO_ALAW_EXT", AL_FORMAT_STEREO_ALAW_EXT },
// Internal Buffer Formats
{ "AL_MONO8", AL_MONO8 },
@ -178,6 +180,7 @@ static const ALenums enumeration[] = {
{ "AL_FLOAT", AL_FLOAT },
{ "AL_DOUBLE", AL_DOUBLE },
{ "AL_MULAW", AL_MULAW },
{ "AL_ALAW", AL_ALAW },
{ "AL_IMA4", AL_IMA4 },
{ "AL_BYTE3", AL_BYTE3 },
{ "AL_UNSIGNED_BYTE3", AL_UNSIGNED_BYTE3 },
@ -187,6 +190,10 @@ static const ALenums enumeration[] = {
{ "AL_BITS", AL_BITS },
{ "AL_CHANNELS", AL_CHANNELS },
{ "AL_SIZE", AL_SIZE },
{ "AL_INTERNAL_FORMAT", AL_INTERNAL_FORMAT },
{ "AL_BYTE_LENGTH", AL_BYTE_LENGTH },
{ "AL_SAMPLE_LENGTH", AL_SAMPLE_LENGTH },
{ "AL_SEC_LENGTH", AL_SEC_LENGTH },
// Buffer States (not supported yet)
{ "AL_UNUSED", AL_UNUSED },

View File

@ -32,8 +32,6 @@
static void InitFilterParams(ALfilter *filter, ALenum type);
#define LookupFilter(m, k) ((ALfilter*)LookupUIntMapKey(&(m), (k)))
#define RemoveFilter(m, k) ((ALfilter*)PopUIntMapValue(&(m), (k)))
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
{
@ -82,7 +80,7 @@ AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters)
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters)
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters)
{
ALCcontext *Context;
ALCdevice *device;
@ -103,7 +101,7 @@ AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters)
if(!filters[i])
continue;
if(LookupFilter(device->FilterMap, filters[i]) == NULL)
if(LookupFilter(device, filters[i]) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
n = 0;
@ -114,7 +112,7 @@ AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters)
for(i = 0;i < n;i++)
{
// Recheck that the filter is valid, because there could be duplicated names
if((ALFilter=RemoveFilter(device->FilterMap, filters[i])) == NULL)
if((ALFilter=RemoveFilter(device, filters[i])) == NULL)
continue;
FreeThunkEntry(ALFilter->filter);
@ -134,7 +132,7 @@ AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter)
Context = GetContextRef();
if(!Context) return AL_FALSE;
result = ((!filter || LookupFilter(Context->Device->FilterMap, filter)) ?
result = ((!filter || LookupFilter(Context->Device, filter)) ?
AL_TRUE : AL_FALSE);
ALCcontext_DecRef(Context);
@ -152,7 +150,7 @@ AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue)
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
switch(param)
{
@ -175,7 +173,7 @@ AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue)
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValues)
AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues)
{
ALCcontext *Context;
ALCdevice *Device;
@ -192,7 +190,7 @@ AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValue
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_SetParamiv(ALFilter, Context, param, piValues);
@ -213,7 +211,7 @@ AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_SetParamf(ALFilter, Context, param, flValue);
@ -224,7 +222,7 @@ AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue
ALCcontext_DecRef(Context);
}
AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflValues)
AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues)
{
ALCcontext *Context;
ALCdevice *Device;
@ -234,7 +232,7 @@ AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflVa
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_SetParamfv(ALFilter, Context, param, pflValues);
@ -255,7 +253,7 @@ AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piVal
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
switch(param)
{
@ -292,7 +290,7 @@ AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piVa
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_GetParamiv(ALFilter, Context, param, piValues);
@ -313,7 +311,7 @@ AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pfl
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_GetParamf(ALFilter, Context, param, pflValue);
@ -334,7 +332,7 @@ AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pf
if(!Context) return;
Device = Context->Device;
if((ALFilter=LookupFilter(Device->FilterMap, filter)) != NULL)
if((ALFilter=LookupFilter(Device, filter)) != NULL)
{
/* Call the appropriate handler */
ALfilter_GetParamfv(ALFilter, Context, param, pflValues);
@ -350,11 +348,11 @@ ALfloat lpCoeffCalc(ALfloat g, ALfloat cw)
{
ALfloat a = 0.0f;
/* Be careful with gains < 0.01, as that causes the coefficient
* head towards 1, which will flatten the signal */
/* Be careful with gains < 0.001, as that causes the coefficient head
* towards 1, which will flatten the signal */
if(g < 0.9999f) /* 1-epsilon */
{
g = maxf(g, 0.01f);
g = maxf(g, 0.001f);
a = (1 - g*cw - aluSqrt(2*g*(1-cw) - g*g*(1 - cw*cw))) /
(1 - g);
}

View File

@ -226,7 +226,7 @@ AL_API void AL_APIENTRY alListeneriv( ALenum eParam, const ALint* plValues )
{
case AL_POSITION:
case AL_VELOCITY:
alListener3f(eParam, plValues[0], plValues[1], plValues[2]);
alListener3f(eParam, (ALfloat)plValues[0], (ALfloat)plValues[1], (ALfloat)plValues[2]);
return;
case AL_ORIENTATION:

View File

@ -50,11 +50,6 @@ static ALvoid InitSourceParams(ALsource *Source);
static ALvoid GetSourceOffset(ALsource *Source, ALenum eName, ALdouble *Offsets, ALdouble updateLen);
static ALint GetByteOffset(ALsource *Source);
#define LookupSource(m, k) ((ALsource*)LookupUIntMapKey(&(m), (k)))
#define RemoveSource(m, k) ((ALsource*)PopUIntMapValue(&(m), (k)))
#define LookupBuffer(m, k) ((ALbuffer*)LookupUIntMapKey(&(m), (k)))
#define LookupFilter(m, k) ((ALfilter*)LookupUIntMapKey(&(m), (k)))
#define LookupEffectSlot(m, k) ((ALeffectslot*)LookupUIntMapKey(&(m), (k)))
AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources)
{
@ -124,7 +119,7 @@ AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
// Check that all Sources are valid (and can therefore be deleted)
for(i = 0;i < n;i++)
{
if(LookupSource(Context->SourceMap, sources[i]) == NULL)
if(LookupSource(Context, sources[i]) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
n = 0;
@ -138,7 +133,7 @@ AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources)
ALsource **srclist, **srclistend;
// Remove Source from list of Sources
if((Source=RemoveSource(Context->SourceMap, sources[i])) == NULL)
if((Source=RemoveSource(Context, sources[i])) == NULL)
continue;
FreeThunkEntry(Source->source);
@ -193,7 +188,7 @@ AL_API ALboolean AL_APIENTRY alIsSource(ALuint source)
Context = GetContextRef();
if(!Context) return AL_FALSE;
result = (LookupSource(Context->SourceMap, source) ? AL_TRUE : AL_FALSE);
result = (LookupSource(Context, source) ? AL_TRUE : AL_FALSE);
ALCcontext_DecRef(Context);
@ -209,7 +204,7 @@ AL_API ALvoid AL_APIENTRY alSourcef(ALuint source, ALenum eParam, ALfloat flValu
pContext = GetContextRef();
if(!pContext) return;
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
switch(eParam)
{
@ -402,7 +397,7 @@ AL_API ALvoid AL_APIENTRY alSource3f(ALuint source, ALenum eParam, ALfloat flVal
pContext = GetContextRef();
if(!pContext) return;
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
switch(eParam)
{
@ -500,7 +495,7 @@ AL_API ALvoid AL_APIENTRY alSourcefv(ALuint source, ALenum eParam, const ALfloat
if(pflValues)
{
if(LookupSource(pContext->SourceMap, source) != NULL)
if(LookupSource(pContext, source) != NULL)
{
switch(eParam)
{
@ -539,7 +534,7 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
pContext = GetContextRef();
if(!pContext) return;
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
ALCdevice *device = pContext->Device;
@ -569,8 +564,7 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
ALbufferlistitem *oldlist;
ALbuffer *buffer = NULL;
if(lValue == 0 ||
(buffer=LookupBuffer(device->BufferMap, lValue)) != NULL)
if(lValue == 0 || (buffer=LookupBuffer(device, lValue)) != NULL)
{
Source->BuffersInQueue = 0;
Source->BuffersPlayed = 0;
@ -662,8 +656,7 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
case AL_DIRECT_FILTER: {
ALfilter *filter = NULL;
if(lValue == 0 ||
(filter=LookupFilter(pContext->Device->FilterMap, lValue)) != NULL)
if(lValue == 0 || (filter=LookupFilter(pContext->Device, lValue)) != NULL)
{
LockContext(pContext);
if(!filter)
@ -769,7 +762,7 @@ AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1,
pContext = GetContextRef();
if(!pContext) return;
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
ALCdevice *device = pContext->Device;
@ -781,10 +774,8 @@ AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1,
LockContext(pContext);
if((ALuint)lValue2 < device->NumAuxSends &&
(lValue1 == 0 ||
(ALEffectSlot=LookupEffectSlot(pContext->EffectSlotMap, lValue1)) != NULL) &&
(lValue3 == 0 ||
(ALFilter=LookupFilter(device->FilterMap, lValue3)) != NULL))
(lValue1 == 0 || (ALEffectSlot=LookupEffectSlot(pContext, lValue1)) != NULL) &&
(lValue3 == 0 || (ALFilter=LookupFilter(device, lValue3)) != NULL))
{
/* Release refcount on the previous slot, and add one for
* the new slot */
@ -865,7 +856,7 @@ AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum eParam, const ALint* pl
if(plValues)
{
if(LookupSource(pContext->SourceMap, source) != NULL)
if(LookupSource(pContext, source) != NULL)
{
switch(eParam)
{
@ -896,7 +887,7 @@ AL_API ALvoid AL_APIENTRY alGetSourcef(ALuint source, ALenum eParam, ALfloat *pf
if(pflValue)
{
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
switch(eParam)
{
@ -940,7 +931,7 @@ AL_API ALvoid AL_APIENTRY alGetSourcef(ALuint source, ALenum eParam, ALfloat *pf
pContext->Device->Frequency;
GetSourceOffset(Source, eParam, Offsets, updateLen);
UnlockContext(pContext);
*pflValue = Offsets[0];
*pflValue = (ALfloat)Offsets[0];
break;
case AL_CONE_INNER_ANGLE:
@ -992,7 +983,7 @@ AL_API ALvoid AL_APIENTRY alGetSource3f(ALuint source, ALenum eParam, ALfloat* p
if(pflValue1 && pflValue2 && pflValue3)
{
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
switch(eParam)
{
@ -1076,7 +1067,7 @@ AL_API ALvoid AL_APIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *p
if(pflValues)
{
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
switch(eParam)
{
@ -1087,8 +1078,8 @@ AL_API ALvoid AL_APIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *p
pContext->Device->Frequency;
GetSourceOffset(Source, eParam, Offsets, updateLen);
UnlockContext(pContext);
pflValues[0] = Offsets[0];
pflValues[1] = Offsets[1];
pflValues[0] = (ALfloat)Offsets[0];
pflValues[1] = (ALfloat)Offsets[1];
break;
default:
@ -1119,7 +1110,7 @@ AL_API ALvoid AL_APIENTRY alGetSourcei(ALuint source, ALenum eParam, ALint *plVa
if(plValue)
{
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
switch(eParam)
{
@ -1253,7 +1244,7 @@ AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum eParam, ALint* plVal
if(plValue1 && plValue2 && plValue3)
{
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
switch(eParam)
{
@ -1342,7 +1333,7 @@ AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum eParam, ALint* plVal
if(plValues)
{
if((Source=LookupSource(pContext->SourceMap, source)) != NULL)
if((Source=LookupSource(pContext, source)) != NULL)
{
switch(eParam)
{
@ -1400,7 +1391,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
// Check that all the Sources are valid
for(i = 0;i < n;i++)
{
if(!LookupSource(Context->SourceMap, sources[i]))
if(!LookupSource(Context, sources[i]))
{
alSetError(Context, AL_INVALID_NAME);
goto done;
@ -1430,7 +1421,7 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
for(i = 0;i < n;i++)
{
Source = LookupSource(Context->SourceMap, sources[i]);
Source = LookupSource(Context, sources[i]);
if(Context->DeferUpdates) Source->new_state = AL_PLAYING;
else SetSourceState(Source, Context, AL_PLAYING);
}
@ -1468,7 +1459,7 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources)
// Check all the Sources are valid
for(i = 0;i < n;i++)
{
if(!LookupSource(Context->SourceMap, sources[i]))
if(!LookupSource(Context, sources[i]))
{
alSetError(Context, AL_INVALID_NAME);
goto done;
@ -1478,7 +1469,7 @@ AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources)
LockContext(Context);
for(i = 0;i < n;i++)
{
Source = LookupSource(Context->SourceMap, sources[i]);
Source = LookupSource(Context, sources[i]);
if(Context->DeferUpdates) Source->new_state = AL_PAUSED;
else SetSourceState(Source, Context, AL_PAUSED);
}
@ -1516,7 +1507,7 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources)
// Check all the Sources are valid
for(i = 0;i < n;i++)
{
if(!LookupSource(Context->SourceMap, sources[i]))
if(!LookupSource(Context, sources[i]))
{
alSetError(Context, AL_INVALID_NAME);
goto done;
@ -1526,7 +1517,7 @@ AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources)
LockContext(Context);
for(i = 0;i < n;i++)
{
Source = LookupSource(Context->SourceMap, sources[i]);
Source = LookupSource(Context, sources[i]);
Source->new_state = AL_NONE;
SetSourceState(Source, Context, AL_STOPPED);
}
@ -1564,7 +1555,7 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources)
// Check all the Sources are valid
for(i = 0;i < n;i++)
{
if(!LookupSource(Context->SourceMap, sources[i]))
if(!LookupSource(Context, sources[i]))
{
alSetError(Context, AL_INVALID_NAME);
goto done;
@ -1574,7 +1565,7 @@ AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources)
LockContext(Context);
for(i = 0;i < n;i++)
{
Source = LookupSource(Context->SourceMap, sources[i]);
Source = LookupSource(Context, sources[i]);
Source->new_state = AL_NONE;
SetSourceState(Source, Context, AL_INITIAL);
}
@ -1610,7 +1601,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
// Check that all buffers are valid or zero and that the source is valid
// Check that this is a valid source
if((Source=LookupSource(Context->SourceMap, source)) == NULL)
if((Source=LookupSource(Context, source)) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
goto error;
@ -1645,7 +1636,7 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A
for(i = 0;i < n;i++)
{
ALbuffer *buffer = NULL;
if(buffers[i] && (buffer=LookupBuffer(device->BufferMap, buffers[i])) == NULL)
if(buffers[i] && (buffer=LookupBuffer(device, buffers[i])) == NULL)
{
UnlockContext(Context);
alSetError(Context, AL_INVALID_NAME);
@ -1756,7 +1747,7 @@ AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALui
goto done;
}
if((Source=LookupSource(Context->SourceMap, source)) == NULL)
if((Source=LookupSource(Context, source)) == NULL)
{
alSetError(Context, AL_INVALID_NAME);
goto done;

View File

@ -585,6 +585,9 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
ALboolean UpdateSources;
ALsource **src, **src_end;
ALeffectslot **slot, **slot_end;
int fpuState;
fpuState = SetMixerFPUMode();
LockContext(Context);
Context->DeferUpdates = AL_TRUE;
@ -619,6 +622,7 @@ AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
}
UnlockContext(Context);
RestoreFPUMode(fpuState);
}
ALCcontext_DecRef(Context);

View File

@ -62,15 +62,33 @@
/* Define if we have the sqrtf function */
#cmakedefine HAVE_SQRTF
/* Define if we have the cosf function */
#cmakedefine HAVE_COSF
/* Define if we have the sinf function */
#cmakedefine HAVE_SINF
/* Define if we have the acosf function */
#cmakedefine HAVE_ACOSF
/* Define if we have the asinf function */
#cmakedefine HAVE_ASINF
/* Define if we have the atanf function */
#cmakedefine HAVE_ATANF
/* Define if we have the atan2f function */
#cmakedefine HAVE_ATAN2F
/* Define if we have the fabsf function */
#cmakedefine HAVE_FABSF
/* Define if we have the log10f function */
#cmakedefine HAVE_LOG10F
/* Define if we have the floorf function */
#cmakedefine HAVE_FLOORF
/* Define if we have the strtof function */
#cmakedefine HAVE_STRTOF
@ -110,6 +128,9 @@
/* Define if we have float.h */
#cmakedefine HAVE_FLOAT_H
/* Define if we have fpu_control.h */
#cmakedefine HAVE_FPU_CONTROL_H
/* Define if we have fenv.h */
#cmakedefine HAVE_FENV_H

View File

@ -61,6 +61,18 @@ extern "C" {
#define AL_FORMAT_STEREO_DOUBLE_EXT 0x10013
#endif
#ifndef AL_EXT_MULAW
#define AL_EXT_MULAW 1
#define AL_FORMAT_MONO_MULAW_EXT 0x10014
#define AL_FORMAT_STEREO_MULAW_EXT 0x10015
#endif
#ifndef AL_EXT_ALAW
#define AL_EXT_ALAW 1
#define AL_FORMAT_MONO_ALAW_EXT 0x10016
#define AL_FORMAT_STEREO_ALAW_EXT 0x10017
#endif
#ifndef ALC_LOKI_audio_channel
#define ALC_LOKI_audio_channel 1
#define ALC_CHAN_MAIN_LOKI 0x500001

View File

@ -201,12 +201,12 @@ extern "C" {
/* Effect object function types. */
typedef void (AL_APIENTRY *LPALGENEFFECTS)(ALsizei, ALuint*);
typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, ALuint*);
typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, const ALuint*);
typedef ALboolean (AL_APIENTRY *LPALISEFFECT)(ALuint);
typedef void (AL_APIENTRY *LPALEFFECTI)(ALuint, ALenum, ALint);
typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, ALint*);
typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, const ALint*);
typedef void (AL_APIENTRY *LPALEFFECTF)(ALuint, ALenum, ALfloat);
typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, ALfloat*);
typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, const ALfloat*);
typedef void (AL_APIENTRY *LPALGETEFFECTI)(ALuint, ALenum, ALint*);
typedef void (AL_APIENTRY *LPALGETEFFECTIV)(ALuint, ALenum, ALint*);
typedef void (AL_APIENTRY *LPALGETEFFECTF)(ALuint, ALenum, ALfloat*);
@ -214,12 +214,12 @@ typedef void (AL_APIENTRY *LPALGETEFFECTFV)(ALuint, ALenum, ALfloat*);
/* Filter object function types. */
typedef void (AL_APIENTRY *LPALGENFILTERS)(ALsizei, ALuint*);
typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, ALuint*);
typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, const ALuint*);
typedef ALboolean (AL_APIENTRY *LPALISFILTER)(ALuint);
typedef void (AL_APIENTRY *LPALFILTERI)(ALuint, ALenum, ALint);
typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, ALint*);
typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, const ALint*);
typedef void (AL_APIENTRY *LPALFILTERF)(ALuint, ALenum, ALfloat);
typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, ALfloat*);
typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, const ALfloat*);
typedef void (AL_APIENTRY *LPALGETFILTERI)(ALuint, ALenum, ALint*);
typedef void (AL_APIENTRY *LPALGETFILTERIV)(ALuint, ALenum, ALint*);
typedef void (AL_APIENTRY *LPALGETFILTERF)(ALuint, ALenum, ALfloat*);
@ -227,12 +227,12 @@ typedef void (AL_APIENTRY *LPALGETFILTERFV)(ALuint, ALenum, ALfloat*);
/* Auxiliary Effect Slot object function types. */
typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*);
typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*);
typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, const ALuint*);
typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint);
typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint);
typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*);
typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, const ALint*);
typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat);
typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat*);
typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, const ALfloat*);
typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint*);
typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*);
typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat*);
@ -240,36 +240,36 @@ typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat
#ifdef AL_ALEXT_PROTOTYPES
AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects);
AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, ALuint *effects);
AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects);
AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect);
AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue);
AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, ALint *piValues);
AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues);
AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue);
AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, ALfloat *pflValues);
AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues);
AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue);
AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues);
AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue);
AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues);
AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters);
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, ALuint *filters);
AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters);
AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter);
AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue);
AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, ALint *piValues);
AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues);
AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue);
AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, ALfloat *pflValues);
AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues);
AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue);
AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues);
AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue);
AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues);
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots);
AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots);
AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots);
AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot);
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue);
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues);
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues);
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue);
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues);
AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues);
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue);
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues);
AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue);