Don't keep selecting the mixer to use
This commit is contained in:
parent
86ff35bf71
commit
3e60b18989
@ -1022,7 +1022,7 @@ static void alc_initconfig(void)
|
|||||||
WARN("Invalid resampler: %s\n", str);
|
WARN("Invalid resampler: %s\n", str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aluInitResamplers();
|
aluInitMixer();
|
||||||
|
|
||||||
str = getenv("ALSOFT_TRAP_ERROR");
|
str = getenv("ALSOFT_TRAP_ERROR");
|
||||||
if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1))
|
if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1))
|
||||||
|
54
Alc/mixer.c
54
Alc/mixer.c
@ -46,20 +46,9 @@ extern inline void InitiatePositionArrays(ALuint frac, ALuint increment, ALuint
|
|||||||
alignas(16) ALfloat CubicLUT[FRACTIONONE][4];
|
alignas(16) ALfloat CubicLUT[FRACTIONONE][4];
|
||||||
|
|
||||||
|
|
||||||
void aluInitResamplers(void)
|
static HrtfMixerFunc MixHrtfSamples = MixHrtf_C;
|
||||||
{
|
static MixerFunc MixSamples = Mix_C;
|
||||||
ALuint i;
|
static ResamplerFunc ResampleSamples = Resample_point32_C;
|
||||||
for(i = 0;i < FRACTIONONE;i++)
|
|
||||||
{
|
|
||||||
ALfloat mu = (ALfloat)i / FRACTIONONE;
|
|
||||||
ALfloat mu2 = mu*mu, mu3 = mu*mu*mu;
|
|
||||||
CubicLUT[i][0] = -0.5f*mu3 + mu2 + -0.5f*mu;
|
|
||||||
CubicLUT[i][1] = 1.5f*mu3 + -2.5f*mu2 + 1.0f;
|
|
||||||
CubicLUT[i][2] = -1.5f*mu3 + 2.0f*mu2 + 0.5f*mu;
|
|
||||||
CubicLUT[i][3] = 0.5f*mu3 + -0.5f*mu2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline HrtfMixerFunc SelectHrtfMixer(void)
|
static inline HrtfMixerFunc SelectHrtfMixer(void)
|
||||||
{
|
{
|
||||||
@ -124,6 +113,25 @@ static inline ResamplerFunc SelectResampler(enum Resampler resampler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void aluInitMixer(void)
|
||||||
|
{
|
||||||
|
ALuint i;
|
||||||
|
for(i = 0;i < FRACTIONONE;i++)
|
||||||
|
{
|
||||||
|
ALfloat mu = (ALfloat)i / FRACTIONONE;
|
||||||
|
ALfloat mu2 = mu*mu, mu3 = mu*mu*mu;
|
||||||
|
CubicLUT[i][0] = -0.5f*mu3 + mu2 + -0.5f*mu;
|
||||||
|
CubicLUT[i][1] = 1.5f*mu3 + -2.5f*mu2 + 1.0f;
|
||||||
|
CubicLUT[i][2] = -1.5f*mu3 + 2.0f*mu2 + 0.5f*mu;
|
||||||
|
CubicLUT[i][3] = 0.5f*mu3 + -0.5f*mu2;
|
||||||
|
}
|
||||||
|
|
||||||
|
MixHrtfSamples = SelectHrtfMixer();
|
||||||
|
MixSamples = SelectMixer();
|
||||||
|
ResampleSamples = SelectResampler(DefaultResampler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline ALfloat Sample_ALbyte(ALbyte val)
|
static inline ALfloat Sample_ALbyte(ALbyte val)
|
||||||
{ return val * (1.0f/127.0f); }
|
{ return val * (1.0f/127.0f); }
|
||||||
|
|
||||||
@ -206,15 +214,12 @@ static const ALfloat *DoFilters(ALfilterState *lpfilter, ALfilterState *hpfilter
|
|||||||
|
|
||||||
ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
|
ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint SamplesToDo)
|
||||||
{
|
{
|
||||||
MixerFunc Mix;
|
|
||||||
HrtfMixerFunc HrtfMix;
|
|
||||||
ResamplerFunc Resample;
|
ResamplerFunc Resample;
|
||||||
ALbufferlistitem *BufferListItem;
|
ALbufferlistitem *BufferListItem;
|
||||||
ALuint DataPosInt, DataPosFrac;
|
ALuint DataPosInt, DataPosFrac;
|
||||||
ALboolean isbformat = AL_FALSE;
|
ALboolean isbformat = AL_FALSE;
|
||||||
ALboolean Looping;
|
ALboolean Looping;
|
||||||
ALuint increment;
|
ALuint increment;
|
||||||
enum Resampler Resampler;
|
|
||||||
ALenum State;
|
ALenum State;
|
||||||
ALuint OutPos;
|
ALuint OutPos;
|
||||||
ALuint NumChannels;
|
ALuint NumChannels;
|
||||||
@ -229,7 +234,6 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
|
|||||||
DataPosInt = Source->position;
|
DataPosInt = Source->position;
|
||||||
DataPosFrac = Source->position_fraction;
|
DataPosFrac = Source->position_fraction;
|
||||||
Looping = Source->Looping;
|
Looping = Source->Looping;
|
||||||
Resampler = Source->Resampler;
|
|
||||||
NumChannels = Source->NumChannels;
|
NumChannels = Source->NumChannels;
|
||||||
SampleSize = Source->SampleSize;
|
SampleSize = Source->SampleSize;
|
||||||
increment = voice->Step;
|
increment = voice->Step;
|
||||||
@ -249,15 +253,13 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
|
|||||||
|
|
||||||
IrSize = (Device->Hrtf ? GetHrtfIrSize(Device->Hrtf) : 0);
|
IrSize = (Device->Hrtf ? GetHrtfIrSize(Device->Hrtf) : 0);
|
||||||
|
|
||||||
Mix = SelectMixer();
|
|
||||||
HrtfMix = SelectHrtfMixer();
|
|
||||||
Resample = ((increment == FRACTIONONE && DataPosFrac == 0) ?
|
Resample = ((increment == FRACTIONONE && DataPosFrac == 0) ?
|
||||||
Resample_copy32_C : SelectResampler(Resampler));
|
Resample_copy32_C : ResampleSamples);
|
||||||
|
|
||||||
OutPos = 0;
|
OutPos = 0;
|
||||||
do {
|
do {
|
||||||
const ALuint BufferPrePadding = ResamplerPrePadding[Resampler];
|
const ALuint BufferPrePadding = ResamplerPrePadding[DefaultResampler];
|
||||||
const ALuint BufferPadding = ResamplerPadding[Resampler];
|
const ALuint BufferPadding = ResamplerPadding[DefaultResampler];
|
||||||
ALuint SrcBufferSize, DstBufferSize;
|
ALuint SrcBufferSize, DstBufferSize;
|
||||||
|
|
||||||
/* Figure out how many buffer samples will be needed */
|
/* Figure out how many buffer samples will be needed */
|
||||||
@ -467,10 +469,10 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
|
|||||||
parms->Filters[chan].ActiveType
|
parms->Filters[chan].ActiveType
|
||||||
);
|
);
|
||||||
if(!voice->IsHrtf)
|
if(!voice->IsHrtf)
|
||||||
Mix(samples, parms->OutChannels, parms->OutBuffer, parms->Gains[chan],
|
MixSamples(samples, parms->OutChannels, parms->OutBuffer, parms->Gains[chan],
|
||||||
parms->Counter, OutPos, DstBufferSize);
|
parms->Counter, OutPos, DstBufferSize);
|
||||||
else
|
else
|
||||||
HrtfMix(parms->OutBuffer, samples, parms->Counter, voice->Offset,
|
MixHrtfSamples(parms->OutBuffer, samples, parms->Counter, voice->Offset,
|
||||||
OutPos, IrSize, &parms->Hrtf[chan].Params,
|
OutPos, IrSize, &parms->Hrtf[chan].Params,
|
||||||
&parms->Hrtf[chan].State, DstBufferSize);
|
&parms->Hrtf[chan].State, DstBufferSize);
|
||||||
}
|
}
|
||||||
@ -492,7 +494,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
|
|||||||
Device->FilteredData, ResampledData, DstBufferSize,
|
Device->FilteredData, ResampledData, DstBufferSize,
|
||||||
parms->Filters[chan].ActiveType
|
parms->Filters[chan].ActiveType
|
||||||
);
|
);
|
||||||
Mix(samples, 1, parms->OutBuffer, &parms->Gain,
|
MixSamples(samples, 1, parms->OutBuffer, &parms->Gain,
|
||||||
parms->Counter, OutPos, DstBufferSize);
|
parms->Counter, OutPos, DstBufferSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,6 @@ typedef struct ALsource {
|
|||||||
|
|
||||||
volatile ALfloat Radius;
|
volatile ALfloat Radius;
|
||||||
|
|
||||||
enum Resampler Resampler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Last user-specified offset, and the offset type (bytes, samples, or
|
* Last user-specified offset, and the offset type (bytes, samples, or
|
||||||
* seconds).
|
* seconds).
|
||||||
|
@ -216,7 +216,7 @@ inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALu
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void aluInitResamplers(void);
|
void aluInitMixer(void);
|
||||||
|
|
||||||
ALvoid aluInitPanning(ALCdevice *Device);
|
ALvoid aluInitPanning(ALCdevice *Device);
|
||||||
|
|
||||||
|
@ -2549,8 +2549,6 @@ static ALvoid InitSourceParams(ALsource *Source)
|
|||||||
|
|
||||||
Source->DistanceModel = DefaultDistanceModel;
|
Source->DistanceModel = DefaultDistanceModel;
|
||||||
|
|
||||||
Source->Resampler = DefaultResampler;
|
|
||||||
|
|
||||||
Source->state = AL_INITIAL;
|
Source->state = AL_INITIAL;
|
||||||
Source->new_state = AL_NONE;
|
Source->new_state = AL_NONE;
|
||||||
Source->SourceType = AL_UNDETERMINED;
|
Source->SourceType = AL_UNDETERMINED;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user