diff options
-rw-r--r-- | Alc/ALc.c | 120 | ||||
-rw-r--r-- | Alc/ALu.c | 13 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 6 |
3 files changed, 78 insertions, 61 deletions
@@ -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 */ @@ -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); \ } diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index b0f0135f..00512997 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -603,7 +603,7 @@ struct ALCdevice_struct // Device flags ALuint Flags; - enum Channel DevChannels[MaxChannels]; + ALuint ChannelOffsets[MaxChannels]; enum Channel Speaker2Chan[MaxChannels]; ALfloat SpeakerAngle[MaxChannels]; @@ -659,6 +659,10 @@ struct ALCdevice_struct // Specifies if the device is currently running #define DEVICE_RUNNING (1<<31) +/* Invalid channel offset */ +#define INVALID_OFFSET (~0u) + + #define LookupBuffer(m, k) ((struct ALbuffer*)LookupUIntMapKey(&(m)->BufferMap, (k))) #define LookupEffect(m, k) ((struct ALeffect*)LookupUIntMapKey(&(m)->EffectMap, (k))) #define LookupFilter(m, k) ((struct ALfilter*)LookupUIntMapKey(&(m)->FilterMap, (k))) |