Make a couple more operator bools explicit
[openal-soft.git] / core / converter.h
blob2d22ae387b82de9f7a9cfaeaf1cf494b2b40f333
1 #ifndef CORE_CONVERTER_H
2 #define CORE_CONVERTER_H
4 #include <cstddef>
5 #include <memory>
7 #include "almalloc.h"
8 #include "devformat.h"
9 #include "mixer/defs.h"
11 using uint = unsigned int;
14 struct SampleConverter {
15 DevFmtType mSrcType{};
16 DevFmtType mDstType{};
17 uint mSrcTypeSize{};
18 uint mDstTypeSize{};
20 int mSrcPrepCount{};
22 uint mFracOffset{};
23 uint mIncrement{};
24 InterpState mState{};
25 ResamplerFunc mResample{};
27 alignas(16) float mSrcSamples[BufferLineSize]{};
28 alignas(16) float mDstSamples[BufferLineSize]{};
30 struct ChanSamples {
31 alignas(16) float PrevSamples[MaxResamplerPadding];
33 al::FlexArray<ChanSamples> mChan;
35 SampleConverter(size_t numchans) : mChan{numchans} { }
37 uint convert(const void **src, uint *srcframes, void *dst, uint dstframes);
38 uint availableOut(uint srcframes) const;
40 DEF_FAM_NEWDEL(SampleConverter, mChan)
42 using SampleConverterPtr = std::unique_ptr<SampleConverter>;
44 SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, size_t numchans,
45 uint srcRate, uint dstRate, Resampler resampler);
48 struct ChannelConverter {
49 DevFmtType mSrcType{};
50 uint mSrcStep{};
51 uint mChanMask{};
52 DevFmtChannels mDstChans{};
54 bool is_active() const noexcept { return mChanMask != 0; }
56 void convert(const void *src, float *dst, uint frames) const;
59 #endif /* CORE_CONVERTER_H */