aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/Include/alu.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-01-12 01:25:33 -0800
committerChris Robinson <[email protected]>2019-01-12 01:25:33 -0800
commitd64eaba3229f48a519586c0436235e3c2809329b (patch)
treed578ef76627df78c0ec7b1ef2bca1fd1e8af0db1 /OpenAL32/Include/alu.h
parentab1667146627e93688cfeb4cf877764f220c0c3e (diff)
Use a flexible array for DirectHrtfState and ALvoice
Diffstat (limited to 'OpenAL32/Include/alu.h')
-rw-r--r--OpenAL32/Include/alu.h113
1 files changed, 62 insertions, 51 deletions
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index eef7126d..d8e288f1 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -24,6 +24,56 @@
#include "almalloc.h"
+constexpr inline ALfloat minf(ALfloat a, ALfloat b) noexcept
+{ return ((a > b) ? b : a); }
+constexpr inline ALfloat maxf(ALfloat a, ALfloat b) noexcept
+{ return ((a > b) ? a : b); }
+constexpr inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max) noexcept
+{ return minf(max, maxf(min, val)); }
+
+constexpr inline ALdouble mind(ALdouble a, ALdouble b) noexcept
+{ return ((a > b) ? b : a); }
+constexpr inline ALdouble maxd(ALdouble a, ALdouble b) noexcept
+{ return ((a > b) ? a : b); }
+constexpr inline ALdouble clampd(ALdouble val, ALdouble min, ALdouble max) noexcept
+{ return mind(max, maxd(min, val)); }
+
+constexpr inline ALuint minu(ALuint a, ALuint b) noexcept
+{ return ((a > b) ? b : a); }
+constexpr inline ALuint maxu(ALuint a, ALuint b) noexcept
+{ return ((a > b) ? a : b); }
+constexpr inline ALuint clampu(ALuint val, ALuint min, ALuint max) noexcept
+{ return minu(max, maxu(min, val)); }
+
+constexpr inline ALint mini(ALint a, ALint b) noexcept
+{ return ((a > b) ? b : a); }
+constexpr inline ALint maxi(ALint a, ALint b) noexcept
+{ return ((a > b) ? a : b); }
+constexpr inline ALint clampi(ALint val, ALint min, ALint max) noexcept
+{ return mini(max, maxi(min, val)); }
+
+constexpr inline ALint64 mini64(ALint64 a, ALint64 b) noexcept
+{ return ((a > b) ? b : a); }
+constexpr inline ALint64 maxi64(ALint64 a, ALint64 b) noexcept
+{ return ((a > b) ? a : b); }
+constexpr inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max) noexcept
+{ return mini64(max, maxi64(min, val)); }
+
+constexpr inline ALuint64 minu64(ALuint64 a, ALuint64 b) noexcept
+{ return ((a > b) ? b : a); }
+constexpr inline ALuint64 maxu64(ALuint64 a, ALuint64 b) noexcept
+{ return ((a > b) ? a : b); }
+constexpr inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max) noexcept
+{ return minu64(max, maxu64(min, val)); }
+
+constexpr inline size_t minz(size_t a, size_t b) noexcept
+{ return ((a > b) ? b : a); }
+constexpr inline size_t maxz(size_t a, size_t b) noexcept
+{ return ((a > b) ? a : b); }
+constexpr inline size_t clampz(size_t val, size_t min, size_t max) noexcept
+{ return minz(max, maxz(min, val)); }
+
+
enum class DistanceModel;
#define MAX_PITCH 255
@@ -267,7 +317,18 @@ struct ALvoice {
ALfloat (*Buffer)[BUFFERSIZE];
ALsizei Channels;
- } Send[];
+ };
+ al::FlexArray<SendData> Send;
+
+ ALvoice(size_t numsends) : Send{numsends} { }
+ ALvoice(const ALvoice&) = delete;
+ ALvoice& operator=(const ALvoice&) = delete;
+
+ static constexpr size_t Sizeof(size_t numsends) noexcept
+ {
+ return maxz(sizeof(ALvoice),
+ al::FlexArray<SendData>::Sizeof(numsends, offsetof(ALvoice, Send)));
+ }
};
void DeinitVoice(ALvoice *voice) noexcept;
@@ -306,56 +367,6 @@ using HrtfDirectMixerFunc = void(*)(ALfloat *RESTRICT LeftOut, ALfloat *RESTRICT
#define FRACTIONMASK (FRACTIONONE-1)
-constexpr inline ALfloat minf(ALfloat a, ALfloat b) noexcept
-{ return ((a > b) ? b : a); }
-constexpr inline ALfloat maxf(ALfloat a, ALfloat b) noexcept
-{ return ((a > b) ? a : b); }
-constexpr inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max) noexcept
-{ return minf(max, maxf(min, val)); }
-
-constexpr inline ALdouble mind(ALdouble a, ALdouble b) noexcept
-{ return ((a > b) ? b : a); }
-constexpr inline ALdouble maxd(ALdouble a, ALdouble b) noexcept
-{ return ((a > b) ? a : b); }
-constexpr inline ALdouble clampd(ALdouble val, ALdouble min, ALdouble max) noexcept
-{ return mind(max, maxd(min, val)); }
-
-constexpr inline ALuint minu(ALuint a, ALuint b) noexcept
-{ return ((a > b) ? b : a); }
-constexpr inline ALuint maxu(ALuint a, ALuint b) noexcept
-{ return ((a > b) ? a : b); }
-constexpr inline ALuint clampu(ALuint val, ALuint min, ALuint max) noexcept
-{ return minu(max, maxu(min, val)); }
-
-constexpr inline ALint mini(ALint a, ALint b) noexcept
-{ return ((a > b) ? b : a); }
-constexpr inline ALint maxi(ALint a, ALint b) noexcept
-{ return ((a > b) ? a : b); }
-constexpr inline ALint clampi(ALint val, ALint min, ALint max) noexcept
-{ return mini(max, maxi(min, val)); }
-
-constexpr inline ALint64 mini64(ALint64 a, ALint64 b) noexcept
-{ return ((a > b) ? b : a); }
-constexpr inline ALint64 maxi64(ALint64 a, ALint64 b) noexcept
-{ return ((a > b) ? a : b); }
-constexpr inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max) noexcept
-{ return mini64(max, maxi64(min, val)); }
-
-constexpr inline ALuint64 minu64(ALuint64 a, ALuint64 b) noexcept
-{ return ((a > b) ? b : a); }
-constexpr inline ALuint64 maxu64(ALuint64 a, ALuint64 b) noexcept
-{ return ((a > b) ? a : b); }
-constexpr inline ALuint64 clampu64(ALuint64 val, ALuint64 min, ALuint64 max) noexcept
-{ return minu64(max, maxu64(min, val)); }
-
-constexpr inline size_t minz(size_t a, size_t b) noexcept
-{ return ((a > b) ? b : a); }
-constexpr inline size_t maxz(size_t a, size_t b) noexcept
-{ return ((a > b) ? a : b); }
-constexpr inline size_t clampz(size_t val, size_t min, size_t max) noexcept
-{ return minz(max, maxz(min, val)); }
-
-
inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu) noexcept
{ return val1 + (val2-val1)*mu; }
inline ALfloat cubic(ALfloat val1, ALfloat val2, ALfloat val3, ALfloat val4, ALfloat mu) noexcept