diff options
Diffstat (limited to '')
-rw-r--r-- | src/pcm/SoxrResampler.hxx (renamed from src/SongPointer.hxx) | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/src/SongPointer.hxx b/src/pcm/SoxrResampler.hxx index ded3b3e1d..74d32e2b5 100644 --- a/src/SongPointer.hxx +++ b/src/pcm/SoxrResampler.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 The Music Player Daemon Project + * Copyright (C) 2003-2014 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -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 |