diff options
author | Chris Robinson <[email protected]> | 2018-11-21 05:06:31 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-21 05:06:31 -0800 |
commit | 757c42c74bb1f88dfc6f24200382a0ea741fccac (patch) | |
tree | 0907ea85e05f27a19e83794046bc85d474013d7d /OpenAL32/Include/alMain.h | |
parent | 4c64fa1e4e11f39f7b6634e24dee13bb7434927c (diff) |
Use a normal vector for the distance buffer storage
Diffstat (limited to 'OpenAL32/Include/alMain.h')
-rw-r--r-- | OpenAL32/Include/alMain.h | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index c7bdcc2a..e6ad849e 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -556,11 +556,34 @@ typedef struct EnumeratedHrtf { /* Maximum delay in samples for speaker distance compensation. */ #define MAX_DELAY_LENGTH 1024 -typedef struct DistanceComp { - ALfloat Gain{1.0f}; - ALsizei Length{0}; /* Valid range is [0...MAX_DELAY_LENGTH). */ - ALfloat *Buffer{nullptr}; -} DistanceComp; +class DistanceComp { + struct DistData { + ALfloat Gain{1.0f}; + ALsizei Length{0}; /* Valid range is [0...MAX_DELAY_LENGTH). */ + ALfloat *Buffer{nullptr}; + } mChannel[MAX_OUTPUT_CHANNELS]; + al::vector<ALfloat,16> mSamples; + +public: + void resize(size_t amt) { mSamples.resize(amt); } + void shrink_to_fit() { mSamples.shrink_to_fit(); } + void clear() noexcept + { + for(auto &chan : mChannel) + { + chan.Gain = 1.0f; + chan.Length = 0; + chan.Buffer = nullptr; + } + mSamples.clear(); + } + + ALfloat *data() noexcept { return mSamples.data(); } + const ALfloat *data() const noexcept { return mSamples.data(); } + + DistData& operator[](size_t o) noexcept { return mChannel[o]; } + const DistData& operator[](size_t o) const noexcept { return mChannel[o]; } +}; /* Size for temporary storage of buffer data, in ALfloats. Larger values need * more memory, while smaller values may need more iterations. The value needs @@ -695,7 +718,7 @@ struct ALCdevice_struct { ALfloat AvgSpeakerDist{0.0f}; /* Delay buffers used to compensate for speaker distances. */ - DistanceComp ChannelDelay[MAX_OUTPUT_CHANNELS]; + DistanceComp ChannelDelay; /* Dithering control. */ ALfloat DitherDepth{0.0f}; |