Add some missing constexpr attributes
[openal-soft.git] / alc / converter.h
blob17da3aaeb2e433c09a5d4b4d7dae79c2c4c11941
1 #ifndef CONVERTER_H
2 #define CONVERTER_H
4 #include <cstddef>
5 #include <memory>
7 #include "AL/al.h"
9 #include "alcmain.h"
10 #include "almalloc.h"
11 #include "alnumeric.h"
12 #include "alu.h"
13 #include "devformat.h"
14 #include "voice.h"
17 struct SampleConverter {
18 DevFmtType mSrcType{};
19 DevFmtType mDstType{};
20 ALuint mSrcTypeSize{};
21 ALuint mDstTypeSize{};
23 int mSrcPrepCount{};
25 ALuint mFracOffset{};
26 ALuint mIncrement{};
27 InterpState mState{};
28 ResamplerFunc mResample{};
30 alignas(16) float mSrcSamples[BUFFERSIZE]{};
31 alignas(16) float mDstSamples[BUFFERSIZE]{};
33 struct ChanSamples {
34 alignas(16) float PrevSamples[MAX_RESAMPLER_PADDING];
36 al::FlexArray<ChanSamples> mChan;
38 SampleConverter(size_t numchans) : mChan{numchans} { }
40 ALuint convert(const void **src, ALuint *srcframes, void *dst, ALuint dstframes);
41 ALuint availableOut(ALuint srcframes) const;
43 DEF_FAM_NEWDEL(SampleConverter, mChan)
45 using SampleConverterPtr = std::unique_ptr<SampleConverter>;
47 SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, size_t numchans,
48 ALuint srcRate, ALuint dstRate, Resampler resampler);
51 struct ChannelConverter {
52 DevFmtType mSrcType{};
53 ALuint mSrcStep{};
54 ALuint mChanMask{};
55 DevFmtChannels mDstChans{};
57 bool is_active() const noexcept { return mChanMask != 0; }
59 void convert(const void *src, float *dst, ALuint frames) const;
62 #endif /* CONVERTER_H */