aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/converter.cpp7
-rw-r--r--core/converter.h8
2 files changed, 14 insertions, 1 deletions
diff --git a/core/converter.cpp b/core/converter.cpp
index 6a06b464..f4c36c87 100644
--- a/core/converter.cpp
+++ b/core/converter.cpp
@@ -167,8 +167,13 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType,
converter->mSrcTypeSize = BytesFromDevFmt(srcType);
converter->mDstTypeSize = BytesFromDevFmt(dstType);
- converter->mSrcPrepCount = 0;
+ converter->mSrcPrepCount = MaxResamplerEdge;
converter->mFracOffset = 0;
+ for(auto &chan : converter->mChan)
+ {
+ const al::span<float> buffer{chan.PrevSamples};
+ std::fill(buffer.begin(), buffer.end(), 0.0f);
+ }
/* Have to set the mixer FPU mode since that's what the resampler code expects. */
FPUCtl mixer_mode{};
diff --git a/core/converter.h b/core/converter.h
index 2d22ae38..46d9b83e 100644
--- a/core/converter.h
+++ b/core/converter.h
@@ -1,6 +1,7 @@
#ifndef CORE_CONVERTER_H
#define CORE_CONVERTER_H
+#include <chrono>
#include <cstddef>
#include <memory>
@@ -37,6 +38,13 @@ struct SampleConverter {
uint convert(const void **src, uint *srcframes, void *dst, uint dstframes);
uint availableOut(uint srcframes) const;
+ using SampleOffset = std::chrono::duration<int64_t, std::ratio<1,MixerFracOne>>;
+ SampleOffset currentInputDelay() const noexcept
+ {
+ const int64_t prep{mSrcPrepCount - MaxResamplerEdge};
+ return SampleOffset{(prep<<MixerFracBits) + mFracOffset};
+ }
+
DEF_FAM_NEWDEL(SampleConverter, mChan)
};
using SampleConverterPtr = std::unique_ptr<SampleConverter>;