audio-drain/audio/drain/Resampler.h

51 lines
1.3 KiB
C
Raw Normal View History

2015-04-10 23:00:13 +02:00
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
2015-04-10 23:00:13 +02:00
#include <audio/drain/Algo.h>
#ifdef HAVE_SPEEX_DSP_RESAMPLE
#include <speex/speex_resampler.h>
#endif
2016-07-19 21:43:58 +02:00
#include <ememory/memory.h>
2015-04-10 23:00:13 +02:00
namespace audio {
namespace drain {
// TODO: Manage change timestamp when pull mode
// TODO: drain ...
class Resampler : public audio::drain::Algo {
private:
#ifdef HAVE_SPEEX_DSP_RESAMPLE
SpeexResamplerState* m_speexResampler;
#endif
size_t m_positionRead; //!< For residual data in the buffer last read number of chunk
size_t m_positionWrite; //!< Current pointer of writing new output data of resampler
protected:
/**
* @brief Constructor
*/
Resampler();
void init();
public:
2016-07-19 21:43:58 +02:00
static ememory::SharedPtr<audio::drain::Resampler> create();
2015-04-10 23:00:13 +02:00
/**
* @brief Destructor
*/
virtual ~Resampler();
protected:
virtual void configurationChange();
public:
2015-04-13 21:49:48 +02:00
virtual bool process(audio::Time& _time,
2015-04-10 23:00:13 +02:00
void* _input,
size_t _inputNbChunk,
void*& _output,
size_t& _outputNbChunk);
private:
2015-04-13 21:49:48 +02:00
audio::Duration m_residualTimeInResampler; //!< the time of data locked in the resampler ...
2015-04-10 23:00:13 +02:00
};
}
}