diff options
author | Max Kellermann <max@duempel.org> | 2013-11-11 22:31:46 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-11-30 16:22:57 +0100 |
commit | 5ba90cd8ea87cf97d64409b7b4c59033c2450c77 (patch) | |
tree | eec1565c805de7bc142de82e5100cc3c1f86aa8d /src/pcm/GlueResampler.hxx | |
parent | e9127523db55a267f67532fd61e913f2879324fc (diff) | |
download | mpd-5ba90cd8ea87cf97d64409b7b4c59033c2450c77.tar.gz mpd-5ba90cd8ea87cf97d64409b7b4c59033c2450c77.tar.xz mpd-5ba90cd8ea87cf97d64409b7b4c59033c2450c77.zip |
pcm/PcmResampler: convert to abstract interface
The PcmResampler interface is implemented by the two classes
FallbackPcmResampler and LibsampleratePcmResampler. This prepares for
adding more resampler libraries.
Diffstat (limited to 'src/pcm/GlueResampler.hxx')
-rw-r--r-- | src/pcm/GlueResampler.hxx | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/pcm/GlueResampler.hxx b/src/pcm/GlueResampler.hxx index a7e0a84f2..7bd923bab 100644 --- a/src/pcm/GlueResampler.hxx +++ b/src/pcm/GlueResampler.hxx @@ -22,22 +22,41 @@ #include "check.h" #include "AudioFormat.hxx" -#include "PcmResample.hxx" +#include "FormatConverter.hxx" class Error; +class PcmResampler; template<typename T> struct ConstBuffer; +/** + * A glue class that integrates a #PcmResampler and automatically + * converts source data to the sample format required by the + * #PcmResampler instance. + */ class GluePcmResampler { - PcmResampler resampler; + PcmResampler *const resampler; + + SampleFormat src_sample_format, requested_sample_format; + SampleFormat output_sample_format; - AudioFormat src_format; - unsigned new_sample_rate; + /** + * This object converts input data to the sample format + * requested by the #PcmResampler. + */ + PcmFormatConverter format_converter; public: + GluePcmResampler(); + ~GluePcmResampler(); + bool Open(AudioFormat src_format, unsigned new_sample_rate, Error &error); void Close(); + SampleFormat GetOutputSampleFormat() const { + return output_sample_format; + } + ConstBuffer<void> Resample(ConstBuffer<void> src, Error &error); }; |