aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm/SoxrResampler.hxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/pcm/SoxrResampler.hxx (renamed from src/SongPointer.hxx)54
1 files changed, 19 insertions, 35 deletions
diff --git a/src/SongPointer.hxx b/src/pcm/SoxrResampler.hxx
index ded3b3e1d..69c173741 100644
--- a/src/SongPointer.hxx
+++ b/src/pcm/SoxrResampler.hxx
@@ -17,47 +17,31 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_SONG_POINTER_HXX
-#define MPD_SONG_POINTER_HXX
+#ifndef MPD_PCM_SOXR_RESAMPLER_HXX
+#define MPD_PCM_SOXR_RESAMPLER_HXX
-#include "Song.hxx"
+#include "Resampler.hxx"
+#include "PcmBuffer.hxx"
-#include <utility>
+struct AudioFormat;
-class SongPointer {
- Song *song;
-
-public:
- explicit SongPointer(Song *_song)
- :song(_song) {}
-
- SongPointer(const SongPointer &) = delete;
-
- SongPointer(SongPointer &&other):song(other.song) {
- other.song = nullptr;
- }
-
- ~SongPointer() {
- if (song != nullptr)
- song->Free();
- }
-
- SongPointer &operator=(const SongPointer &) = delete;
+/**
+ * A resampler using soxr.
+ */
+class SoxrPcmResampler final : public PcmResampler {
+ struct soxr *soxr;
- SongPointer &operator=(SongPointer &&other) {
- std::swap(song, other.song);
- return *this;
- }
+ unsigned channels;
+ float ratio;
- operator const Song *() const {
- return song;
- }
+ PcmBuffer buffer;
- Song *Steal() {
- auto result = song;
- song = nullptr;
- return result;
- }
+public:
+ virtual AudioFormat Open(AudioFormat &af, unsigned new_sample_rate,
+ Error &error) override;
+ virtual void Close() override;
+ virtual ConstBuffer<void> Resample(ConstBuffer<void> src,
+ Error &error) override;
};
#endif