aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-11-04 04:41:11 -0800
committerChris Robinson <[email protected]>2012-11-04 04:41:11 -0800
commite2368eb960ba1a43f365103a69e03803b8171731 (patch)
tree17c5f08eaf3b45f4903bea71db56362faed3afa7 /Alc
parent3e71a7cb9473cc403ad324d7e8468e2d6abd7de6 (diff)
Use an array to specify the offset for each channel of the device buffer
This effectively inverts the DevChannels array
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c120
-rw-r--r--Alc/ALu.c13
2 files changed, 73 insertions, 60 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index c93d6758..39296eb5 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1287,48 +1287,54 @@ ALint64 ALCdevice_GetLatencyDefault(ALCdevice *device)
*/
void SetDefaultWFXChannelOrder(ALCdevice *device)
{
+ ALuint i;
+
+ for(i = 0;i < MaxChannels;i++)
+ device->ChannelOffsets[i] = INVALID_OFFSET;
+
switch(device->FmtChans)
{
- case DevFmtMono: device->DevChannels[0] = FrontCenter; break;
-
- case DevFmtStereo: device->DevChannels[0] = FrontLeft;
- device->DevChannels[1] = FrontRight; break;
-
- case DevFmtQuad: device->DevChannels[0] = FrontLeft;
- device->DevChannels[1] = FrontRight;
- device->DevChannels[2] = BackLeft;
- device->DevChannels[3] = BackRight; break;
-
- case DevFmtX51: device->DevChannels[0] = FrontLeft;
- device->DevChannels[1] = FrontRight;
- device->DevChannels[2] = FrontCenter;
- device->DevChannels[3] = LFE;
- device->DevChannels[4] = BackLeft;
- device->DevChannels[5] = BackRight; break;
-
- case DevFmtX51Side: device->DevChannels[0] = FrontLeft;
- device->DevChannels[1] = FrontRight;
- device->DevChannels[2] = FrontCenter;
- device->DevChannels[3] = LFE;
- device->DevChannels[4] = SideLeft;
- device->DevChannels[5] = SideRight; break;
-
- case DevFmtX61: device->DevChannels[0] = FrontLeft;
- device->DevChannels[1] = FrontRight;
- device->DevChannels[2] = FrontCenter;
- device->DevChannels[3] = LFE;
- device->DevChannels[4] = BackCenter;
- device->DevChannels[5] = SideLeft;
- device->DevChannels[6] = SideRight; break;
-
- case DevFmtX71: device->DevChannels[0] = FrontLeft;
- device->DevChannels[1] = FrontRight;
- device->DevChannels[2] = FrontCenter;
- device->DevChannels[3] = LFE;
- device->DevChannels[4] = BackLeft;
- device->DevChannels[5] = BackRight;
- device->DevChannels[6] = SideLeft;
- device->DevChannels[7] = SideRight; break;
+ case DevFmtMono: device->ChannelOffsets[FrontCenter] = 0;
+ break;
+ case DevFmtStereo: device->ChannelOffsets[FrontLeft] = 0;
+ device->ChannelOffsets[FrontRight] = 1;
+ break;
+ case DevFmtQuad: device->ChannelOffsets[FrontLeft] = 0;
+ device->ChannelOffsets[FrontRight] = 1;
+ device->ChannelOffsets[BackLeft] = 2;
+ device->ChannelOffsets[BackRight] = 3;
+ 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;
+ 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;
+ 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;
+ 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;
+ break;
}
}
@@ -1338,24 +1344,28 @@ void SetDefaultWFXChannelOrder(ALCdevice *device)
*/
void SetDefaultChannelOrder(ALCdevice *device)
{
+ ALuint i;
+
+ for(i = 0;i < MaxChannels;i++)
+ device->ChannelOffsets[i] = INVALID_OFFSET;
+
switch(device->FmtChans)
{
- case DevFmtX51: device->DevChannels[0] = FrontLeft;
- device->DevChannels[1] = FrontRight;
- device->DevChannels[2] = BackLeft;
- device->DevChannels[3] = BackRight;
- device->DevChannels[4] = FrontCenter;
- device->DevChannels[5] = LFE;
+ 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;
return;
-
- case DevFmtX71: device->DevChannels[0] = FrontLeft;
- device->DevChannels[1] = FrontRight;
- device->DevChannels[2] = BackLeft;
- device->DevChannels[3] = BackRight;
- device->DevChannels[4] = FrontCenter;
- device->DevChannels[5] = LFE;
- device->DevChannels[6] = SideLeft;
- device->DevChannels[7] = SideRight;
+ 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;
return;
/* Same as WFX order */
diff --git a/Alc/ALu.c b/Alc/ALu.c
index e0e5f8a3..a44c04b3 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -931,16 +931,19 @@ static int Write_##T(ALCdevice *device, T *RESTRICT buffer, \
{ \
ALfloat (*RESTRICT DryBuffer)[BUFFERSIZE] = device->DryBuffer; \
ALuint numchans = ChannelsFromDevFmt(device->FmtChans); \
- const enum Channel *ChanMap = device->DevChannels; \
+ const ALuint *offsets = device->ChannelOffsets; \
ALuint i, j; \
\
- for(j = 0;j < numchans;j++) \
+ for(j = 0;j < MaxChannels;j++) \
{ \
- T *RESTRICT out = buffer + j; \
- enum Channel chan = ChanMap[j]; \
+ T *RESTRICT out; \
\
+ if(offsets[j] == INVALID_OFFSET) \
+ continue; \
+ \
+ out = buffer + offsets[j]; \
for(i = 0;i < SamplesToDo;i++) \
- out[i*numchans] = func(DryBuffer[chan][i]); \
+ out[i*numchans] = func(DryBuffer[j][i]); \
} \
return SamplesToDo*numchans*sizeof(T); \
}