[DEV] WORK on a port for BOOST
This commit is contained in:
parent
aa020d5e3c
commit
7af6577e64
@ -21,8 +21,8 @@ drain::Algo::Algo() :
|
|||||||
|
|
||||||
void drain::Algo::init() {
|
void drain::Algo::init() {
|
||||||
// set notification callback :
|
// set notification callback :
|
||||||
m_input.setCallback(std::bind(&drain::Algo::configurationChangeLocal, this));
|
m_input.setCallback(std11::bind(&drain::Algo::configurationChangeLocal, this));
|
||||||
m_output.setCallback(std::bind(&drain::Algo::configurationChangeLocal, this));
|
m_output.setCallback(std11::bind(&drain::Algo::configurationChangeLocal, this));
|
||||||
// first configure ==> update the internal parameters
|
// first configure ==> update the internal parameters
|
||||||
configurationChange();
|
configurationChange();
|
||||||
}
|
}
|
||||||
|
26
drain/Algo.h
26
drain/Algo.h
@ -13,15 +13,21 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <audio/format.h>
|
#include <audio/format.h>
|
||||||
#include <audio/channel.h>
|
#include <audio/channel.h>
|
||||||
#include <chrono>
|
#if __cplusplus >= 201103L
|
||||||
#include <functional>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#else
|
||||||
|
#include <etk/chrono.h>
|
||||||
|
#include <etk/functional.h>
|
||||||
|
#include <etk/memory.h>
|
||||||
|
#endif
|
||||||
#include "AutoLogInOut.h"
|
#include "AutoLogInOut.h"
|
||||||
#include "IOFormatInterface.h"
|
#include "IOFormatInterface.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
namespace drain{
|
namespace drain{
|
||||||
class Algo : public std::enable_shared_from_this<Algo> {
|
class Algo : public std11::enable_shared_from_this<Algo> {
|
||||||
private:
|
private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
public:
|
public:
|
||||||
@ -110,7 +116,7 @@ namespace drain{
|
|||||||
* @return true The process is done corectly
|
* @return true The process is done corectly
|
||||||
* @return false An error occured
|
* @return false An error occured
|
||||||
*/
|
*/
|
||||||
virtual bool process(std::chrono::system_clock::time_point& _time,
|
virtual bool process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
@ -142,19 +148,19 @@ namespace drain{
|
|||||||
return m_supportedFormat;
|
return m_supportedFormat;
|
||||||
};
|
};
|
||||||
protected: // note when nothing ==> support all type
|
protected: // note when nothing ==> support all type
|
||||||
std::vector<std::vector<audio::channel>> m_supportedMap;
|
std::vector<std::vector<audio::channel> > m_supportedMap;
|
||||||
public:
|
public:
|
||||||
virtual std::vector<std::vector<audio::channel>> getMapSupportedInput() {
|
virtual std::vector<std::vector<audio::channel> > getMapSupportedInput() {
|
||||||
if (m_output.getConfigured() == true) {
|
if (m_output.getConfigured() == true) {
|
||||||
std::vector<std::vector<audio::channel>> out;
|
std::vector<std::vector<audio::channel> > out;
|
||||||
out.push_back(m_output.getMap());
|
out.push_back(m_output.getMap());
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
return m_supportedMap;
|
return m_supportedMap;
|
||||||
};
|
};
|
||||||
virtual std::vector<std::vector<audio::channel>> getMapSupportedOutput() {
|
virtual std::vector<std::vector<audio::channel> > getMapSupportedOutput() {
|
||||||
if (m_input.getConfigured() == true) {
|
if (m_input.getConfigured() == true) {
|
||||||
std::vector<std::vector<audio::channel>> out;
|
std::vector<std::vector<audio::channel> > out;
|
||||||
out.push_back(m_input.getMap());
|
out.push_back(m_input.getMap());
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ void drain::ChannelReorder::init() {
|
|||||||
m_type = "ChannelReorder";
|
m_type = "ChannelReorder";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<drain::ChannelReorder> drain::ChannelReorder::create() {
|
std11::shared_ptr<drain::ChannelReorder> drain::ChannelReorder::create() {
|
||||||
std::shared_ptr<drain::ChannelReorder> tmp(new drain::ChannelReorder());
|
std11::shared_ptr<drain::ChannelReorder> tmp(new drain::ChannelReorder());
|
||||||
tmp->init();
|
tmp->init();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ void drain::ChannelReorder::configurationChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool drain::ChannelReorder::process(std::chrono::system_clock::time_point& _time,
|
bool drain::ChannelReorder::process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
|
@ -18,7 +18,7 @@ namespace drain{
|
|||||||
ChannelReorder();
|
ChannelReorder();
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<ChannelReorder> create();
|
static std11::shared_ptr<ChannelReorder> create();
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@ -26,7 +26,7 @@ namespace drain{
|
|||||||
protected:
|
protected:
|
||||||
virtual void configurationChange();
|
virtual void configurationChange();
|
||||||
public:
|
public:
|
||||||
virtual bool process(std::chrono::system_clock::time_point& _time,
|
virtual bool process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
|
@ -27,14 +27,14 @@ void drain::EndPointCallback::init(recordFunction _callback) {
|
|||||||
m_type = "EndPointCallback";
|
m_type = "EndPointCallback";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<drain::EndPointCallback> drain::EndPointCallback::create(playbackFunction _callback) {
|
std11::shared_ptr<drain::EndPointCallback> drain::EndPointCallback::create(playbackFunction _callback) {
|
||||||
std::shared_ptr<drain::EndPointCallback> tmp(new drain::EndPointCallback());
|
std11::shared_ptr<drain::EndPointCallback> tmp(new drain::EndPointCallback());
|
||||||
tmp->init(_callback);
|
tmp->init(_callback);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<drain::EndPointCallback> drain::EndPointCallback::create(recordFunction _callback) {
|
std11::shared_ptr<drain::EndPointCallback> drain::EndPointCallback::create(recordFunction _callback) {
|
||||||
std::shared_ptr<drain::EndPointCallback> tmp(new drain::EndPointCallback());
|
std11::shared_ptr<drain::EndPointCallback> tmp(new drain::EndPointCallback());
|
||||||
tmp->init(_callback);
|
tmp->init(_callback);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ void drain::EndPointCallback::configurationChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool drain::EndPointCallback::process(std::chrono::system_clock::time_point& _time,
|
bool drain::EndPointCallback::process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
|
@ -8,22 +8,26 @@
|
|||||||
#define __AIRT_ALGO_END_POINT_CALLBACK_H__
|
#define __AIRT_ALGO_END_POINT_CALLBACK_H__
|
||||||
|
|
||||||
#include <drain/EndPoint.h>
|
#include <drain/EndPoint.h>
|
||||||
#include <functional>
|
#if __cplusplus >= 201103L
|
||||||
|
#include <functional>
|
||||||
|
#else
|
||||||
|
#include <etk/functional.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace drain {
|
namespace drain {
|
||||||
typedef std::function<void (void* _data,
|
typedef std11::function<void (void* _data,
|
||||||
const std::chrono::system_clock::time_point& _playTime,
|
const std11::chrono::system_clock::time_point& _playTime,
|
||||||
size_t _nbChunk,
|
size_t _nbChunk,
|
||||||
enum audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map)> playbackFunction;
|
const std::vector<audio::channel>& _map)> playbackFunction;
|
||||||
typedef std::function<void (const void* _data,
|
typedef std11::function<void (const void* _data,
|
||||||
const std::chrono::system_clock::time_point& _readTime,
|
const std11::chrono::system_clock::time_point& _readTime,
|
||||||
size_t _nbChunk,
|
size_t _nbChunk,
|
||||||
enum audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map)> recordFunction;
|
const std::vector<audio::channel>& _map)> recordFunction;
|
||||||
class EndPointCallback : public EndPoint {
|
class EndPointCallback : public EndPoint {
|
||||||
private:
|
private:
|
||||||
playbackFunction m_outputFunction;
|
playbackFunction m_outputFunction;
|
||||||
@ -36,14 +40,14 @@ namespace drain {
|
|||||||
void init(playbackFunction _callback);
|
void init(playbackFunction _callback);
|
||||||
void init(recordFunction _callback);
|
void init(recordFunction _callback);
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<EndPointCallback> create(playbackFunction _callback);
|
static std11::shared_ptr<EndPointCallback> create(playbackFunction _callback);
|
||||||
static std::shared_ptr<EndPointCallback> create(recordFunction _callback);
|
static std11::shared_ptr<EndPointCallback> create(recordFunction _callback);
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~EndPointCallback() {};
|
virtual ~EndPointCallback() {};
|
||||||
virtual void configurationChange();
|
virtual void configurationChange();
|
||||||
virtual bool process(std::chrono::system_clock::time_point& _time,
|
virtual bool process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
|
@ -20,8 +20,8 @@ void drain::EndPointRead::init() {
|
|||||||
m_type = "EndPointRead";
|
m_type = "EndPointRead";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<drain::EndPointRead> drain::EndPointRead::create() {
|
std11::shared_ptr<drain::EndPointRead> drain::EndPointRead::create() {
|
||||||
std::shared_ptr<drain::EndPointRead> tmp(new drain::EndPointRead());
|
std11::shared_ptr<drain::EndPointRead> tmp(new drain::EndPointRead());
|
||||||
tmp->init();
|
tmp->init();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ void drain::EndPointRead::configurationChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool drain::EndPointRead::process(std::chrono::system_clock::time_point& _time,
|
bool drain::EndPointRead::process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
|
@ -18,13 +18,13 @@ namespace drain{
|
|||||||
EndPointRead();
|
EndPointRead();
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<EndPointRead> create();
|
static std11::shared_ptr<EndPointRead> create();
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~EndPointRead() {};
|
virtual ~EndPointRead() {};
|
||||||
virtual void configurationChange();
|
virtual void configurationChange();
|
||||||
virtual bool process(std::chrono::system_clock::time_point& _time,
|
virtual bool process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
|
@ -20,8 +20,8 @@ void drain::EndPointWrite::init() {
|
|||||||
m_type = "EndPoint";
|
m_type = "EndPoint";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<drain::EndPointWrite> drain::EndPointWrite::create() {
|
std11::shared_ptr<drain::EndPointWrite> drain::EndPointWrite::create() {
|
||||||
std::shared_ptr<drain::EndPointWrite> tmp(new drain::EndPointWrite());
|
std11::shared_ptr<drain::EndPointWrite> tmp(new drain::EndPointWrite());
|
||||||
tmp->init();
|
tmp->init();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ void drain::EndPointWrite::configurationChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool drain::EndPointWrite::process(std::chrono::system_clock::time_point& _time,
|
bool drain::EndPointWrite::process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
@ -50,7 +50,7 @@ bool drain::EndPointWrite::process(std::chrono::system_clock::time_point& _time,
|
|||||||
// set output pointer:
|
// set output pointer:
|
||||||
_outputNbChunk = m_outputData.size()/(m_formatSize*m_output.getMap().size());
|
_outputNbChunk = m_outputData.size()/(m_formatSize*m_output.getMap().size());
|
||||||
_output = &m_outputData[0];
|
_output = &m_outputData[0];
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std11::unique_lock<std11::mutex> lock(m_mutex);
|
||||||
// check if data in the tmpBuffer
|
// check if data in the tmpBuffer
|
||||||
if (m_tmpData.size() == 0) {
|
if (m_tmpData.size() == 0) {
|
||||||
DRAIN_WARNING("No data in the user buffer (write null data ... " << _outputNbChunk << " chunks)");
|
DRAIN_WARNING("No data in the user buffer (write null data ... " << _outputNbChunk << " chunks)");
|
||||||
@ -71,7 +71,7 @@ bool drain::EndPointWrite::process(std::chrono::system_clock::time_point& _time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void drain::EndPointWrite::write(const void* _value, size_t _nbChunk) {
|
void drain::EndPointWrite::write(const void* _value, size_t _nbChunk) {
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
std11::unique_lock<std11::mutex> lock(m_mutex);
|
||||||
DRAIN_INFO("[ASYNC] Write data : " << _nbChunk << " chunks"
|
DRAIN_INFO("[ASYNC] Write data : " << _nbChunk << " chunks"
|
||||||
<< " ==> " << _nbChunk*m_output.getMap().size() << " samples"
|
<< " ==> " << _nbChunk*m_output.getMap().size() << " samples"
|
||||||
<< " formatSize=" << int32_t(m_formatSize)
|
<< " formatSize=" << int32_t(m_formatSize)
|
||||||
|
@ -8,20 +8,25 @@
|
|||||||
#define __AIRT_ALGO_ALGO_END_POINT_WRITE_H__
|
#define __AIRT_ALGO_ALGO_END_POINT_WRITE_H__
|
||||||
|
|
||||||
#include <drain/EndPoint.h>
|
#include <drain/EndPoint.h>
|
||||||
#include <mutex>
|
#if __cplusplus >= 201103L
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <mutex>
|
||||||
|
#else
|
||||||
|
#include <etk/functional.h>
|
||||||
|
#include <etk/mutex.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace drain{
|
namespace drain{
|
||||||
typedef std::function<void (const std::chrono::system_clock::time_point& _time,
|
typedef std11::function<void (const std11::chrono::system_clock::time_point& _time,
|
||||||
size_t _nbChunk,
|
size_t _nbChunk,
|
||||||
enum audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t _frequency,
|
uint32_t _frequency,
|
||||||
const std::vector<audio::channel>& _map)> playbackFunctionWrite;
|
const std::vector<audio::channel>& _map)> playbackFunctionWrite;
|
||||||
class EndPointWrite : public EndPoint {
|
class EndPointWrite : public EndPoint {
|
||||||
private:
|
private:
|
||||||
std::vector<int8_t> m_tmpData;
|
std::vector<int8_t> m_tmpData;
|
||||||
playbackFunctionWrite m_function;
|
playbackFunctionWrite m_function;
|
||||||
std::mutex m_mutex;
|
std11::mutex m_mutex;
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@ -29,13 +34,13 @@ namespace drain{
|
|||||||
EndPointWrite();
|
EndPointWrite();
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<EndPointWrite> create();
|
static std11::shared_ptr<EndPointWrite> create();
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~EndPointWrite() {};
|
virtual ~EndPointWrite() {};
|
||||||
virtual void configurationChange();
|
virtual void configurationChange();
|
||||||
virtual bool process(std::chrono::system_clock::time_point& _time,
|
virtual bool process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
|
@ -136,8 +136,8 @@ void drain::FormatUpdate::init() {
|
|||||||
m_type = "FormatUpdate";
|
m_type = "FormatUpdate";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<drain::FormatUpdate> drain::FormatUpdate::create() {
|
std11::shared_ptr<drain::FormatUpdate> drain::FormatUpdate::create() {
|
||||||
std::shared_ptr<drain::FormatUpdate> tmp(new drain::FormatUpdate());
|
std11::shared_ptr<drain::FormatUpdate> tmp(new drain::FormatUpdate());
|
||||||
tmp->init();
|
tmp->init();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -243,7 +243,7 @@ void drain::FormatUpdate::configurationChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool drain::FormatUpdate::process(std::chrono::system_clock::time_point& _time,
|
bool drain::FormatUpdate::process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
|
@ -17,7 +17,7 @@ namespace drain {
|
|||||||
FormatUpdate();
|
FormatUpdate();
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<FormatUpdate> create();
|
static std11::shared_ptr<FormatUpdate> create();
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@ -25,7 +25,7 @@ namespace drain {
|
|||||||
protected:
|
protected:
|
||||||
virtual void configurationChange();
|
virtual void configurationChange();
|
||||||
public:
|
public:
|
||||||
virtual bool process(std::chrono::system_clock::time_point& _time,
|
virtual bool process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
|
@ -113,7 +113,6 @@ void drain::IOFormatInterface::configurationChange() {
|
|||||||
m_ioChangeFunctor();
|
m_ioChangeFunctor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void drain::IOFormatInterface::setCallback(const std11::function<void()>& _functor) {
|
||||||
void drain::IOFormatInterface::setCallback(const std::function<void()>& _functor) {
|
|
||||||
m_ioChangeFunctor = _functor;
|
m_ioChangeFunctor = _functor;
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,15 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <audio/format.h>
|
#include <audio/format.h>
|
||||||
#include <audio/channel.h>
|
#include <audio/channel.h>
|
||||||
#include <chrono>
|
#if __cplusplus >= 201103L
|
||||||
#include <functional>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
#else
|
||||||
|
#include <etk/chrono.h>
|
||||||
|
#include <etk/functional.h>
|
||||||
|
#include <etk/memory.h>
|
||||||
|
#endif
|
||||||
#include "AutoLogInOut.h"
|
#include "AutoLogInOut.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
@ -70,14 +76,14 @@ namespace drain{
|
|||||||
*/
|
*/
|
||||||
void setFrequency(float _value);
|
void setFrequency(float _value);
|
||||||
protected:
|
protected:
|
||||||
std::function<void()> m_ioChangeFunctor; //!< function pointer on the upper class
|
std11::function<void()> m_ioChangeFunctor; //!< function pointer on the upper class
|
||||||
void configurationChange();
|
void configurationChange();
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Set the callback function to be notify when the arameter change.
|
* @brief Set the callback function to be notify when the arameter change.
|
||||||
* @param[in] _functor Function to call.
|
* @param[in] _functor Function to call.
|
||||||
*/
|
*/
|
||||||
void setCallback(const std::function<void()>& _functor);
|
void setCallback(const std11::function<void()>& _functor);
|
||||||
};
|
};
|
||||||
std::ostream& operator <<(std::ostream& _os, const IOFormatInterface& _obj);
|
std::ostream& operator <<(std::ostream& _os, const IOFormatInterface& _obj);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <drain/ChannelReorder.h>
|
#include <drain/ChannelReorder.h>
|
||||||
#include <drain/FormatUpdate.h>
|
#include <drain/FormatUpdate.h>
|
||||||
#include <drain/Resampler.h>
|
#include <drain/Resampler.h>
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Process"
|
#define __class__ "Process"
|
||||||
@ -25,12 +24,12 @@ drain::Process::Process() :
|
|||||||
m_data.clear();
|
m_data.clear();
|
||||||
}
|
}
|
||||||
drain::Process::~Process() {
|
drain::Process::~Process() {
|
||||||
for (auto &it : m_listAlgo) {
|
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||||
it.reset();
|
m_listAlgo[iii].reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool drain::Process::push(std::chrono::system_clock::time_point& _time,
|
bool drain::Process::push(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _data,
|
void* _data,
|
||||||
size_t _nbChunk) {
|
size_t _nbChunk) {
|
||||||
void* out = nullptr;
|
void* out = nullptr;
|
||||||
@ -40,7 +39,7 @@ bool drain::Process::push(std::chrono::system_clock::time_point& _time,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool drain::Process::pull(std::chrono::system_clock::time_point& _time,
|
bool drain::Process::pull(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _data,
|
void* _data,
|
||||||
size_t _nbChunk,
|
size_t _nbChunk,
|
||||||
size_t _chunkSize) {
|
size_t _chunkSize) {
|
||||||
@ -89,7 +88,7 @@ bool drain::Process::pull(std::chrono::system_clock::time_point& _time,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool drain::Process::process(std::chrono::system_clock::time_point& _time,
|
bool drain::Process::process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _inData,
|
void* _inData,
|
||||||
size_t _inNbChunk,
|
size_t _inNbChunk,
|
||||||
void*& _outData,
|
void*& _outData,
|
||||||
@ -112,12 +111,12 @@ bool drain::Process::process(std::chrono::system_clock::time_point& _time,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drain::Process::pushBack(const std::shared_ptr<drain::Algo>& _algo) {
|
void drain::Process::pushBack(const std11::shared_ptr<drain::Algo>& _algo) {
|
||||||
removeAlgoDynamic();
|
removeAlgoDynamic();
|
||||||
m_listAlgo.push_back(_algo);
|
m_listAlgo.push_back(_algo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drain::Process::pushFront(const std::shared_ptr<drain::Algo>& _algo) {
|
void drain::Process::pushFront(const std11::shared_ptr<drain::Algo>& _algo) {
|
||||||
removeAlgoDynamic();
|
removeAlgoDynamic();
|
||||||
m_listAlgo.insert(m_listAlgo.begin(), _algo);
|
m_listAlgo.insert(m_listAlgo.begin(), _algo);
|
||||||
}
|
}
|
||||||
@ -132,10 +131,10 @@ template<typename T> std::vector<T> getUnion(const std::vector<T>& _out, const s
|
|||||||
// next is ok for all format
|
// next is ok for all format
|
||||||
} else {
|
} else {
|
||||||
// must check all values
|
// must check all values
|
||||||
for (auto &itOut : _out) {
|
for (size_t ooo=0; ooo<_out.size(); ++ooo) {
|
||||||
for (auto &itIn : _in) {
|
for (size_t iii=0; iii<_in.size(); ++iii) {
|
||||||
if (itOut == itIn) {
|
if (_out[ooo] == _in[iii]) {
|
||||||
out.push_back(itOut);
|
out.push_back(_out[ooo]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,23 +145,23 @@ template<typename T> std::vector<T> getUnion(const std::vector<T>& _out, const s
|
|||||||
|
|
||||||
void drain::Process::displayAlgo() {
|
void drain::Process::displayAlgo() {
|
||||||
DRAIN_DEBUG(" Input : " << m_inputConfig);
|
DRAIN_DEBUG(" Input : " << m_inputConfig);
|
||||||
for (auto &it : m_listAlgo) {
|
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||||
DRAIN_DEBUG(" [" << it->getType() << "] '" << it->getName() << "'");
|
DRAIN_DEBUG(" [" << m_listAlgo[iii]->getType() << "] '" << m_listAlgo[iii]->getName() << "'");
|
||||||
if (it->getInputFormat().getConfigured() == true) {
|
if (m_listAlgo[iii]->getInputFormat().getConfigured() == true) {
|
||||||
DRAIN_DEBUG(" Input : " << it->getInputFormat());
|
DRAIN_DEBUG(" Input : " << m_listAlgo[iii]->getInputFormat());
|
||||||
} else {
|
} else {
|
||||||
DRAIN_DEBUG(" Input : Not configured");
|
DRAIN_DEBUG(" Input : Not configured");
|
||||||
DRAIN_DEBUG(" format : " << it->getFormatSupportedInput());
|
DRAIN_DEBUG(" format : " << m_listAlgo[iii]->getFormatSupportedInput());
|
||||||
DRAIN_DEBUG(" frequency : " << it->getFrequencySupportedInput());
|
DRAIN_DEBUG(" frequency : " << m_listAlgo[iii]->getFrequencySupportedInput());
|
||||||
DRAIN_DEBUG(" map : " << it->getMapSupportedInput());
|
DRAIN_DEBUG(" map : " << m_listAlgo[iii]->getMapSupportedInput());
|
||||||
}
|
}
|
||||||
if (it->getOutputFormat().getConfigured() == true) {
|
if (m_listAlgo[iii]->getOutputFormat().getConfigured() == true) {
|
||||||
DRAIN_DEBUG(" Output: " << it->getOutputFormat());
|
DRAIN_DEBUG(" Output: " << m_listAlgo[iii]->getOutputFormat());
|
||||||
} else {
|
} else {
|
||||||
DRAIN_DEBUG(" Output : Not configured");
|
DRAIN_DEBUG(" Output : Not configured");
|
||||||
DRAIN_DEBUG(" format : " << it->getFormatSupportedOutput());
|
DRAIN_DEBUG(" format : " << m_listAlgo[iii]->getFormatSupportedOutput());
|
||||||
DRAIN_DEBUG(" frequency : " << it->getFrequencySupportedOutput());
|
DRAIN_DEBUG(" frequency : " << m_listAlgo[iii]->getFrequencySupportedOutput());
|
||||||
DRAIN_DEBUG(" map : " << it->getMapSupportedOutput());
|
DRAIN_DEBUG(" map : " << m_listAlgo[iii]->getMapSupportedOutput());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DRAIN_DEBUG(" Output : " << m_outputConfig);
|
DRAIN_DEBUG(" Output : " << m_outputConfig);
|
||||||
@ -200,8 +199,8 @@ void drain::Process::updateAlgo(size_t _position) {
|
|||||||
DRAIN_DEBUG(" freq union :" << freq);
|
DRAIN_DEBUG(" freq union :" << freq);
|
||||||
|
|
||||||
// step 2 : Check map:
|
// step 2 : Check map:
|
||||||
std::vector<std::vector<audio::channel>> mapOut;
|
std::vector<std::vector<audio::channel> > mapOut;
|
||||||
std::vector<std::vector<audio::channel>> mapIn;
|
std::vector<std::vector<audio::channel> > mapIn;
|
||||||
if (_position == 0) {
|
if (_position == 0) {
|
||||||
mapOut.push_back(m_inputConfig.getMap());
|
mapOut.push_back(m_inputConfig.getMap());
|
||||||
} else {
|
} else {
|
||||||
@ -212,7 +211,7 @@ void drain::Process::updateAlgo(size_t _position) {
|
|||||||
} else {
|
} else {
|
||||||
mapIn = m_listAlgo[_position]->getMapSupportedInput();
|
mapIn = m_listAlgo[_position]->getMapSupportedInput();
|
||||||
}
|
}
|
||||||
std::vector<std::vector<audio::channel>> map = getUnion<std::vector<audio::channel>>(mapOut, mapIn);
|
std::vector<std::vector<audio::channel> > map = getUnion<std::vector<audio::channel> >(mapOut, mapIn);
|
||||||
DRAIN_VERBOSE(" map out :" << mapOut);
|
DRAIN_VERBOSE(" map out :" << mapOut);
|
||||||
DRAIN_VERBOSE(" map in :" << mapIn);
|
DRAIN_VERBOSE(" map in :" << mapIn);
|
||||||
DRAIN_DEBUG(" map union :" << map);
|
DRAIN_DEBUG(" map union :" << map);
|
||||||
@ -343,7 +342,7 @@ void drain::Process::updateAlgo(size_t _position) {
|
|||||||
if ( out.getFormat() != audio::format_int16
|
if ( out.getFormat() != audio::format_int16
|
||||||
/* && out.getFormat() != format_float */) {
|
/* && out.getFormat() != format_float */) {
|
||||||
// need add a format Updater
|
// need add a format Updater
|
||||||
std::shared_ptr<drain::FormatUpdate> algo = drain::FormatUpdate::create();
|
std11::shared_ptr<drain::FormatUpdate> algo = drain::FormatUpdate::create();
|
||||||
algo->setTemporary();
|
algo->setTemporary();
|
||||||
algo->setInputFormat(out);
|
algo->setInputFormat(out);
|
||||||
out.setFormat(audio::format_int16);
|
out.setFormat(audio::format_int16);
|
||||||
@ -353,7 +352,7 @@ void drain::Process::updateAlgo(size_t _position) {
|
|||||||
_position++;
|
_position++;
|
||||||
}
|
}
|
||||||
// need add a resampler
|
// need add a resampler
|
||||||
std::shared_ptr<drain::Resampler> algo = drain::Resampler::create();
|
std11::shared_ptr<drain::Resampler> algo = drain::Resampler::create();
|
||||||
algo->setTemporary();
|
algo->setTemporary();
|
||||||
algo->setInputFormat(out);
|
algo->setInputFormat(out);
|
||||||
out.setFrequency(in.getFrequency());
|
out.setFrequency(in.getFrequency());
|
||||||
@ -365,7 +364,7 @@ void drain::Process::updateAlgo(size_t _position) {
|
|||||||
}
|
}
|
||||||
if (out.getMap() != in.getMap()) {
|
if (out.getMap() != in.getMap()) {
|
||||||
// need add a channel Reorder
|
// need add a channel Reorder
|
||||||
std::shared_ptr<drain::ChannelReorder> algo = drain::ChannelReorder::create();
|
std11::shared_ptr<drain::ChannelReorder> algo = drain::ChannelReorder::create();
|
||||||
algo->setTemporary();
|
algo->setTemporary();
|
||||||
algo->setInputFormat(out);
|
algo->setInputFormat(out);
|
||||||
out.setMap(in.getMap());
|
out.setMap(in.getMap());
|
||||||
@ -376,7 +375,7 @@ void drain::Process::updateAlgo(size_t _position) {
|
|||||||
}
|
}
|
||||||
if (out.getFormat() != in.getFormat()) {
|
if (out.getFormat() != in.getFormat()) {
|
||||||
// need add a format Updater
|
// need add a format Updater
|
||||||
std::shared_ptr<drain::FormatUpdate> algo = drain::FormatUpdate::create();
|
std11::shared_ptr<drain::FormatUpdate> algo = drain::FormatUpdate::create();
|
||||||
algo->setTemporary();
|
algo->setTemporary();
|
||||||
algo->setInputFormat(out);
|
algo->setInputFormat(out);
|
||||||
out.setFormat(in.getFormat());
|
out.setFormat(in.getFormat());
|
||||||
|
@ -14,8 +14,13 @@
|
|||||||
#include <audio/format.h>
|
#include <audio/format.h>
|
||||||
#include <audio/channel.h>
|
#include <audio/channel.h>
|
||||||
#include <drain/Algo.h>
|
#include <drain/Algo.h>
|
||||||
#include <chrono>
|
#if __cplusplus >= 201103L
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <chrono>
|
||||||
|
#else
|
||||||
|
#include <etk/chrono.h>
|
||||||
|
#include <etk/memory.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace drain{
|
namespace drain{
|
||||||
class Process {
|
class Process {
|
||||||
@ -33,7 +38,7 @@ namespace drain{
|
|||||||
* @return true The procress is done corectly.
|
* @return true The procress is done corectly.
|
||||||
* @return false An error occured.
|
* @return false An error occured.
|
||||||
*/
|
*/
|
||||||
bool push(std::chrono::system_clock::time_point& _time,
|
bool push(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _data,
|
void* _data,
|
||||||
size_t _nbChunk);
|
size_t _nbChunk);
|
||||||
/**
|
/**
|
||||||
@ -45,7 +50,7 @@ namespace drain{
|
|||||||
* @return true The procress is done corectly.
|
* @return true The procress is done corectly.
|
||||||
* @return false An error occured.
|
* @return false An error occured.
|
||||||
*/
|
*/
|
||||||
bool pull(std::chrono::system_clock::time_point& _time,
|
bool pull(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _data,
|
void* _data,
|
||||||
size_t _nbChunk,
|
size_t _nbChunk,
|
||||||
size_t _chunkSize);
|
size_t _chunkSize);
|
||||||
@ -59,7 +64,7 @@ namespace drain{
|
|||||||
* @return true The procress is done corectly.
|
* @return true The procress is done corectly.
|
||||||
* @return false An error occured.
|
* @return false An error occured.
|
||||||
*/
|
*/
|
||||||
bool process(std::chrono::system_clock::time_point& _time,
|
bool process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _inData,
|
void* _inData,
|
||||||
size_t _inNbChunk,
|
size_t _inNbChunk,
|
||||||
void*& _outData,
|
void*& _outData,
|
||||||
@ -68,7 +73,7 @@ namespace drain{
|
|||||||
size_t _inNbChunk,
|
size_t _inNbChunk,
|
||||||
void*& _outData,
|
void*& _outData,
|
||||||
size_t& _outNbChunk) {
|
size_t& _outNbChunk) {
|
||||||
std::chrono::system_clock::time_point time;
|
std11::chrono::system_clock::time_point time;
|
||||||
return process(time, _inData, _inNbChunk, _outData, _outNbChunk);
|
return process(time, _inData, _inNbChunk, _outData, _outNbChunk);
|
||||||
}
|
}
|
||||||
bool processIn(void* _inData,
|
bool processIn(void* _inData,
|
||||||
@ -94,10 +99,10 @@ namespace drain{
|
|||||||
m_outputConfig = _interface;
|
m_outputConfig = _interface;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
std::vector<std::shared_ptr<drain::Algo> > m_listAlgo;
|
std::vector<std11::shared_ptr<drain::Algo> > m_listAlgo;
|
||||||
public:
|
public:
|
||||||
void pushBack(const std::shared_ptr<drain::Algo>& _algo);
|
void pushBack(const std11::shared_ptr<drain::Algo>& _algo);
|
||||||
void pushFront(const std::shared_ptr<drain::Algo>& _algo);
|
void pushFront(const std11::shared_ptr<drain::Algo>& _algo);
|
||||||
void clear() {
|
void clear() {
|
||||||
m_isConfigured = false;
|
m_isConfigured = false;
|
||||||
m_listAlgo.clear();
|
m_listAlgo.clear();
|
||||||
@ -105,16 +110,41 @@ namespace drain{
|
|||||||
size_t size() {
|
size_t size() {
|
||||||
return m_listAlgo.size();
|
return m_listAlgo.size();
|
||||||
}
|
}
|
||||||
std::vector<std::shared_ptr<drain::Algo> >::iterator begin() {
|
std::vector<std11::shared_ptr<drain::Algo> >::iterator begin() {
|
||||||
return m_listAlgo.begin();
|
return m_listAlgo.begin();
|
||||||
}
|
}
|
||||||
std::vector<std::shared_ptr<drain::Algo> >::iterator end() {
|
std::vector<std11::shared_ptr<drain::Algo> >::iterator end() {
|
||||||
return m_listAlgo.end();
|
return m_listAlgo.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T> std11::shared_ptr<T> get(const std::string& _name) {
|
||||||
|
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||||
|
if (m_listAlgo[iii] == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m_listAlgo[iii]->getName() == _name) {
|
||||||
|
return std11::dynamic_pointer_cast<T>(m_listAlgo[iii]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std11::shared_ptr<T>();
|
||||||
|
}
|
||||||
|
template<typename T> std11::shared_ptr<const T> get(const std::string& _name) const {
|
||||||
|
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||||
|
if (m_listAlgo[iii] == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (m_listAlgo[iii]->getName() == _name) {
|
||||||
|
return std11::dynamic_pointer_cast<T>(m_listAlgo[iii]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std11::shared_ptr<const T>();
|
||||||
|
}
|
||||||
|
template<typename T> std11::shared_ptr<T> get(int32_t _id) {
|
||||||
|
return std11::dynamic_pointer_cast<T>(m_listAlgo[_id]);
|
||||||
|
}
|
||||||
template<typename T> void removeIfFirst() {
|
template<typename T> void removeIfFirst() {
|
||||||
if (m_listAlgo.size() > 0) {
|
if (m_listAlgo.size() > 0) {
|
||||||
std::shared_ptr<T> algoEP = std::dynamic_pointer_cast<T>(m_listAlgo[0]);
|
std11::shared_ptr<T> algoEP = get<T>(0);
|
||||||
if (algoEP != nullptr) {
|
if (algoEP != nullptr) {
|
||||||
m_listAlgo.erase(m_listAlgo.begin());
|
m_listAlgo.erase(m_listAlgo.begin());
|
||||||
}
|
}
|
||||||
@ -122,40 +152,15 @@ namespace drain{
|
|||||||
}
|
}
|
||||||
template<typename T> void removeIfLast() {
|
template<typename T> void removeIfLast() {
|
||||||
if (m_listAlgo.size() > 0) {
|
if (m_listAlgo.size() > 0) {
|
||||||
std::shared_ptr<T> algoEP = std::dynamic_pointer_cast<T>(m_listAlgo[m_listAlgo.size()-1]);
|
std11::shared_ptr<T> algoEP = get<T>(m_listAlgo.size()-1);
|
||||||
if (algoEP != nullptr) {
|
if (algoEP != nullptr) {
|
||||||
m_listAlgo.erase(m_listAlgo.begin()+m_listAlgo.size()-1);
|
m_listAlgo.erase(m_listAlgo.begin()+m_listAlgo.size()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template<typename T> std::shared_ptr<T> get(int32_t _id) {
|
|
||||||
return std::dynamic_pointer_cast<T>(m_listAlgo[_id]);
|
|
||||||
}
|
|
||||||
template<typename T> std::shared_ptr<T> get(const std::string& _name) {
|
|
||||||
for (auto &it : m_listAlgo) {
|
|
||||||
if (it == nullptr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (it->getName() == _name) {
|
|
||||||
return std::dynamic_pointer_cast<T>(it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
template<typename T> std::shared_ptr<const T> get(const std::string& _name) const {
|
|
||||||
for (auto &it : m_listAlgo) {
|
|
||||||
if (it == nullptr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (it->getName() == _name) {
|
|
||||||
return std::dynamic_pointer_cast<T>(it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
template<typename T> bool hasType() {
|
template<typename T> bool hasType() {
|
||||||
for (auto &it : m_listAlgo) {
|
for (size_t iii=0; iii<m_listAlgo.size(); ++iii) {
|
||||||
std::shared_ptr<T> tmp = std::dynamic_pointer_cast<T>(it);
|
std11::shared_ptr<T> tmp = std11::dynamic_pointer_cast<T>(m_listAlgo[iii]);
|
||||||
if (tmp != nullptr) {
|
if (tmp != nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ void drain::Resampler::init() {
|
|||||||
m_supportedFormat.push_back(audio::format_int16);
|
m_supportedFormat.push_back(audio::format_int16);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<drain::Resampler> drain::Resampler::create() {
|
std11::shared_ptr<drain::Resampler> drain::Resampler::create() {
|
||||||
std::shared_ptr<drain::Resampler> tmp(new drain::Resampler());
|
std11::shared_ptr<drain::Resampler> tmp(new drain::Resampler());
|
||||||
tmp->init();
|
tmp->init();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -84,8 +84,8 @@ void drain::Resampler::configurationChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
static std::ostream& operator <<(std::ostream& _os, const std::chrono::system_clock::time_point& _obj) {
|
static std::ostream& operator <<(std::ostream& _os, const std11::chrono::system_clock::time_point& _obj) {
|
||||||
std::chrono::nanoseconds ns = std::chrono::duration_cast<std::chrono::nanoseconds>(_obj.time_since_epoch());
|
std11::chrono::nanoseconds ns = std11::chrono::duration_cast<std11::chrono::nanoseconds>(_obj.time_since_epoch());
|
||||||
int64_t totalSecond = ns.count()/1000000000;
|
int64_t totalSecond = ns.count()/1000000000;
|
||||||
int64_t millisecond = (ns.count()%1000000000)/1000000;
|
int64_t millisecond = (ns.count()%1000000000)/1000000;
|
||||||
int64_t microsecond = (ns.count()%1000000)/1000;
|
int64_t microsecond = (ns.count()%1000000)/1000;
|
||||||
@ -102,7 +102,7 @@ namespace std {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool drain::Resampler::process(std::chrono::system_clock::time_point& _time,
|
bool drain::Resampler::process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
@ -126,7 +126,7 @@ bool drain::Resampler::process(std::chrono::system_clock::time_point& _time,
|
|||||||
DRAIN_VERBOSE("Resampler correct timestamp : " << _time << " ==> " << (_time - m_residualTimeInResampler));
|
DRAIN_VERBOSE("Resampler correct timestamp : " << _time << " ==> " << (_time - m_residualTimeInResampler));
|
||||||
_time -= m_residualTimeInResampler;
|
_time -= m_residualTimeInResampler;
|
||||||
|
|
||||||
std::chrono::nanoseconds inTime((int64_t(_inputNbChunk)*int64_t(1000000000)) / int64_t(m_input.getFrequency()));
|
std11::chrono::nanoseconds inTime((int64_t(_inputNbChunk)*int64_t(1000000000)) / int64_t(m_input.getFrequency()));
|
||||||
m_residualTimeInResampler += inTime;
|
m_residualTimeInResampler += inTime;
|
||||||
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
||||||
float nbInputTime = float(_inputNbChunk)/m_input.getFrequency();
|
float nbInputTime = float(_inputNbChunk)/m_input.getFrequency();
|
||||||
@ -165,7 +165,7 @@ bool drain::Resampler::process(std::chrono::system_clock::time_point& _time,
|
|||||||
}
|
}
|
||||||
_outputNbChunk = nbChunkOutput;
|
_outputNbChunk = nbChunkOutput;
|
||||||
DRAIN_VERBOSE(" process chunk=" << nbChunkInput << " out=" << nbChunkOutput);
|
DRAIN_VERBOSE(" process chunk=" << nbChunkInput << " out=" << nbChunkOutput);
|
||||||
std::chrono::nanoseconds outTime((int64_t(_outputNbChunk)*int64_t(1000000000)) / int64_t(m_output.getFrequency()));
|
std11::chrono::nanoseconds outTime((int64_t(_outputNbChunk)*int64_t(1000000000)) / int64_t(m_output.getFrequency()));
|
||||||
// correct time :
|
// correct time :
|
||||||
m_residualTimeInResampler -= outTime;
|
m_residualTimeInResampler -= outTime;
|
||||||
/*
|
/*
|
||||||
|
@ -11,7 +11,11 @@
|
|||||||
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
||||||
#include <speex/speex_resampler.h>
|
#include <speex/speex_resampler.h>
|
||||||
#endif
|
#endif
|
||||||
#include <memory>
|
#if __cplusplus >= 201103L
|
||||||
|
#include <memory>
|
||||||
|
#else
|
||||||
|
#include <etk/memory.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace drain {
|
namespace drain {
|
||||||
// TODO: Manage change timestamp when pull mode
|
// TODO: Manage change timestamp when pull mode
|
||||||
@ -30,7 +34,7 @@ namespace drain {
|
|||||||
Resampler();
|
Resampler();
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<Resampler> create();
|
static std11::shared_ptr<Resampler> create();
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@ -38,13 +42,13 @@ namespace drain {
|
|||||||
protected:
|
protected:
|
||||||
virtual void configurationChange();
|
virtual void configurationChange();
|
||||||
public:
|
public:
|
||||||
virtual bool process(std::chrono::system_clock::time_point& _time,
|
virtual bool process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
size_t& _outputNbChunk);
|
size_t& _outputNbChunk);
|
||||||
private:
|
private:
|
||||||
std::chrono::nanoseconds m_residualTimeInResampler; //!< the time of data locked in the resampler ...
|
std11::chrono::nanoseconds m_residualTimeInResampler; //!< the time of data locked in the resampler ...
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ void drain::Volume::init() {
|
|||||||
m_supportedFormat.push_back(audio::format_int16_on_int32);
|
m_supportedFormat.push_back(audio::format_int16_on_int32);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<drain::Volume> drain::Volume::create() {
|
std11::shared_ptr<drain::Volume> drain::Volume::create() {
|
||||||
std::shared_ptr<drain::Volume> tmp(new drain::Volume());
|
std11::shared_ptr<drain::Volume> tmp(new drain::Volume());
|
||||||
tmp->init();
|
tmp->init();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@ -155,15 +155,15 @@ void drain::Volume::configurationChange() {
|
|||||||
void drain::Volume::volumeChange() {
|
void drain::Volume::volumeChange() {
|
||||||
//m_volumeAppli = 20 * log(m_volumedB);
|
//m_volumeAppli = 20 * log(m_volumedB);
|
||||||
float volumedB = 0.0f;
|
float volumedB = 0.0f;
|
||||||
for (auto &it : m_volumeList) {
|
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||||
if (it == nullptr) {
|
if (m_volumeList[iii] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
volumedB += it->getVolume();
|
volumedB += m_volumeList[iii]->getVolume();
|
||||||
DRAIN_VERBOSE("append volume : '" << it->getName() << " vol=" << it->getVolume() << "dB");
|
DRAIN_VERBOSE("append volume : '" << m_volumeList[iii]->getName() << " vol=" << m_volumeList[iii]->getVolume() << "dB");
|
||||||
}
|
}
|
||||||
DRAIN_DEBUG(" Total volume : " << volumedB << "dB nbVolume=" << m_volumeList.size());
|
DRAIN_DEBUG(" Total volume : " << volumedB << "dB nbVolume=" << m_volumeList.size());
|
||||||
#if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs))
|
#if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs) || __cplusplus < 201103L)
|
||||||
m_volumeAppli = pow(10.0f, volumedB/20.0f);
|
m_volumeAppli = pow(10.0f, volumedB/20.0f);
|
||||||
#else
|
#else
|
||||||
m_volumeAppli = std::pow(10.0f, volumedB/20.0f);
|
m_volumeAppli = std::pow(10.0f, volumedB/20.0f);
|
||||||
@ -304,7 +304,7 @@ std::vector<audio::format> drain::Volume::getFormatSupportedOutput() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool drain::Volume::process(std::chrono::system_clock::time_point& _time,
|
bool drain::Volume::process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
@ -334,19 +334,19 @@ bool drain::Volume::process(std::chrono::system_clock::time_point& _time,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drain::Volume::addVolumeStage(const std::shared_ptr<VolumeElement>& _volume) {
|
void drain::Volume::addVolumeStage(const std11::shared_ptr<VolumeElement>& _volume) {
|
||||||
if (_volume == nullptr) {
|
if (_volume == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto &it : m_volumeList) {
|
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||||
if (it == nullptr) {
|
if (m_volumeList[iii] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it == _volume) {
|
if (m_volumeList[iii] == _volume) {
|
||||||
// already done ...
|
// already done ...
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (it->getName() == _volume->getName()) {
|
if (m_volumeList[iii]->getName() == _volume->getName()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -357,11 +357,11 @@ void drain::Volume::addVolumeStage(const std::shared_ptr<VolumeElement>& _volume
|
|||||||
bool drain::Volume::setParameter(const std::string& _parameter, const std::string& _value) {
|
bool drain::Volume::setParameter(const std::string& _parameter, const std::string& _value) {
|
||||||
if (_parameter == "FLOW") {
|
if (_parameter == "FLOW") {
|
||||||
// set Volume ...
|
// set Volume ...
|
||||||
for (auto &it : m_volumeList) {
|
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||||
if (it == nullptr) {
|
if (m_volumeList[iii] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it->getName() == "FLOW") {
|
if (m_volumeList[iii]->getName() == "FLOW") {
|
||||||
float value = 0;
|
float value = 0;
|
||||||
if (sscanf(_value.c_str(), "%fdB", &value) != 1) {
|
if (sscanf(_value.c_str(), "%fdB", &value) != 1) {
|
||||||
return false;
|
return false;
|
||||||
@ -371,7 +371,7 @@ bool drain::Volume::setParameter(const std::string& _parameter, const std::strin
|
|||||||
DRAIN_ERROR("Can not set volume ... : '" << _parameter << "' out of range : [-300..300]");
|
DRAIN_ERROR("Can not set volume ... : '" << _parameter << "' out of range : [-300..300]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
it->setVolume(value);
|
m_volumeList[iii]->setVolume(value);
|
||||||
DRAIN_DEBUG("Set volume : FLOW = " << value << " dB (from:" << _value << ")");
|
DRAIN_DEBUG("Set volume : FLOW = " << value << " dB (from:" << _value << ")");
|
||||||
volumeChange();
|
volumeChange();
|
||||||
return true;
|
return true;
|
||||||
@ -385,12 +385,12 @@ bool drain::Volume::setParameter(const std::string& _parameter, const std::strin
|
|||||||
std::string drain::Volume::getParameter(const std::string& _parameter) const {
|
std::string drain::Volume::getParameter(const std::string& _parameter) const {
|
||||||
if (_parameter == "FLOW") {
|
if (_parameter == "FLOW") {
|
||||||
// set Volume ...
|
// set Volume ...
|
||||||
for (auto &it : m_volumeList) {
|
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||||
if (it == nullptr) {
|
if (m_volumeList[iii] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it->getName() == "FLOW") {
|
if (m_volumeList[iii]->getName() == "FLOW") {
|
||||||
return std::to_string(it->getVolume()) + "dB";
|
return etk::to_string(m_volumeList[iii]->getVolume()) + "dB";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -401,11 +401,11 @@ std::string drain::Volume::getParameter(const std::string& _parameter) const {
|
|||||||
std::string drain::Volume::getParameterProperty(const std::string& _parameter) const {
|
std::string drain::Volume::getParameterProperty(const std::string& _parameter) const {
|
||||||
if (_parameter == "FLOW") {
|
if (_parameter == "FLOW") {
|
||||||
// set Volume ...
|
// set Volume ...
|
||||||
for (auto &it : m_volumeList) {
|
for (size_t iii=0; iii<m_volumeList.size(); ++iii) {
|
||||||
if (it == nullptr) {
|
if (m_volumeList[iii] == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (it->getName() == "FLOW") {
|
if (m_volumeList[iii]->getName() == "FLOW") {
|
||||||
return "[-300..300]dB";
|
return "[-300..300]dB";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,11 @@
|
|||||||
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
#ifdef HAVE_SPEEX_DSP_RESAMPLE
|
||||||
#include <speex/speex_resampler.h>
|
#include <speex/speex_resampler.h>
|
||||||
#endif
|
#endif
|
||||||
#include <memory>
|
#if __cplusplus >= 201103L
|
||||||
|
#include <memory>
|
||||||
|
#else
|
||||||
|
#include <etk/memory.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace drain {
|
namespace drain {
|
||||||
// data structure.
|
// data structure.
|
||||||
@ -45,7 +49,7 @@ namespace drain {
|
|||||||
// TODO: Manage set volume
|
// TODO: Manage set volume
|
||||||
class Volume : public Algo {
|
class Volume : public Algo {
|
||||||
private:
|
private:
|
||||||
std::vector<std::shared_ptr<drain::VolumeElement>> m_volumeList;
|
std::vector<std11::shared_ptr<drain::VolumeElement> > m_volumeList;
|
||||||
// for float input :
|
// for float input :
|
||||||
float m_volumeAppli;
|
float m_volumeAppli;
|
||||||
// for integer input :
|
// for integer input :
|
||||||
@ -60,7 +64,7 @@ namespace drain {
|
|||||||
Volume();
|
Volume();
|
||||||
void init();
|
void init();
|
||||||
public:
|
public:
|
||||||
static std::shared_ptr<Volume> create();
|
static std11::shared_ptr<Volume> create();
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
@ -68,7 +72,7 @@ namespace drain {
|
|||||||
protected:
|
protected:
|
||||||
virtual void configurationChange();
|
virtual void configurationChange();
|
||||||
public:
|
public:
|
||||||
virtual bool process(std::chrono::system_clock::time_point& _time,
|
virtual bool process(std11::chrono::system_clock::time_point& _time,
|
||||||
void* _input,
|
void* _input,
|
||||||
size_t _inputNbChunk,
|
size_t _inputNbChunk,
|
||||||
void*& _output,
|
void*& _output,
|
||||||
@ -77,7 +81,7 @@ namespace drain {
|
|||||||
virtual std::vector<audio::format> getFormatSupportedInput();
|
virtual std::vector<audio::format> getFormatSupportedInput();
|
||||||
virtual std::vector<audio::format> getFormatSupportedOutput();
|
virtual std::vector<audio::format> getFormatSupportedOutput();
|
||||||
public:
|
public:
|
||||||
virtual void addVolumeStage(const std::shared_ptr<drain::VolumeElement>& _volume);
|
virtual void addVolumeStage(const std11::shared_ptr<drain::VolumeElement>& _volume);
|
||||||
virtual bool setParameter(const std::string& _parameter, const std::string& _value);
|
virtual bool setParameter(const std::string& _parameter, const std::string& _value);
|
||||||
virtual std::string getParameter(const std::string& _parameter) const;
|
virtual std::string getParameter(const std::string& _parameter) const;
|
||||||
virtual std::string getParameterProperty(const std::string& _parameter) const;
|
virtual std::string getParameterProperty(const std::string& _parameter) const;
|
||||||
|
@ -10,7 +10,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <audio/format.h>
|
#include <audio/format.h>
|
||||||
#include <drain/channel.h>
|
#include <drain/channel.h>
|
||||||
#include <chrono>
|
#if __cplusplus >= 201103L
|
||||||
|
#include <chrono>
|
||||||
|
#else
|
||||||
|
#include <etk/chrono.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace drain {
|
namespace drain {
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user