aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
Diffstat (limited to 'alc')
-rw-r--r--alc/converter.cpp11
-rw-r--r--alc/converter.h8
-rw-r--r--alc/hrtf.cpp19
-rw-r--r--alc/hrtf.h4
-rw-r--r--alc/ringbuffer.cpp2
-rw-r--r--alc/ringbuffer.h4
6 files changed, 13 insertions, 35 deletions
diff --git a/alc/converter.cpp b/alc/converter.cpp
index 7e3c17cc..58b59179 100644
--- a/alc/converter.cpp
+++ b/alc/converter.cpp
@@ -143,14 +143,13 @@ void Stereo2Mono(ALfloat *RESTRICT dst, const void *src, const size_t frames) no
} // namespace
-SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, ALsizei numchans,
- ALsizei srcRate, ALsizei dstRate, Resampler resampler)
+SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, size_t numchans,
+ ALsizei srcRate, ALsizei dstRate, Resampler resampler)
{
- if(numchans <= 0 || srcRate <= 0 || dstRate <= 0)
+ if(numchans < 1 || srcRate < 1 || dstRate < 1)
return nullptr;
- void *ptr{al_calloc(16, SampleConverter::Sizeof(numchans))};
- SampleConverterPtr converter{new (ptr) SampleConverter{static_cast<size_t>(numchans)}};
+ SampleConverterPtr converter{new (FamCount{numchans}) SampleConverter{numchans}};
converter->mSrcType = srcType;
converter->mDstType = dstType;
converter->mSrcTypeSize = BytesFromDevFmt(srcType);
@@ -162,7 +161,7 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType,
/* Have to set the mixer FPU mode since that's what the resampler code expects. */
FPUCtl mixer_mode{};
auto step = static_cast<ALsizei>(
- mind(static_cast<ALdouble>(srcRate)/dstRate*FRACTIONONE + 0.5, MAX_PITCH*FRACTIONONE));
+ mind(srcRate*ALdouble{FRACTIONONE}/dstRate + 0.5, MAX_PITCH*FRACTIONONE));
converter->mIncrement = maxi(step, 1);
if(converter->mIncrement == FRACTIONONE)
converter->mResample = Resample_<CopyTag,CTag>;
diff --git a/alc/converter.h b/alc/converter.h
index 62f09af1..46e57f10 100644
--- a/alc/converter.h
+++ b/alc/converter.h
@@ -39,13 +39,7 @@ struct SampleConverter {
ALuint convert(const ALvoid **src, ALuint *srcframes, ALvoid *dst, ALuint dstframes);
ALuint availableOut(ALuint srcframes) const;
- static constexpr size_t Sizeof(size_t length) noexcept
- {
- return maxz(sizeof(SampleConverter),
- al::FlexArray<ChanSamples>::Sizeof(length, offsetof(SampleConverter, mChan)));
- }
-
- DEF_PLACE_NEWDEL()
+ DEF_FAM_NEWDEL(SampleConverter, mChan)
};
using SampleConverterPtr = std::unique_ptr<SampleConverter>;
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp
index 5a39f686..04818a4f 100644
--- a/alc/hrtf.cpp
+++ b/alc/hrtf.cpp
@@ -61,22 +61,12 @@ struct HrtfHandle {
HrtfHandle(const HrtfHandle&) = delete;
HrtfHandle& operator=(const HrtfHandle&) = delete;
- static std::unique_ptr<HrtfHandle> Create(size_t fname_len);
- static constexpr size_t Sizeof(size_t length) noexcept
- {
- return maxz(sizeof(HrtfHandle),
- al::FlexArray<char>::Sizeof(length, offsetof(HrtfHandle, filename)));
- }
+ static std::unique_ptr<HrtfHandle> Create(size_t fname_len)
+ { return std::unique_ptr<HrtfHandle>{new (FamCount{fname_len}) HrtfHandle{fname_len}}; }
- DEF_PLACE_NEWDEL()
+ DEF_FAM_NEWDEL(HrtfHandle, filename)
};
-std::unique_ptr<HrtfHandle> HrtfHandle::Create(size_t fname_len)
-{
- void *ptr{al_calloc(alignof(HrtfHandle), HrtfHandle::Sizeof(fname_len))};
- return std::unique_ptr<HrtfHandle>{new (ptr) HrtfHandle{fname_len}};
-}
-
namespace {
using namespace std::placeholders;
@@ -294,8 +284,7 @@ void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, AL
std::unique_ptr<DirectHrtfState> DirectHrtfState::Create(size_t num_chans)
{
- void *ptr{al_calloc(16, DirectHrtfState::Sizeof(num_chans))};
- return std::unique_ptr<DirectHrtfState>{new (ptr) DirectHrtfState{num_chans}};
+ return std::unique_ptr<DirectHrtfState>{new (FamCount{num_chans}) DirectHrtfState{num_chans}};
}
void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALuint NumChannels,
diff --git a/alc/hrtf.h b/alc/hrtf.h
index 487dca61..85614f2e 100644
--- a/alc/hrtf.h
+++ b/alc/hrtf.h
@@ -85,10 +85,8 @@ struct DirectHrtfState {
DirectHrtfState(size_t numchans) : Coeffs{numchans} { }
static std::unique_ptr<DirectHrtfState> Create(size_t num_chans);
- static constexpr size_t Sizeof(size_t numchans) noexcept
- { return al::FlexArray<HrirArray,16>::Sizeof(numchans, offsetof(DirectHrtfState, Coeffs)); }
- DEF_PLACE_NEWDEL()
+ DEF_FAM_NEWDEL(DirectHrtfState, Coeffs)
};
struct AngularPoint {
diff --git a/alc/ringbuffer.cpp b/alc/ringbuffer.cpp
index d99676b8..d61f6129 100644
--- a/alc/ringbuffer.cpp
+++ b/alc/ringbuffer.cpp
@@ -48,7 +48,7 @@ RingBufferPtr CreateRingBuffer(size_t sz, size_t elem_sz, int limit_writes)
if(power_of_two < sz) return nullptr;
const size_t bufbytes{power_of_two * elem_sz};
- RingBufferPtr rb{new (al_calloc(16, sizeof(*rb) + bufbytes)) RingBuffer{bufbytes}};
+ RingBufferPtr rb{new (FamCount{bufbytes}) RingBuffer{bufbytes}};
rb->mWriteSize = limit_writes ? sz : (power_of_two-1);
rb->mSizeMask = power_of_two - 1;
rb->mElemSize = elem_sz;
diff --git a/alc/ringbuffer.h b/alc/ringbuffer.h
index 84139b66..3151fdcb 100644
--- a/alc/ringbuffer.h
+++ b/alc/ringbuffer.h
@@ -34,8 +34,6 @@ struct RingBuffer {
al::FlexArray<al::byte, 16> mBuffer;
RingBuffer(const size_t count) : mBuffer{count} { }
- RingBuffer(const RingBuffer&) = delete;
- RingBuffer& operator=(const RingBuffer&) = delete;
/** Reset the read and write pointers to zero. This is not thread safe. */
void reset() noexcept;
@@ -84,7 +82,7 @@ struct RingBuffer {
/** Advance the write pointer `cnt' places. */
void writeAdvance(size_t cnt) noexcept;
- DEF_PLACE_NEWDEL()
+ DEF_FAM_NEWDEL(RingBuffer, mBuffer)
};
using RingBufferPtr = std::unique_ptr<RingBuffer>;