aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-03-10 14:29:44 -0800
committerChris Robinson <[email protected]>2016-03-10 14:29:44 -0800
commitd648486bcd431b34ad68b76db400ff7e963c72e2 (patch)
tree6b4e2fab0b5c92cbef7800dc0efceb6459c942c4
parentda5f75615bf4dee38d456949b30b90921ad713c0 (diff)
Generalize GetChannelIdxByName
-rw-r--r--Alc/ALc.c2
-rw-r--r--Alc/ALu.c15
-rw-r--r--Alc/effects/dedicated.c4
-rw-r--r--Alc/panning.c2
-rw-r--r--OpenAL32/Include/alMain.h12
5 files changed, 15 insertions, 20 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 6074df4a..8ede026a 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 8ea74669..eb7afd90 100644
--- a/Alc/ALu.c
+++ b/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++)
diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c
index 2706a672..447e6b95 100644
--- a/Alc/effects/dedicated.c
+++ b/Alc/effects/dedicated.c
@@ -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
{
diff --git a/Alc/panning.c b/Alc/panning.c
index beb928d9..1765d1c8 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -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);
}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index fc55b93b..aae19b05 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -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;