Use a separate value for the maximum buffer channels
Unlike the device, input buffers are accessed based on channel numbers instead of enums. This means the maximum number of channels they hold depends on the number of channels any one format can have, rather than the total number of recognized channels. Currently, this is 8 for 7.1.
This commit is contained in:
@@ -313,7 +313,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
|
||||
}
|
||||
|
||||
SrcMatrix = ALSource->Params.Direct.Gains;
|
||||
for(i = 0;i < MaxChannels;i++)
|
||||
for(i = 0;i < MAX_INPUT_CHANNELS;i++)
|
||||
{
|
||||
for(c = 0;c < MaxChannels;c++)
|
||||
SrcMatrix[i][c] = 0.0f;
|
||||
@@ -859,7 +859,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
|
||||
ALfloat DirGain = 0.0f;
|
||||
ALfloat AmbientGain;
|
||||
|
||||
for(i = 0;i < MaxChannels;i++)
|
||||
for(i = 0;i < MAX_INPUT_CHANNELS;i++)
|
||||
{
|
||||
for(j = 0;j < MaxChannels;j++)
|
||||
Matrix[i][j] = 0.0f;
|
||||
|
||||
+2
-2
@@ -96,7 +96,7 @@ void MixDirect_C(const DirectParams *params, const ALfloat *restrict data, ALuin
|
||||
for(c = 0;c < MaxChannels;c++)
|
||||
{
|
||||
DrySend = params->Gains[srcchan][c];
|
||||
if(DrySend < 0.00001f)
|
||||
if(!(DrySend > 0.00001f))
|
||||
continue;
|
||||
|
||||
if(OutPos == 0)
|
||||
@@ -119,7 +119,7 @@ void MixSend_C(const SendParams *params, const ALfloat *restrict data,
|
||||
ALfloat WetSend = params->Gain;
|
||||
ALuint pos;
|
||||
|
||||
if(WetSend < 0.00001f)
|
||||
if(!(WetSend > 0.00001f))
|
||||
return;
|
||||
|
||||
if(OutPos == 0)
|
||||
|
||||
+2
-2
@@ -155,7 +155,7 @@ void MixDirect_SSE(const DirectParams *params, const ALfloat *restrict data, ALu
|
||||
__m128 gain;
|
||||
|
||||
DrySend = params->Gains[srcchan][c];
|
||||
if(DrySend < 0.00001f)
|
||||
if(!(DrySend > 0.00001f))
|
||||
continue;
|
||||
|
||||
if(OutPos == 0)
|
||||
@@ -189,7 +189,7 @@ void MixSend_SSE(const SendParams *params, const ALfloat *restrict data,
|
||||
__m128 gain;
|
||||
ALuint pos;
|
||||
|
||||
if(WetGain < 0.00001f)
|
||||
if(!(WetGain > 0.00001f))
|
||||
return;
|
||||
|
||||
if(OutPos == 0)
|
||||
|
||||
@@ -57,6 +57,7 @@ enum FmtChannels {
|
||||
FmtX61 = UserFmtX61,
|
||||
FmtX71 = UserFmtX71,
|
||||
};
|
||||
#define MAX_INPUT_CHANNELS (8)
|
||||
|
||||
ALuint BytesFromFmt(enum FmtType type);
|
||||
ALuint ChannelsFromFmt(enum FmtChannels chans);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "alMain.h"
|
||||
#include "alu.h"
|
||||
#include "alFilter.h"
|
||||
#include "alBuffer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -31,17 +32,17 @@ typedef struct ALbufferlistitem
|
||||
typedef struct HrtfState {
|
||||
ALboolean Moving;
|
||||
ALuint Counter;
|
||||
ALIGN(16) ALfloat History[MaxChannels][SRC_HISTORY_LENGTH];
|
||||
ALIGN(16) ALfloat Values[MaxChannels][HRIR_LENGTH][2];
|
||||
ALIGN(16) ALfloat History[MAX_INPUT_CHANNELS][SRC_HISTORY_LENGTH];
|
||||
ALIGN(16) ALfloat Values[MAX_INPUT_CHANNELS][HRIR_LENGTH][2];
|
||||
ALuint Offset;
|
||||
} HrtfState;
|
||||
|
||||
typedef struct HrtfParams {
|
||||
ALfloat Gain;
|
||||
ALfloat Dir[3];
|
||||
ALIGN(16) ALfloat Coeffs[MaxChannels][HRIR_LENGTH][2];
|
||||
ALIGN(16) ALfloat Coeffs[MAX_INPUT_CHANNELS][HRIR_LENGTH][2];
|
||||
ALIGN(16) ALfloat CoeffStep[HRIR_LENGTH][2];
|
||||
ALuint Delay[MaxChannels][2];
|
||||
ALuint Delay[MAX_INPUT_CHANNELS][2];
|
||||
ALint DelayStep[2];
|
||||
ALuint IrSize;
|
||||
} HrtfParams;
|
||||
@@ -59,9 +60,9 @@ typedef struct DirectParams {
|
||||
/* A mixing matrix. First subscript is the channel number of the input data
|
||||
* (regardless of channel configuration) and the second is the channel
|
||||
* target (eg. FrontLeft). Not used with HRTF. */
|
||||
ALfloat Gains[MaxChannels][MaxChannels];
|
||||
ALfloat Gains[MAX_INPUT_CHANNELS][MaxChannels];
|
||||
|
||||
ALfilterState Filter[MaxChannels];
|
||||
ALfilterState Filter[MAX_INPUT_CHANNELS];
|
||||
} DirectParams;
|
||||
|
||||
typedef struct SendParams {
|
||||
@@ -71,7 +72,7 @@ typedef struct SendParams {
|
||||
* output buffer. */
|
||||
ALfloat Gain;
|
||||
|
||||
ALfilterState Filter[MaxChannels];
|
||||
ALfilterState Filter[MAX_INPUT_CHANNELS];
|
||||
} SendParams;
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -1087,8 +1087,8 @@ static ALalaw EncodeALaw(ALshort val)
|
||||
|
||||
static void DecodeIMA4Block(ALshort *dst, const ALima4 *src, ALint numchans)
|
||||
{
|
||||
ALint sample[MaxChannels], index[MaxChannels];
|
||||
ALuint code[MaxChannels];
|
||||
ALint sample[MAX_INPUT_CHANNELS], index[MAX_INPUT_CHANNELS];
|
||||
ALuint code[MAX_INPUT_CHANNELS];
|
||||
ALsizei j,k,c;
|
||||
|
||||
for(c = 0;c < numchans;c++)
|
||||
@@ -1749,7 +1749,7 @@ DECL_TEMPLATE(ALubyte3, ALubyte3)
|
||||
static void Convert_##T##_ALima4(T *dst, const ALima4 *src, ALuint numchans, \
|
||||
ALuint len) \
|
||||
{ \
|
||||
ALshort tmp[65*MaxChannels]; /* Max samples an IMA4 frame can be */ \
|
||||
ALshort tmp[65*MAX_INPUT_CHANNELS]; /* Max samples an IMA4 frame can be */\
|
||||
ALuint i, j, k; \
|
||||
\
|
||||
i = 0; \
|
||||
@@ -1785,7 +1785,7 @@ DECL_TEMPLATE(ALubyte3)
|
||||
static void Convert_ALima4_##T(ALima4 *dst, const T *src, ALuint numchans, \
|
||||
ALuint len) \
|
||||
{ \
|
||||
ALshort tmp[65*MaxChannels]; /* Max samples an IMA4 frame can be */ \
|
||||
ALshort tmp[65*MAX_INPUT_CHANNELS]; /* Max samples an IMA4 frame can be */\
|
||||
ALint sample[MaxChannels] = {0,0,0,0,0,0,0,0}; \
|
||||
ALint index[MaxChannels] = {0,0,0,0,0,0,0,0}; \
|
||||
ALuint i, j; \
|
||||
|
||||
+1
-1
@@ -2326,7 +2326,7 @@ ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state)
|
||||
|
||||
if(Source->state != AL_PLAYING)
|
||||
{
|
||||
for(j = 0;j < MaxChannels;j++)
|
||||
for(j = 0;j < MAX_INPUT_CHANNELS;j++)
|
||||
{
|
||||
for(k = 0;k < SRC_HISTORY_LENGTH;k++)
|
||||
Source->Hrtf.History[j][k] = 0.0f;
|
||||
|
||||
Reference in New Issue
Block a user