From 3dcb08201511ffdb47c69b5efe4cf390df8a5471 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 11 Jan 2017 15:26:48 +0100 Subject: [PATCH] pcm/Resampler: add method Reset() Hook for src_reset(), not yet used. --- src/pcm/GlueResampler.cxx | 6 ++++++ src/pcm/GlueResampler.hxx | 5 +++++ src/pcm/LibsamplerateResampler.cxx | 6 ++++++ src/pcm/LibsamplerateResampler.hxx | 1 + src/pcm/Resampler.hxx | 6 ++++++ 5 files changed, 24 insertions(+) diff --git a/src/pcm/GlueResampler.cxx b/src/pcm/GlueResampler.cxx index f386380e0..9b48eb5ff 100644 --- a/src/pcm/GlueResampler.cxx +++ b/src/pcm/GlueResampler.cxx @@ -65,6 +65,12 @@ GluePcmResampler::Close() resampler->Close(); } +void +GluePcmResampler::Reset() +{ + resampler->Reset(); +} + ConstBuffer GluePcmResampler::Resample(ConstBuffer src) { diff --git a/src/pcm/GlueResampler.hxx b/src/pcm/GlueResampler.hxx index 0edb44713..e2afa30ce 100644 --- a/src/pcm/GlueResampler.hxx +++ b/src/pcm/GlueResampler.hxx @@ -55,6 +55,11 @@ public: return output_sample_format; } + /** + * @see PcmResampler::Reset() + */ + void Reset(); + ConstBuffer Resample(ConstBuffer src); }; diff --git a/src/pcm/LibsamplerateResampler.cxx b/src/pcm/LibsamplerateResampler.cxx index 6a02a621c..957bea03f 100644 --- a/src/pcm/LibsamplerateResampler.cxx +++ b/src/pcm/LibsamplerateResampler.cxx @@ -114,6 +114,12 @@ LibsampleratePcmResampler::Close() state = src_delete(state); } +void +LibsampleratePcmResampler::Reset() +{ + src_reset(state); +} + inline ConstBuffer LibsampleratePcmResampler::Resample2(ConstBuffer src) { diff --git a/src/pcm/LibsamplerateResampler.hxx b/src/pcm/LibsamplerateResampler.hxx index 9ce3348c6..3660bfd84 100644 --- a/src/pcm/LibsamplerateResampler.hxx +++ b/src/pcm/LibsamplerateResampler.hxx @@ -44,6 +44,7 @@ class LibsampleratePcmResampler final : public PcmResampler { public: AudioFormat Open(AudioFormat &af, unsigned new_sample_rate) override; void Close() override; + void Reset() override; ConstBuffer Resample(ConstBuffer src) override; private: diff --git a/src/pcm/Resampler.hxx b/src/pcm/Resampler.hxx index 3ebe90450..a82387e39 100644 --- a/src/pcm/Resampler.hxx +++ b/src/pcm/Resampler.hxx @@ -54,6 +54,12 @@ public: */ virtual void Close() = 0; + /** + * Reset the filter's state, e.g. drop/flush buffers. + */ + virtual void Reset() { + } + /** * Resamples a block of PCM data. *