aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alcmain.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-12-27 11:30:45 -0800
committerChris Robinson <[email protected]>2020-12-27 11:30:45 -0800
commit04358890d9de4182599688a13b12dfb02aae6dca (patch)
tree365b1a2a7e6056a91261cd7e2e084e037cf8aa29 /alc/alcmain.h
parentadb54677208c8dba40e60cd0731a11219cbbe319 (diff)
Use a unique_ptr to hold DistanceComp data
Diffstat (limited to 'alc/alcmain.h')
-rw-r--r--alc/alcmain.h28
1 files changed, 11 insertions, 17 deletions
diff --git a/alc/alcmain.h b/alc/alcmain.h
index 2ba19c47..d525c825 100644
--- a/alc/alcmain.h
+++ b/alc/alcmain.h
@@ -124,31 +124,25 @@ struct FilterSubList {
/* Maximum delay in samples for speaker distance compensation. */
#define MAX_DELAY_LENGTH 1024
-class DistanceComp {
-public:
- struct DistData {
+struct DistanceComp {
+ struct ChanData {
float Gain{1.0f};
uint Length{0u}; /* Valid range is [0...MAX_DELAY_LENGTH). */
float *Buffer{nullptr};
};
-private:
- using FloatArray = al::FlexArray<float,16>;
- std::array<DistData,MAX_OUTPUT_CHANNELS> mChannels;
- std::unique_ptr<FloatArray> mSamples;
+ std::array<ChanData,MAX_OUTPUT_CHANNELS> mChannels;
+ al::FlexArray<float,16> mSamples;
-public:
- void setSampleCount(size_t new_size)
- { mSamples = FloatArray::Create(new_size); }
- void clear() noexcept
+ DistanceComp(size_t count) : mSamples{count} { }
+
+ static std::unique_ptr<DistanceComp> Create(size_t numsamples)
{
- mChannels.fill(DistData{});
- mSamples = nullptr;
+ return std::unique_ptr<DistanceComp>{
+ new(FamCount(numsamples)) DistanceComp{numsamples}};
}
- float *getSamples() noexcept { return mSamples->data(); }
-
- al::span<DistData,MAX_OUTPUT_CHANNELS> as_span() { return mChannels; }
+ DEF_FAM_NEWDEL(DistanceComp, mSamples);
};
@@ -297,7 +291,7 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
std::unique_ptr<Compressor> Limiter;
/* Delay buffers used to compensate for speaker distances. */
- DistanceComp ChannelDelay;
+ std::unique_ptr<DistanceComp> ChannelDelays;
/* Dithering control. */
float DitherDepth{0.0f};