Use a separate macro for the max output channel count

This commit is contained in:
Chris Robinson 2014-11-07 02:18:24 -08:00
parent 6c954e71db
commit 4c3f27193f
16 changed files with 58 additions and 59 deletions

View File

@ -1470,7 +1470,7 @@ void SetDefaultWFXChannelOrder(ALCdevice *device)
{
ALuint i;
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
device->ChannelName[i] = InvalidChannel;
switch(device->FmtChans)
@ -1534,7 +1534,7 @@ void SetDefaultChannelOrder(ALCdevice *device)
{
ALuint i;
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
device->ChannelName[i] = InvalidChannel;
switch(device->FmtChans)

View File

@ -129,7 +129,7 @@ static void UpdateDryStepping(DirectParams *params, ALuint num_chans)
for(i = 0;i < num_chans;i++)
{
MixGains *gains = params->Mix.Gains[i];
for(j = 0;j < MaxChannels;j++)
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
{
gains[j].Current = gains[j].Target;
gains[j].Step = 1.0f;
@ -143,7 +143,7 @@ static void UpdateDryStepping(DirectParams *params, ALuint num_chans)
for(i = 0;i < num_chans;i++)
{
MixGains *gains = params->Mix.Gains[i];
for(j = 0;j < MaxChannels;j++)
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
{
ALfloat cur = maxf(gains[j].Current, FLT_EPSILON);
ALfloat trg = maxf(gains[j].Target, FLT_EPSILON);
@ -461,10 +461,10 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
for(c = 0;c < num_channels;c++)
{
MixGains *gains = voice->Direct.Mix.Gains[c];
ALfloat Target[MaxChannels];
ALfloat Target[MAX_OUTPUT_CHANNELS];
ComputeBFormatGains(Device, matrix[c], DryGain, Target);
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
gains[i].Target = Target[i];
}
/* B-Format cannot handle logarithmic gain stepping, since the gain can
@ -483,7 +483,7 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
MixGains *gains = voice->Direct.Mix.Gains[c];
int idx;
for(j = 0;j < MaxChannels;j++)
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
gains[j].Target = 0.0f;
if((idx=GetChannelIdxByName(Device, chans[c].channel)) != -1)
gains[idx].Target = DryGain;
@ -528,13 +528,13 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
for(c = 0;c < num_channels;c++)
{
MixGains *gains = voice->Direct.Mix.Gains[c];
ALfloat Target[MaxChannels];
ALfloat Target[MAX_OUTPUT_CHANNELS];
/* Special-case LFE */
if(chans[c].channel == LFE)
{
int idx;
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
gains[i].Target = 0.0f;
if((idx=GetChannelIdxByName(Device, chans[c].channel)) != -1)
gains[idx].Target = DryGain;
@ -542,7 +542,7 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
}
ComputeAngleGains(Device, chans[c].angle, chans[c].elevation, DryGain, Target);
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
gains[i].Target = Target[i];
}
UpdateDryStepping(&voice->Direct, num_channels);
@ -996,7 +996,7 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
{
MixGains *gains = voice->Direct.Mix.Gains[0];
ALfloat radius = ALSource->Radius;
ALfloat Target[MaxChannels];
ALfloat Target[MAX_OUTPUT_CHANNELS];
/* Normalize the length, and compute panned gains. */
if(!(Distance > FLT_EPSILON) && !(radius > FLT_EPSILON))
@ -1013,7 +1013,7 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
ComputeDirectionalGains(Device, Position, DryGain, Target);
}
for(j = 0;j < MaxChannels;j++)
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
gains[j].Target = Target[j];
UpdateDryStepping(&voice->Direct, 1);
@ -1128,7 +1128,7 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
IncrementRef(&device->MixCount);
SamplesToDo = minu(size, BUFFERSIZE);
for(c = 0;c < MaxChannels;c++)
for(c = 0;c < MAX_OUTPUT_CHANNELS;c++)
memset(device->DryBuffer[c], 0, SamplesToDo*sizeof(ALfloat));
V0(device->Backend,lock)();

View File

@ -39,7 +39,7 @@ typedef struct ALautowahState {
DERIVE_FROM_TYPE(ALeffectState);
/* Effect gains for each channel */
ALfloat Gain[MaxChannels];
ALfloat Gain[MAX_OUTPUT_CHANNELS];
/* Effect parameters */
ALfloat AttackRate;
@ -135,7 +135,7 @@ static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo,
}
state->GainCtrl = gain;
for(kt = 0;kt < MaxChannels;kt++)
for(kt = 0;kt < MAX_OUTPUT_CHANNELS;kt++)
{
ALfloat gain = state->Gain[kt];
if(!(gain > GAIN_SILENCE_THRESHOLD))

View File

@ -46,7 +46,7 @@ typedef struct ALchorusState {
ALint lfo_disp;
/* Gains for left and right sides */
ALfloat Gain[2][MaxChannels];
ALfloat Gain[2][MAX_OUTPUT_CHANNELS];
/* effect parameters */
enum ChorusWaveForm waveform;
@ -223,7 +223,7 @@ static ALvoid ALchorusState_process(ALchorusState *state, ALuint SamplesToDo, co
break;
}
for(kt = 0;kt < MaxChannels;kt++)
for(kt = 0;kt < MAX_OUTPUT_CHANNELS;kt++)
{
ALfloat gain = state->Gain[0][kt];
if(gain > GAIN_SILENCE_THRESHOLD)

View File

@ -31,7 +31,7 @@ typedef struct ALcompressorState {
DERIVE_FROM_TYPE(ALeffectState);
/* Effect gains for each channel */
ALfloat Gain[MaxChannels];
ALfloat Gain[MAX_OUTPUT_CHANNELS];
/* Effect parameters */
ALboolean Enabled;
@ -116,7 +116,7 @@ static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint Samples
}
for(kt = 0;kt < MaxChannels;kt++)
for(kt = 0;kt < MAX_OUTPUT_CHANNELS;kt++)
{
ALfloat gain = state->Gain[kt];
if(!(gain > GAIN_SILENCE_THRESHOLD))

View File

@ -32,7 +32,7 @@
typedef struct ALdedicatedState {
DERIVE_FROM_TYPE(ALeffectState);
ALfloat gains[MaxChannels];
ALfloat gains[MAX_OUTPUT_CHANNELS];
} ALdedicatedState;
@ -50,7 +50,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, ALCdevice *device
ALfloat Gain;
ALuint i;
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
state->gains[i] = 0.0f;
Gain = Slot->Gain * Slot->EffectProps.Dedicated.Gain;
@ -80,7 +80,7 @@ static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALuint SamplesTo
const ALfloat *gains = state->gains;
ALuint i, c;
for(c = 0;c < MaxChannels;c++)
for(c = 0;c < MAX_OUTPUT_CHANNELS;c++)
{
if(!(gains[c] > GAIN_SILENCE_THRESHOLD))
continue;
@ -108,7 +108,7 @@ ALeffectState *ALdedicatedStateFactory_create(ALdedicatedStateFactory *UNUSED(fa
if(!state) return NULL;
SET_VTABLE2(ALdedicatedState, ALeffectState, state);
for(s = 0;s < MaxChannels;s++)
for(s = 0;s < MAX_OUTPUT_CHANNELS;s++)
state->gains[s] = 0.0f;
return STATIC_CAST(ALeffectState, state);

View File

@ -34,7 +34,7 @@ typedef struct ALdistortionState {
DERIVE_FROM_TYPE(ALeffectState);
/* Effect gains for each channel */
ALfloat Gain[MaxChannels];
ALfloat Gain[MAX_OUTPUT_CHANNELS];
/* Effect parameters */
ALfilterState lowpass;
@ -154,7 +154,7 @@ static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint Samples
temps[it] = oversample_buffer[it][0] * state->attenuation;
}
for(kt = 0;kt < MaxChannels;kt++)
for(kt = 0;kt < MAX_OUTPUT_CHANNELS;kt++)
{
ALfloat gain = state->Gain[kt];
if(!(gain > GAIN_SILENCE_THRESHOLD))

View File

@ -43,7 +43,7 @@ typedef struct ALechoState {
} Tap[2];
ALuint Offset;
/* The panning gains for the two taps */
ALfloat Gain[2][MaxChannels];
ALfloat Gain[2][MAX_OUTPUT_CHANNELS];
ALfloat FeedGain;
@ -138,7 +138,7 @@ static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const
offset++;
}
for(k = 0;k < MaxChannels;k++)
for(k = 0;k < MAX_OUTPUT_CHANNELS;k++)
{
ALfloat gain = state->Gain[0][k];
if(gain > GAIN_SILENCE_THRESHOLD)

View File

@ -75,7 +75,7 @@ typedef struct ALequalizerState {
DERIVE_FROM_TYPE(ALeffectState);
/* Effect gains for each channel */
ALfloat Gain[MaxChannels];
ALfloat Gain[MAX_OUTPUT_CHANNELS];
/* Effect parameters */
ALfilterState filter[4];
@ -140,7 +140,7 @@ static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesTo
temps[it] = smp;
}
for(kt = 0;kt < MaxChannels;kt++)
for(kt = 0;kt < MAX_OUTPUT_CHANNELS;kt++)
{
ALfloat gain = state->Gain[kt];
if(!(gain > GAIN_SILENCE_THRESHOLD))

View File

@ -46,7 +46,7 @@ typedef struct ALflangerState {
ALint lfo_disp;
/* Gains for left and right sides */
ALfloat Gain[2][MaxChannels];
ALfloat Gain[2][MAX_OUTPUT_CHANNELS];
/* effect parameters */
enum FlangerWaveForm waveform;
@ -223,7 +223,7 @@ static ALvoid ALflangerState_process(ALflangerState *state, ALuint SamplesToDo,
break;
}
for(kt = 0;kt < MaxChannels;kt++)
for(kt = 0;kt < MAX_OUTPUT_CHANNELS;kt++)
{
ALfloat gain = state->Gain[0][kt];
if(gain > GAIN_SILENCE_THRESHOLD)

View File

@ -42,7 +42,7 @@ typedef struct ALmodulatorState {
ALuint index;
ALuint step;
ALfloat Gain[MaxChannels];
ALfloat Gain[MAX_OUTPUT_CHANNELS];
ALfilterState Filter;
} ALmodulatorState;
@ -92,7 +92,7 @@ static void Process##func(ALmodulatorState *state, ALuint SamplesToDo, \
temps[i] = samp * func(index); \
} \
\
for(k = 0;k < MaxChannels;k++) \
for(k = 0;k < MAX_OUTPUT_CHANNELS;k++) \
{ \
ALfloat gain = state->Gain[k]; \
if(!(gain > GAIN_SILENCE_THRESHOLD)) \

View File

@ -86,7 +86,7 @@ typedef struct ALreverbState {
// The gain for each output channel based on 3D panning (only for the
// EAX path).
ALfloat PanGain[MaxChannels];
ALfloat PanGain[MAX_OUTPUT_CHANNELS];
} Early;
// Decorrelator delay line.
@ -125,7 +125,7 @@ typedef struct ALreverbState {
// The gain for each output channel based on 3D panning (only for the
// EAX path).
ALfloat PanGain[MaxChannels];
ALfloat PanGain[MAX_OUTPUT_CHANNELS];
} Late;
struct {
@ -565,7 +565,7 @@ static ALvoid ALreverbState_processStandard(ALreverbState *State, ALuint Samples
for(index = 0;index < SamplesToDo;index++)
VerbPass(State, SamplesIn[index], out[index]);
for(c = 0;c < MaxChannels;c++)
for(c = 0;c < MAX_OUTPUT_CHANNELS;c++)
{
ALfloat gain = State->Gain[c];
if(!(gain > GAIN_SILENCE_THRESHOLD))
@ -586,7 +586,7 @@ static ALvoid ALreverbState_processEax(ALreverbState *State, ALuint SamplesToDo,
for(index = 0;index < SamplesToDo;index++)
EAXVerbPass(State, SamplesIn[index], early[index], late[index]);
for(c = 0;c < MaxChannels;c++)
for(c = 0;c < MAX_OUTPUT_CHANNELS;c++)
{
ALfloat earlyGain, lateGain;
@ -1231,7 +1231,7 @@ static ALeffectState *ALreverbStateFactory_create(ALreverbStateFactory* UNUSED(f
state->Late.LpSample[index] = 0.0f;
}
for(index = 0;index < MaxChannels;index++)
for(index = 0;index < MAX_OUTPUT_CHANNELS;index++)
{
state->Early.PanGain[index] = 0.0f;
state->Late.PanGain[index] = 0.0f;

View File

@ -432,7 +432,7 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam
parms->Filters[chan].ActiveType
);
if(!voice->IsHrtf)
Mix(samples, MaxChannels, parms->OutBuffer, parms->Mix.Gains[chan],
Mix(samples, Device->NumSpeakers, parms->OutBuffer, parms->Mix.Gains[chan],
parms->Counter, OutPos, DstBufferSize);
else
HrtfMix(parms->OutBuffer, samples, parms->Counter, voice->Offset,

View File

@ -32,7 +32,7 @@
#include "alu.h"
void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat elevation, ALfloat ingain, ALfloat gains[MaxChannels])
void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat elevation, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS])
{
ALfloat dir[3] = {
sinf(angle) * cosf(elevation),
@ -42,7 +42,7 @@ void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat elevation
ComputeDirectionalGains(device, dir, ingain, gains);
}
void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfloat ingain, ALfloat gains[MaxChannels])
void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS])
{
ALfloat coeffs[MAX_AMBI_COEFFS];
ALuint i, j;
@ -68,7 +68,7 @@ void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfl
coeffs[14] = x * (x*x - 3.0f*y*y); /* X * (X*X - 3*Y*Y) */
coeffs[15] = y * (3.0f*x*x - y*y); /* Y * (3*X*X - Y*Y) */
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
gains[i] = 0.0f;
for(i = 0;i < device->NumSpeakers;i++)
{
@ -78,21 +78,21 @@ void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfl
}
}
void ComputeAmbientGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels])
void ComputeAmbientGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS])
{
ALuint i;
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
gains[i] = 0.0f;
for(i = 0;i < device->NumSpeakers;i++)
gains[i] = device->Speaker[i].HOACoeff[0] * ingain;
}
void ComputeBFormatGains(const ALCdevice *device, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MaxChannels])
void ComputeBFormatGains(const ALCdevice *device, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS])
{
ALuint i, j;
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
gains[i] = 0.0f;
for(i = 0;i < device->NumSpeakers;i++)
{
@ -196,7 +196,7 @@ ALvoid aluInitPanning(ALCdevice *device)
chanmap = X71Cfg;
break;
}
for(i = 0;i < MaxChannels && device->ChannelName[i] != InvalidChannel;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS && device->ChannelName[i] != InvalidChannel;i++)
{
for(j = 0;j < count;j++)
{

View File

@ -524,10 +524,9 @@ enum Channel {
SideLeft,
SideRight,
MaxChannels,
InvalidChannel = MaxChannels
InvalidChannel
};
#define MAX_OUTPUT_CHANNELS (8)
/* Device formats */
enum DevFmtType {
@ -658,10 +657,10 @@ struct ALCdevice_struct
// Device flags
ALuint Flags;
enum Channel ChannelName[MaxChannels];
enum Channel ChannelName[MAX_OUTPUT_CHANNELS];
/* This only counts positional speakers, i.e. not including LFE. */
ChannelConfig Speaker[MaxChannels];
ChannelConfig Speaker[MAX_OUTPUT_CHANNELS];
ALuint NumSpeakers;
ALuint64 ClockBase;
@ -673,7 +672,7 @@ struct ALCdevice_struct
alignas(16) ALfloat FilteredData[BUFFERSIZE];
// Dry path buffer mix
alignas(16) ALfloat DryBuffer[MaxChannels][BUFFERSIZE];
alignas(16) ALfloat DryBuffer[MAX_OUTPUT_CHANNELS][BUFFERSIZE];
/* Running count of the mixer invocations, in 31.1 fixed point. This
* actually increments *twice* when mixing, first at the start and then at
@ -840,7 +839,7 @@ const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans) DECL_CONST;
inline ALint GetChannelIdxByName(const ALCdevice *device, enum Channel chan)
{
ALint i = 0;
for(i = 0;i < MaxChannels;i++)
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
{
if(device->ChannelName[i] == chan)
return i;

View File

@ -96,7 +96,7 @@ typedef struct DirectParams {
ALfloat Dir[3];
} Hrtf;
MixGains Gains[MAX_INPUT_CHANNELS][MaxChannels];
MixGains Gains[MAX_INPUT_CHANNELS][MAX_OUTPUT_CHANNELS];
} Mix;
} DirectParams;
@ -207,7 +207,7 @@ ALvoid aluInitPanning(ALCdevice *Device);
* Sets channel gains based on a direction. The direction must be a 3-component
* vector no longer than 1 unit.
*/
void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfloat ingain, ALfloat gains[MaxChannels]);
void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/**
* ComputeAngleGains
@ -215,14 +215,14 @@ void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfl
* Sets channel gains based on angle and elevation. The angle and elevation
* parameters are in radians, going right and up respectively.
*/
void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat elevation, ALfloat ingain, ALfloat gains[MaxChannels]);
void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat elevation, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/**
* ComputeAmbientGains
*
* Sets channel gains for ambient, omni-directional sounds.
*/
void ComputeAmbientGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels]);
void ComputeAmbientGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/**
* ComputeBFormatGains
@ -231,7 +231,7 @@ void ComputeAmbientGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[
* a 1x4 'slice' of the rotation matrix for a given channel used to orient the
* coefficients.
*/
void ComputeBFormatGains(const ALCdevice *device, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MaxChannels]);
void ComputeBFormatGains(const ALCdevice *device, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
ALvoid CalcSourceParams(struct ALvoice *voice, const struct ALsource *source, const ALCcontext *ALContext);