11 #include "alnumeric.h"
13 #include "devformat.h"
17 struct SampleConverter
{
18 DevFmtType mSrcType
{};
19 DevFmtType mDstType
{};
20 ALuint mSrcTypeSize
{};
21 ALuint mDstTypeSize
{};
23 ALint mSrcPrepCount
{};
28 ResamplerFunc mResample
{};
30 alignas(16) ALfloat mSrcSamples
[BUFFERSIZE
]{};
31 alignas(16) ALfloat mDstSamples
[BUFFERSIZE
]{};
34 alignas(16) ALfloat PrevSamples
[MAX_RESAMPLER_PADDING
];
36 al::FlexArray
<ChanSamples
> mChan
;
38 SampleConverter(size_t numchans
) : mChan
{numchans
} { }
40 ALuint
convert(const ALvoid
**src
, ALuint
*srcframes
, ALvoid
*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
{
53 DevFmtChannels mSrcChans
;
54 DevFmtChannels mDstChans
;
56 bool is_active() const noexcept
{ return mSrcChans
!= mDstChans
; }
58 void convert(const ALvoid
*src
, ALfloat
*dst
, ALuint frames
) const;
61 #endif /* CONVERTER_H */