11 #include "alnumeric.h"
13 #include "devformat.h"
16 struct SampleConverter
{
17 DevFmtType mSrcType
{};
18 DevFmtType mDstType
{};
19 ALuint mSrcTypeSize
{};
20 ALuint mDstTypeSize
{};
22 ALint mSrcPrepCount
{};
27 ResamplerFunc mResample
{};
29 alignas(16) ALfloat mSrcSamples
[BUFFERSIZE
]{};
30 alignas(16) ALfloat mDstSamples
[BUFFERSIZE
]{};
33 alignas(16) ALfloat PrevSamples
[MAX_RESAMPLER_PADDING
];
35 al::FlexArray
<ChanSamples
> mChan
;
37 SampleConverter(size_t numchans
) : mChan
{numchans
} { }
39 ALuint
convert(const ALvoid
**src
, ALuint
*srcframes
, ALvoid
*dst
, ALuint dstframes
);
40 ALuint
availableOut(ALuint srcframes
) const;
42 DEF_FAM_NEWDEL(SampleConverter
, mChan
)
44 using SampleConverterPtr
= std::unique_ptr
<SampleConverter
>;
46 SampleConverterPtr
CreateSampleConverter(DevFmtType srcType
, DevFmtType dstType
, size_t numchans
,
47 ALuint srcRate
, ALuint dstRate
, Resampler resampler
);
50 struct ChannelConverter
{
52 DevFmtChannels mSrcChans
;
53 DevFmtChannels mDstChans
;
55 bool is_active() const noexcept
{ return mSrcChans
!= mDstChans
; }
57 void convert(const ALvoid
*src
, ALfloat
*dst
, ALuint frames
) const;
60 #endif /* CONVERTER_H */