Add a helper to search for a channel index by name
This commit is contained in:
@@ -1535,6 +1535,8 @@ void SetDefaultChannelOrder(ALCdevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
extern inline ALint GetChannelIdxByName(const ALCdevice *device, enum Channel chan);
|
||||
|
||||
|
||||
/* alcSetError
|
||||
*
|
||||
|
||||
@@ -409,15 +409,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
|
||||
|
||||
for(j = 0;j < MaxChannels;j++)
|
||||
gains[j].Target = 0.0f;
|
||||
for(i = 0;i < (ALint)Device->NumSpeakers;i++)
|
||||
{
|
||||
enum Channel chan = Device->Speaker[i].ChanName;
|
||||
if(chan == chans[c].channel)
|
||||
{
|
||||
gains[chan].Target = DryGain;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(GetChannelIdxByName(Device, chans[c].channel) != -1)
|
||||
gains[chans[c].channel].Target = DryGain;
|
||||
}
|
||||
UpdateDryStepping(&voice->Direct, num_channels);
|
||||
|
||||
@@ -467,7 +460,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A
|
||||
{
|
||||
for(i = 0;i < MaxChannels;i++)
|
||||
Target[i] = 0.0f;
|
||||
Target[chans[c].channel] = DryGain;
|
||||
if(GetChannelIdxByName(Device, chans[c].channel) != -1)
|
||||
Target[chans[c].channel] = DryGain;
|
||||
ok = true;
|
||||
}
|
||||
else for(i = 0;i < (ALint)Device->NumSpeakers;i++)
|
||||
|
||||
+7
-11
@@ -55,21 +55,17 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, ALCdevice *device
|
||||
|
||||
Gain = Slot->Gain * Slot->EffectProps.Dedicated.Gain;
|
||||
if(Slot->EffectType == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
|
||||
state->gains[LFE] = Gain;
|
||||
{
|
||||
if(GetChannelIdxByName(device, LFE) != -1)
|
||||
state->gains[LFE] = Gain;
|
||||
}
|
||||
else if(Slot->EffectType == AL_EFFECT_DEDICATED_DIALOGUE)
|
||||
{
|
||||
ALboolean done = AL_FALSE;
|
||||
/* Dialog goes to the front-center speaker if it exists, otherwise it
|
||||
* plays from the front-center location. */
|
||||
for(i = 0;i < device->NumSpeakers;i++)
|
||||
{
|
||||
if(device->Speaker[i].ChanName == FrontCenter)
|
||||
{
|
||||
state->gains[FrontCenter] = Gain;
|
||||
done = AL_TRUE;
|
||||
}
|
||||
}
|
||||
if(!done)
|
||||
if(GetChannelIdxByName(device, FrontCenter) != -1)
|
||||
state->gains[FrontCenter] = Gain;
|
||||
else
|
||||
{
|
||||
static const ALfloat front_dir[3] = { 0.0f, 0.0f, -1.0f };
|
||||
ComputeDirectionalGains(device, front_dir, Gain, state->gains);
|
||||
|
||||
@@ -828,6 +828,23 @@ void SetDefaultWFXChannelOrder(ALCdevice *device);
|
||||
const ALCchar *DevFmtTypeString(enum DevFmtType type) DECL_CONST;
|
||||
const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans) DECL_CONST;
|
||||
|
||||
/**
|
||||
* GetChannelIdxByName
|
||||
*
|
||||
* Returns the device's channel index given a channel name (e.g. FrontCenter),
|
||||
* or -1 if it doesn't exist.
|
||||
*/
|
||||
inline ALint GetChannelIdxByName(const ALCdevice *device, enum Channel chan)
|
||||
{
|
||||
ALint i = 0;
|
||||
for(i = 0;i < MaxChannels;i++)
|
||||
{
|
||||
if(device->ChannelName[i] == chan)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
extern FILE *LogFile;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user