Generalize GetChannelIdxByName
This commit is contained in:
parent
da5f75615b
commit
d648486bcd
@ -1538,7 +1538,7 @@ void SetDefaultChannelOrder(ALCdevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
extern inline ALint GetChannelIdxByName(const ALCdevice *device, enum Channel chan);
|
||||
extern inline ALint GetChannelIndex(const enum Channel names[MAX_OUTPUT_CHANNELS], enum Channel chan);
|
||||
|
||||
|
||||
/* ALCcontext_DeferUpdates
|
||||
|
15
Alc/ALu.c
15
Alc/ALu.c
@ -563,16 +563,11 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
|
||||
voice->Direct.OutChannels = Device->RealOut.NumChannels;
|
||||
for(c = 0;c < num_channels;c++)
|
||||
{
|
||||
int idx;
|
||||
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
|
||||
voice->Direct.Gains[c].Target[j] = 0.0f;
|
||||
for(j = 0;j < Device->RealOut.NumChannels;j++)
|
||||
{
|
||||
if(chans[c].channel == Device->RealOut.ChannelName[j])
|
||||
{
|
||||
voice->Direct.Gains[c].Target[j] = DryGain;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if((idx=GetChannelIdxByName(Device->RealOut, chans[c].channel)) != -1)
|
||||
voice->Direct.Gains[c].Target[idx] = DryGain;
|
||||
}
|
||||
}
|
||||
else for(c = 0;c < num_channels;c++)
|
||||
@ -580,7 +575,7 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
|
||||
int idx;
|
||||
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
|
||||
voice->Direct.Gains[c].Target[j] = 0.0f;
|
||||
if((idx=GetChannelIdxByName(Device, chans[c].channel)) != -1)
|
||||
if((idx=GetChannelIdxByName(Device->Dry, chans[c].channel)) != -1)
|
||||
voice->Direct.Gains[c].Target[idx] = DryGain;
|
||||
}
|
||||
|
||||
@ -676,7 +671,7 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
|
||||
int idx;
|
||||
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
|
||||
voice->Direct.Gains[c].Target[j] = 0.0f;
|
||||
if((idx=GetChannelIdxByName(Device, chans[c].channel)) != -1)
|
||||
if((idx=GetChannelIdxByName(Device->Dry, chans[c].channel)) != -1)
|
||||
voice->Direct.Gains[c].Target[idx] = DryGain;
|
||||
|
||||
for(i = 0;i < NumSends;i++)
|
||||
|
@ -57,7 +57,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice *
|
||||
if(Slot->EffectType == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
|
||||
{
|
||||
int idx;
|
||||
if((idx=GetChannelIdxByName(device, LFE)) != -1)
|
||||
if((idx=GetChannelIdxByName(device->Dry, LFE)) != -1)
|
||||
state->gains[idx] = Gain;
|
||||
}
|
||||
else if(Slot->EffectType == AL_EFFECT_DEDICATED_DIALOGUE)
|
||||
@ -65,7 +65,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice *
|
||||
int idx;
|
||||
/* Dialog goes to the front-center speaker if it exists, otherwise it
|
||||
* plays from the front-center location. */
|
||||
if((idx=GetChannelIdxByName(device, FrontCenter)) != -1)
|
||||
if((idx=GetChannelIdxByName(device->Dry, FrontCenter)) != -1)
|
||||
state->gains[idx] = Gain;
|
||||
else
|
||||
{
|
||||
|
@ -534,7 +534,7 @@ ALvoid aluInitPanning(ALCdevice *device)
|
||||
|
||||
for(i = 0;i < device->Dry.NumChannels;i++)
|
||||
{
|
||||
int chan = GetChannelIdxByName(device, CubeInfo[i].Channel);
|
||||
int chan = GetChannelIdxByName(device->Dry, CubeInfo[i].Channel);
|
||||
GetLerpedHrtfCoeffs(device->Hrtf, CubeInfo[i].Elevation, CubeInfo[i].Angle, 1.0f, 1.0f,
|
||||
device->Hrtf_Params[chan].Coeffs, device->Hrtf_Params[chan].Delay);
|
||||
}
|
||||
|
@ -688,20 +688,20 @@ const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans) DECL_CONST;
|
||||
/**
|
||||
* GetChannelIdxByName
|
||||
*
|
||||
* Returns the dry buffer's channel index for the given channel name (e.g.
|
||||
* FrontCenter), or -1 if it doesn't exist.
|
||||
* Returns the index for the given channel name (e.g. FrontCenter), or -1 if it
|
||||
* doesn't exist.
|
||||
*/
|
||||
inline ALint GetChannelIdxByName(const ALCdevice *device, enum Channel chan)
|
||||
inline ALint GetChannelIndex(const enum Channel names[MAX_OUTPUT_CHANNELS], enum Channel chan)
|
||||
{
|
||||
ALint i = 0;
|
||||
ALint i;
|
||||
for(i = 0;i < MAX_OUTPUT_CHANNELS;i++)
|
||||
{
|
||||
if(device->Dry.ChannelName[i] == chan)
|
||||
if(names[i] == chan)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define GetChannelIdxByName(x, c) GetChannelIndex((x).ChannelName, (c))
|
||||
|
||||
extern FILE *LogFile;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user