summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-09-10 16:52:54 -0700
committerChris Robinson <[email protected]>2014-09-10 16:52:54 -0700
commit01adfde1994c5482305b5ce54ffd921988a84616 (patch)
tree1f0fc7b4c54e9b485993884512b90bfe37794138
parent49cb2421c71e3ef22d81ddfc3eac65e464eaeb2d (diff)
Invert the ChannelOffsets array
-rw-r--r--Alc/ALc.c102
-rw-r--r--Alc/ALu.c11
-rw-r--r--OpenAL32/Include/alMain.h3
3 files changed, 60 insertions, 56 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 4d4d8e4e..fdc7bcbf 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1449,50 +1449,50 @@ void SetDefaultWFXChannelOrder(ALCdevice *device)
ALuint i;
for(i = 0;i < MaxChannels;i++)
- device->ChannelOffsets[i] = INVALID_OFFSET;
+ device->ChannelName[i] = InvalidChannel;
switch(device->FmtChans)
{
- case DevFmtMono: device->ChannelOffsets[FrontCenter] = 0;
+ case DevFmtMono: device->ChannelName[0] = FrontCenter;
break;
- case DevFmtStereo: device->ChannelOffsets[FrontLeft] = 0;
- device->ChannelOffsets[FrontRight] = 1;
+ case DevFmtStereo: device->ChannelName[0] = FrontLeft;
+ device->ChannelName[1] = FrontRight;
break;
- case DevFmtQuad: device->ChannelOffsets[FrontLeft] = 0;
- device->ChannelOffsets[FrontRight] = 1;
- device->ChannelOffsets[BackLeft] = 2;
- device->ChannelOffsets[BackRight] = 3;
+ case DevFmtQuad: device->ChannelName[0] = FrontLeft;
+ device->ChannelName[1] = FrontRight;
+ device->ChannelName[2] = BackLeft;
+ device->ChannelName[3] = BackRight;
break;
- case DevFmtX51: device->ChannelOffsets[FrontLeft] = 0;
- device->ChannelOffsets[FrontRight] = 1;
- device->ChannelOffsets[FrontCenter] = 2;
- device->ChannelOffsets[LFE] = 3;
- device->ChannelOffsets[BackLeft] = 4;
- device->ChannelOffsets[BackRight] = 5;
+ case DevFmtX51: device->ChannelName[0] = FrontLeft;
+ device->ChannelName[1] = FrontRight;
+ device->ChannelName[2] = FrontCenter;
+ device->ChannelName[3] = LFE;
+ device->ChannelName[4] = BackLeft;
+ device->ChannelName[5] = BackRight;
break;
- case DevFmtX51Side: device->ChannelOffsets[FrontLeft] = 0;
- device->ChannelOffsets[FrontRight] = 1;
- device->ChannelOffsets[FrontCenter] = 2;
- device->ChannelOffsets[LFE] = 3;
- device->ChannelOffsets[SideLeft] = 4;
- device->ChannelOffsets[SideRight] = 5;
+ case DevFmtX51Side: device->ChannelName[0] = FrontLeft;
+ device->ChannelName[1] = FrontRight;
+ device->ChannelName[2] = FrontCenter;
+ device->ChannelName[3] = LFE;
+ device->ChannelName[4] = SideLeft;
+ device->ChannelName[5] = SideRight;
break;
- case DevFmtX61: device->ChannelOffsets[FrontLeft] = 0;
- device->ChannelOffsets[FrontRight] = 1;
- device->ChannelOffsets[FrontCenter] = 2;
- device->ChannelOffsets[LFE] = 3;
- device->ChannelOffsets[BackCenter] = 4;
- device->ChannelOffsets[SideLeft] = 5;
- device->ChannelOffsets[SideRight] = 6;
+ case DevFmtX61: device->ChannelName[0] = FrontLeft;
+ device->ChannelName[1] = FrontRight;
+ device->ChannelName[2] = FrontCenter;
+ device->ChannelName[3] = LFE;
+ device->ChannelName[4] = BackCenter;
+ device->ChannelName[5] = SideLeft;
+ device->ChannelName[6] = SideRight;
break;
- case DevFmtX71: device->ChannelOffsets[FrontLeft] = 0;
- device->ChannelOffsets[FrontRight] = 1;
- device->ChannelOffsets[FrontCenter] = 2;
- device->ChannelOffsets[LFE] = 3;
- device->ChannelOffsets[BackLeft] = 4;
- device->ChannelOffsets[BackRight] = 5;
- device->ChannelOffsets[SideLeft] = 6;
- device->ChannelOffsets[SideRight] = 7;
+ case DevFmtX71: device->ChannelName[0] = FrontLeft;
+ device->ChannelName[1] = FrontRight;
+ device->ChannelName[2] = FrontCenter;
+ device->ChannelName[3] = LFE;
+ device->ChannelName[4] = BackLeft;
+ device->ChannelName[5] = BackRight;
+ device->ChannelName[6] = SideLeft;
+ device->ChannelName[7] = SideRight;
break;
}
}
@@ -1506,25 +1506,25 @@ void SetDefaultChannelOrder(ALCdevice *device)
ALuint i;
for(i = 0;i < MaxChannels;i++)
- device->ChannelOffsets[i] = INVALID_OFFSET;
+ device->ChannelName[i] = InvalidChannel;
switch(device->FmtChans)
{
- case DevFmtX51: device->ChannelOffsets[FrontLeft] = 0;
- device->ChannelOffsets[FrontRight] = 1;
- device->ChannelOffsets[BackLeft] = 2;
- device->ChannelOffsets[BackRight] = 3;
- device->ChannelOffsets[FrontCenter] = 4;
- device->ChannelOffsets[LFE] = 5;
+ case DevFmtX51: device->ChannelName[0] = FrontLeft;
+ device->ChannelName[1] = FrontRight;
+ device->ChannelName[2] = BackLeft;
+ device->ChannelName[3] = BackRight;
+ device->ChannelName[4] = FrontCenter;
+ device->ChannelName[5] = LFE;
return;
- case DevFmtX71: device->ChannelOffsets[FrontLeft] = 0;
- device->ChannelOffsets[FrontRight] = 1;
- device->ChannelOffsets[BackLeft] = 2;
- device->ChannelOffsets[BackRight] = 3;
- device->ChannelOffsets[FrontCenter] = 4;
- device->ChannelOffsets[LFE] = 5;
- device->ChannelOffsets[SideLeft] = 6;
- device->ChannelOffsets[SideRight] = 7;
+ case DevFmtX71: device->ChannelName[0] = FrontLeft;
+ device->ChannelName[1] = FrontRight;
+ device->ChannelName[2] = BackLeft;
+ device->ChannelName[3] = BackRight;
+ device->ChannelName[4] = FrontCenter;
+ device->ChannelName[5] = LFE;
+ device->ChannelName[6] = SideLeft;
+ device->ChannelName[7] = SideRight;
return;
/* Same as WFX order */
@@ -1533,9 +1533,9 @@ void SetDefaultChannelOrder(ALCdevice *device)
case DevFmtQuad:
case DevFmtX51Side:
case DevFmtX61:
+ SetDefaultWFXChannelOrder(device);
break;
}
- SetDefaultWFXChannelOrder(device);
}
diff --git a/Alc/ALu.c b/Alc/ALu.c
index b7311d8a..f3641226 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1108,19 +1108,22 @@ static void Write_##T(ALCdevice *device, ALvoid **buffer, ALuint SamplesToDo) \
{ \
ALfloat (*restrict DryBuffer)[BUFFERSIZE] = device->DryBuffer; \
const ALuint numchans = ChannelsFromDevFmt(device->FmtChans); \
- const ALuint *offsets = device->ChannelOffsets; \
+ const enum Channel *chans = device->ChannelName; \
ALuint i, j; \
\
for(j = 0;j < MaxChannels;j++) \
{ \
+ const enum Channel c = chans[j]; \
+ const ALfloat *in; \
T *restrict out; \
\
- if(offsets[j] == INVALID_OFFSET) \
+ if(c == InvalidChannel) \
continue; \
\
- out = (T*)(*buffer) + offsets[j]; \
+ in = DryBuffer[c]; \
+ out = (T*)(*buffer) + j; \
for(i = 0;i < SamplesToDo;i++) \
- out[i*numchans] = func(DryBuffer[j][i]); \
+ out[i*numchans] = func(in[i]); \
} \
*buffer = (char*)(*buffer) + SamplesToDo*numchans*sizeof(T); \
}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 3089763f..d2bb6985 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -525,6 +525,7 @@ enum Channel {
SideRight,
MaxChannels,
+ InvalidChannel = MaxChannels
};
@@ -645,7 +646,7 @@ struct ALCdevice_struct
// Device flags
ALuint Flags;
- ALuint ChannelOffsets[MaxChannels];
+ enum Channel ChannelName[MaxChannels];
enum Channel Speaker2Chan[MaxChannels];
ALfloat SpeakerAngle[MaxChannels];