Handle double-precision buffers in the mixer

This commit is contained in:
Chris Robinson
2018-01-21 18:34:03 -08:00
parent efd11f32a2
commit db13af1935
3 changed files with 13 additions and 29 deletions
+5
View File
@@ -202,6 +202,9 @@ static inline ALfloat Sample_ALshort(ALshort val)
static inline ALfloat Sample_ALfloat(ALfloat val)
{ return val; }
static inline ALfloat Sample_ALdouble(ALdouble val)
{ return (ALfloat)val; }
typedef ALubyte ALmulaw;
static inline ALfloat Sample_ALmulaw(ALmulaw val)
{ return muLawDecompressionTable[val] * (1.0f/32768.0f); }
@@ -222,6 +225,7 @@ static inline void Load_##T(ALfloat *restrict dst, const T *restrict src, \
DECL_TEMPLATE(ALubyte)
DECL_TEMPLATE(ALshort)
DECL_TEMPLATE(ALfloat)
DECL_TEMPLATE(ALdouble)
DECL_TEMPLATE(ALmulaw)
DECL_TEMPLATE(ALalaw)
@@ -236,6 +240,7 @@ static void LoadSamples(ALfloat *restrict dst, const ALvoid *restrict src, ALint
HANDLE_FMT(FmtUByte, ALubyte);
HANDLE_FMT(FmtShort, ALshort);
HANDLE_FMT(FmtFloat, ALfloat);
HANDLE_FMT(FmtDouble, ALdouble);
HANDLE_FMT(FmtMulaw, ALmulaw);
HANDLE_FMT(FmtAlaw, ALalaw);
}
+6 -5
View File
@@ -40,11 +40,12 @@ inline ALsizei FrameSizeFromUserFmt(enum UserFmtChannels chans, enum UserFmtType
/* Storable formats */
enum FmtType {
FmtUByte = UserFmtUByte,
FmtShort = UserFmtShort,
FmtFloat = UserFmtFloat,
FmtMulaw = UserFmtMulaw,
FmtAlaw = UserFmtAlaw,
FmtUByte = UserFmtUByte,
FmtShort = UserFmtShort,
FmtFloat = UserFmtFloat,
FmtDouble = UserFmtDouble,
FmtMulaw = UserFmtMulaw,
FmtAlaw = UserFmtAlaw,
};
enum FmtChannels {
FmtMono = UserFmtMono,
+2 -24
View File
@@ -173,6 +173,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoi
case UserFmtUByte:
case UserFmtShort:
case UserFmtFloat:
case UserFmtDouble:
case UserFmtMulaw:
case UserFmtAlaw:
framesize = FrameSizeFromUserFmt(srcchannels, srctype) * align;
@@ -186,30 +187,6 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoi
SET_ERROR_AND_GOTO(context, err, done);
break;
case UserFmtDouble:
framesize = FrameSizeFromUserFmt(srcchannels, srctype) * align;
if((size%framesize) != 0)
SET_ERROR_AND_GOTO(context, AL_INVALID_VALUE, done);
switch(srcchannels)
{
case UserFmtMono: newformat = AL_FORMAT_MONO_FLOAT32; break;
case UserFmtStereo: newformat = AL_FORMAT_STEREO_FLOAT32; break;
case UserFmtRear: newformat = AL_FORMAT_REAR32; break;
case UserFmtQuad: newformat = AL_FORMAT_QUAD32; break;
case UserFmtX51: newformat = AL_FORMAT_51CHN32; break;
case UserFmtX61: newformat = AL_FORMAT_61CHN32; break;
case UserFmtX71: newformat = AL_FORMAT_71CHN32; break;
case UserFmtBFormat2D: newformat = AL_FORMAT_BFORMAT2D_FLOAT32; break;
case UserFmtBFormat3D: newformat = AL_FORMAT_BFORMAT3D_FLOAT32; break;
}
err = LoadData(albuf, freq, newformat, size/framesize*align,
srcchannels, srctype, data, align, format&ACCESS_FLAGS,
AL_TRUE);
if(err != AL_NO_ERROR)
SET_ERROR_AND_GOTO(context, err, done);
break;
case UserFmtIMA4:
framesize = (align-1)/2 + 4;
framesize *= ChannelsFromUserFmt(srcchannels);
@@ -1141,6 +1118,7 @@ ALsizei BytesFromFmt(enum FmtType type)
case FmtUByte: return sizeof(ALubyte);
case FmtShort: return sizeof(ALshort);
case FmtFloat: return sizeof(ALfloat);
case FmtDouble: return sizeof(ALdouble);
case FmtMulaw: return sizeof(ALubyte);
case FmtAlaw: return sizeof(ALubyte);
}