audio-drain/drain/EndPointWrite.h

86 lines
2.8 KiB
C
Raw Normal View History

/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#ifndef __AIRT_ALGO_ALGO_END_POINT_WRITE_H__
#define __AIRT_ALGO_ALGO_END_POINT_WRITE_H__
2015-02-05 19:10:53 +01:00
#include <drain/EndPoint.h>
2015-02-25 22:05:00 +01:00
#include <etk/functional.h>
#include <etk/mutex.h>
#include <drain/CircularBuffer.h>
2015-02-05 19:10:53 +01:00
namespace drain{
2015-02-24 22:20:11 +01:00
typedef std11::function<void (const std11::chrono::system_clock::time_point& _time,
size_t _nbChunk,
enum audio::format _format,
uint32_t _frequency,
const std::vector<audio::channel>& _map)> playbackFunctionWrite;
class EndPointWrite : public EndPoint {
private:
drain::CircularBuffer m_buffer;
playbackFunctionWrite m_function;
2015-02-24 22:20:11 +01:00
std11::mutex m_mutex;
2015-01-29 21:46:01 +01:00
protected:
/**
* @brief Constructor
*/
EndPointWrite();
2015-01-29 21:46:01 +01:00
void init();
public:
2015-02-24 22:20:11 +01:00
static std11::shared_ptr<EndPointWrite> create();
/**
* @brief Destructor
*/
2015-01-29 21:46:01 +01:00
virtual ~EndPointWrite() {};
virtual void configurationChange();
2015-02-24 22:20:11 +01:00
virtual bool process(std11::chrono::system_clock::time_point& _time,
void* _input,
size_t _inputNbChunk,
void*& _output,
size_t& _outputNbChunk);
2015-01-27 21:26:03 +01:00
virtual void write(const void* _value, size_t _nbChunk);
virtual void setCallback(playbackFunctionWrite _function) {
m_function = _function;
}
protected:
std11::chrono::microseconds m_bufferSizeMicroseconds; // 0 if m_bufferSizeChunk != 0
size_t m_bufferSizeChunk; // 0 if m_bufferSizeMicroseconds != 0
public:
/**
* @brief Set buffer size in chunk number
* @param[in] _nbChunk Number of chunk in the buffer
*/
virtual void setBufferSize(size_t _nbChunk);
/**
* @brief Set buffer size size of the buffer with the stored time in <EFBFBD>s
* @param[in] _time Time in microsecond of the buffer
*/
virtual void setBufferSize(const std11::chrono::microseconds& _time);
/**
* @brief get buffer size in chunk number
* @return Number of chunk that can be written in the buffer
*/
virtual size_t getBufferSize();
/**
* @brief Set buffer size size of the buffer with the stored time in <EFBFBD>s
* @return Time in microsecond that can be written in the buffer
*/
virtual std11::chrono::microseconds getBufferSizeMicrosecond();
/**
* @brief Get buffer size filled in chunk number
* @return Number of chunk in the buffer (that might be read/write)
*/
virtual size_t getBufferFillSize();
/**
* @brief Set buffer size size of the buffer with the stored time in <EFBFBD>s
* @return Time in microsecond of the buffer (that might be read/write)
*/
virtual std11::chrono::microseconds getBufferFillSizeMicrosecond();
};
};
#endif