[DEV] WORK on a port for BOOST

This commit is contained in:
Edouard DUPIN 2015-02-24 22:20:11 +01:00
parent 62cb1ef639
commit 0b50032cab
17 changed files with 436 additions and 381 deletions

View File

@ -67,7 +67,7 @@ void river::CircularBuffer::setCapacity(size_t _capacity, size_t _chunkSize, uin
m_write = &m_data[0]; m_write = &m_data[0];
} }
void river::CircularBuffer::setCapacity(std::chrono::milliseconds _capacity, size_t _chunkSize, uint32_t _frequency) { void river::CircularBuffer::setCapacity(std11::chrono::milliseconds _capacity, size_t _chunkSize, uint32_t _frequency) {
uint32_t nbSampleNeeded = _frequency*_capacity.count()/1000; uint32_t nbSampleNeeded = _frequency*_capacity.count()/1000;
RIVER_DEBUG("buffer setCapacity(" << _capacity.count() << "ms ," << _chunkSize << ")"); RIVER_DEBUG("buffer setCapacity(" << _capacity.count() << "ms ," << _chunkSize << ")");
setCapacity(nbSampleNeeded, _chunkSize, _frequency); setCapacity(nbSampleNeeded, _chunkSize, _frequency);
@ -102,7 +102,7 @@ size_t river::CircularBuffer::getFreeSizeBeforEnd() const {
return size; return size;
} }
size_t river::CircularBuffer::write(const void* _data, size_t _nbChunk, const std::chrono::system_clock::time_point& _time) { size_t river::CircularBuffer::write(const void* _data, size_t _nbChunk, const std11::chrono::system_clock::time_point& _time) {
size_t nbElementDrop = 0; size_t nbElementDrop = 0;
size_t freeSizeBeforeEnd = getFreeSizeBeforEnd(); size_t freeSizeBeforeEnd = getFreeSizeBeforEnd();
size_t freeSize = m_capacity - m_size; size_t freeSize = m_capacity - m_size;
@ -168,14 +168,14 @@ size_t river::CircularBuffer::read(void* _data, size_t _nbChunk) {
return read(_data, _nbChunk, m_timeRead); return read(_data, _nbChunk, m_timeRead);
} }
size_t river::CircularBuffer::read(void* _data, size_t _nbChunk, const std::chrono::system_clock::time_point& _time) { size_t river::CircularBuffer::read(void* _data, size_t _nbChunk, const std11::chrono::system_clock::time_point& _time) {
size_t nbElementDrop = 0; size_t nbElementDrop = 0;
// Critical section (theoriquely protected by Mutex) // Critical section (theoriquely protected by Mutex)
size_t usedSizeBeforeEnd = getUsedSizeBeforEnd(); size_t usedSizeBeforeEnd = getUsedSizeBeforEnd();
// verify if we have elements in the Buffer // verify if we have elements in the Buffer
if (0 < m_size) { if (0 < m_size) {
// check the time of the read : // check the time of the read :
std::chrono::nanoseconds deltaTime = m_timeRead - _time; std11::chrono::nanoseconds deltaTime = m_timeRead - _time;
if (deltaTime.count() == 0) { if (deltaTime.count() == 0) {
// nothing to do ==> just copy data ... // nothing to do ==> just copy data ...
} else if (deltaTime.count() > 0) { } else if (deltaTime.count() > 0) {
@ -196,7 +196,7 @@ size_t river::CircularBuffer::read(void* _data, size_t _nbChunk, const std::chro
nbElementDrop = _nbChunk - m_size; nbElementDrop = _nbChunk - m_size;
_nbChunk = m_size; _nbChunk = m_size;
} }
m_timeRead += std::chrono::microseconds(_nbChunk*1000000/m_frequency); m_timeRead += std11::chrono::microseconds(_nbChunk*1000000/m_frequency);
if (usedSizeBeforeEnd >= _nbChunk) { if (usedSizeBeforeEnd >= _nbChunk) {
// all Data will be copy // all Data will be copy
memcpy(_data, m_read, _nbChunk * m_sizeChunk); memcpy(_data, m_read, _nbChunk * m_sizeChunk);
@ -234,16 +234,16 @@ size_t river::CircularBuffer::read(void* _data, size_t _nbChunk, const std::chro
// return the number of element droped // return the number of element droped
return nbElementDrop; return nbElementDrop;
} }
void river::CircularBuffer::setReadPosition(const std::chrono::system_clock::time_point& _time) { void river::CircularBuffer::setReadPosition(const std11::chrono::system_clock::time_point& _time) {
// Critical section (theoriquely protected by Mutex) // Critical section (theoriquely protected by Mutex)
size_t usedSizeBeforeEnd = getUsedSizeBeforEnd(); size_t usedSizeBeforeEnd = getUsedSizeBeforEnd();
if (0 < m_size) { if (0 < m_size) {
// check the time of the read : // check the time of the read :
std::chrono::nanoseconds deltaTime = _time - m_timeRead; std11::chrono::nanoseconds deltaTime = _time - m_timeRead;
size_t nbSampleToRemove = m_frequency*deltaTime.count()/1000000000; size_t nbSampleToRemove = m_frequency*deltaTime.count()/1000000000;
nbSampleToRemove = std::min(nbSampleToRemove, m_size); nbSampleToRemove = std::min(nbSampleToRemove, m_size);
RIVER_WARNING("Remove sample in the buffer " << nbSampleToRemove << " / " << m_size); RIVER_WARNING("Remove sample in the buffer " << nbSampleToRemove << " / " << m_size);
std::chrono::nanoseconds updateTime((nbSampleToRemove*1000000000)/int64_t(m_frequency)); std11::chrono::nanoseconds updateTime((nbSampleToRemove*1000000000)/int64_t(m_frequency));
if (usedSizeBeforeEnd >= nbSampleToRemove) { if (usedSizeBeforeEnd >= nbSampleToRemove) {
usedSizeBeforeEnd -= nbSampleToRemove; usedSizeBeforeEnd -= nbSampleToRemove;
m_size -= nbSampleToRemove; m_size -= nbSampleToRemove;
@ -256,7 +256,7 @@ void river::CircularBuffer::setReadPosition(const std::chrono::system_clock::tim
m_timeRead += updateTime; m_timeRead += updateTime;
//m_timeRead += deltaTime; //m_timeRead += deltaTime;
} else { } else {
m_timeRead = std::chrono::system_clock::time_point(); m_timeRead = std11::chrono::system_clock::time_point();
} }
} }

View File

@ -10,7 +10,11 @@
#include <etk/types.h> #include <etk/types.h>
#include <vector> #include <vector>
#include <chrono> #if __cplusplus >= 201103L
#include <chrono>
#else
#include <etk/chrono.h>
#endif
namespace river { namespace river {
/** /**
@ -43,7 +47,7 @@ namespace river {
std::vector<uint8_t> m_data; //!< data pointer std::vector<uint8_t> m_data; //!< data pointer
void* m_write; //!< write pointer void* m_write; //!< write pointer
void* m_read; //!< read pointer void* m_read; //!< read pointer
std::chrono::system_clock::time_point m_timeRead; //!< current read time std11::chrono::system_clock::time_point m_timeRead; //!< current read time
uint32_t m_frequency; uint32_t m_frequency;
// TODO : Remove the m_size ==> this is a bad element to be mutex-less // TODO : Remove the m_size ==> this is a bad element to be mutex-less
size_t m_size; //!< number of chunk availlable in this buffer size_t m_size; //!< number of chunk availlable in this buffer
@ -75,7 +79,7 @@ namespace river {
* @param[in] _chunkSize Size of one chunk. * @param[in] _chunkSize Size of one chunk.
* @param[in] _frequency Frequency of the buffer * @param[in] _frequency Frequency of the buffer
*/ */
void setCapacity(std::chrono::milliseconds _capacity, size_t _chunkSize, uint32_t _frequency); void setCapacity(std11::chrono::milliseconds _capacity, size_t _chunkSize, uint32_t _frequency);
/** /**
* @brief get free size of the buffer. * @brief get free size of the buffer.
* @return Number of free chunk. * @return Number of free chunk.
@ -102,7 +106,7 @@ namespace river {
* @param[in] _time Time to start write data (if before end ==> not replace data, write only if after end) * @param[in] _time Time to start write data (if before end ==> not replace data, write only if after end)
* @return Number of chunk copied. * @return Number of chunk copied.
*/ */
size_t write(const void* _data, size_t _nbChunk, const std::chrono::system_clock::time_point& _time); size_t write(const void* _data, size_t _nbChunk, const std11::chrono::system_clock::time_point& _time);
/** /**
* @brief Read Chunk from the buffer to the pointer data. * @brief Read Chunk from the buffer to the pointer data.
* @param[out] _data Pointer on the data. * @param[out] _data Pointer on the data.
@ -110,12 +114,12 @@ namespace river {
* @param[in] _time Time to start read data (if before start ==> add 0 at start, if after, remove unread data) * @param[in] _time Time to start read data (if before start ==> add 0 at start, if after, remove unread data)
* @return Number of chunk copied. * @return Number of chunk copied.
*/ */
size_t read(void* _data, size_t _nbChunk, const std::chrono::system_clock::time_point& _time); size_t read(void* _data, size_t _nbChunk, const std11::chrono::system_clock::time_point& _time);
//! @previous //! @previous
size_t read(void* _data, size_t _nbChunk); size_t read(void* _data, size_t _nbChunk);
void setReadPosition(const std::chrono::system_clock::time_point& _time); void setReadPosition(const std11::chrono::system_clock::time_point& _time);
std::chrono::system_clock::time_point getReadTimeStamp() { std11::chrono::system_clock::time_point getReadTimeStamp() {
return m_timeRead; return m_timeRead;
} }
/** /**

View File

@ -17,7 +17,7 @@
#define __class__ "Interface" #define __class__ "Interface"
river::Interface::Interface(void) : river::Interface::Interface(void) :
m_node(nullptr), m_node(),
m_name(""), m_name(""),
m_volume(0.0f) { m_volume(0.0f) {
static uint32_t uid = 0; static uint32_t uid = 0;
@ -29,8 +29,8 @@ bool river::Interface::init(const std::string& _name,
float _freq, float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::shared_ptr<river::io::Node>& _node, const std11::shared_ptr<river::io::Node>& _node,
const std::shared_ptr<const ejson::Object>& _config) { const std11::shared_ptr<const ejson::Object>& _config) {
m_name = _name; m_name = _name;
m_node = _node; m_node = _node;
m_volume = 0.0f; m_volume = 0.0f;
@ -51,12 +51,12 @@ bool river::Interface::init(const std::string& _name,
&& m_mode == river::modeInterface_input) { && m_mode == river::modeInterface_input) {
m_process.setInputConfig(m_node->getInterfaceFormat()); m_process.setInputConfig(m_node->getInterfaceFormat());
// add all time the volume stage : // add all time the volume stage :
std::shared_ptr<drain::Volume> algo = drain::Volume::create(); std11::shared_ptr<drain::Volume> algo = drain::Volume::create();
//algo->setInputFormat(m_node->getInterfaceFormat()); //algo->setInputFormat(m_node->getInterfaceFormat());
algo->setName("volume"); algo->setName("volume");
m_process.pushBack(algo); m_process.pushBack(algo);
RIVER_INFO("add basic volume stage (1)"); RIVER_INFO("add basic volume stage (1)");
std::shared_ptr<drain::VolumeElement> tmpVolume = m_node->getVolume(); std11::shared_ptr<drain::VolumeElement> tmpVolume = m_node->getVolume();
if (tmpVolume != nullptr) { if (tmpVolume != nullptr) {
RIVER_INFO(" add volume for node"); RIVER_INFO(" add volume for node");
algo->addVolumeStage(tmpVolume); algo->addVolumeStage(tmpVolume);
@ -66,12 +66,12 @@ bool river::Interface::init(const std::string& _name,
&& m_mode == river::modeInterface_output) { && m_mode == river::modeInterface_output) {
m_process.setInputConfig(drain::IOFormatInterface(_map, _format, _freq)); m_process.setInputConfig(drain::IOFormatInterface(_map, _format, _freq));
// add all time the volume stage : // add all time the volume stage :
std::shared_ptr<drain::Volume> algo = drain::Volume::create(); std11::shared_ptr<drain::Volume> algo = drain::Volume::create();
//algo->setOutputFormat(m_node->getInterfaceFormat()); //algo->setOutputFormat(m_node->getInterfaceFormat());
algo->setName("volume"); algo->setName("volume");
m_process.pushBack(algo); m_process.pushBack(algo);
RIVER_INFO("add basic volume stage (2)"); RIVER_INFO("add basic volume stage (2)");
std::shared_ptr<drain::VolumeElement> tmpVolume = m_node->getVolume(); std11::shared_ptr<drain::VolumeElement> tmpVolume = m_node->getVolume();
if (tmpVolume != nullptr) { if (tmpVolume != nullptr) {
RIVER_INFO(" add volume for node"); RIVER_INFO(" add volume for node");
algo->addVolumeStage(tmpVolume); algo->addVolumeStage(tmpVolume);
@ -81,7 +81,7 @@ bool river::Interface::init(const std::string& _name,
&& m_mode == river::modeInterface_feedback) { && m_mode == river::modeInterface_feedback) {
m_process.setInputConfig(m_node->getHarwareFormat()); m_process.setInputConfig(m_node->getHarwareFormat());
// add all time the volume stage : // add all time the volume stage :
std::shared_ptr<drain::Volume> algo = drain::Volume::create(); std11::shared_ptr<drain::Volume> algo = drain::Volume::create();
//algo->setInputFormat(m_node->getInterfaceFormat()); //algo->setInputFormat(m_node->getInterfaceFormat());
algo->setName("volume"); algo->setName("volume");
m_process.pushBack(algo); m_process.pushBack(algo);
@ -94,20 +94,20 @@ bool river::Interface::init(const std::string& _name,
return true; return true;
} }
std::shared_ptr<river::Interface> river::Interface::create(const std::string& _name, std11::shared_ptr<river::Interface> river::Interface::create(const std::string& _name,
float _freq, float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::shared_ptr<river::io::Node>& _node, const std11::shared_ptr<river::io::Node>& _node,
const std::shared_ptr<const ejson::Object>& _config) { const std11::shared_ptr<const ejson::Object>& _config) {
std::shared_ptr<river::Interface> out = std::shared_ptr<river::Interface>(new river::Interface()); std11::shared_ptr<river::Interface> out = std11::shared_ptr<river::Interface>(new river::Interface());
out->init(_name, _freq, _map, _format, _node, _config); out->init(_name, _freq, _map, _format, _node, _config);
return out; return out;
} }
river::Interface::~Interface() { river::Interface::~Interface() {
//stop(true, true); //stop(true, true);
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
//m_node->interfaceRemove(shared_from_this()); //m_node->interfaceRemove(shared_from_this());
} }
/* /*
@ -116,7 +116,7 @@ bool river::Interface::hasEndPoint() {
} }
*/ */
void river::Interface::setReadwrite() { void river::Interface::setReadwrite() {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
m_process.removeAlgoDynamic(); m_process.removeAlgoDynamic();
if (m_process.hasType<drain::EndPoint>() ) { if (m_process.hasType<drain::EndPoint>() ) {
RIVER_ERROR("Endpoint is already present ==> can not change"); RIVER_ERROR("Endpoint is already present ==> can not change");
@ -124,43 +124,43 @@ void river::Interface::setReadwrite() {
} }
if (m_node->isInput() == true) { if (m_node->isInput() == true) {
m_process.removeIfLast<drain::EndPoint>(); m_process.removeIfLast<drain::EndPoint>();
std::shared_ptr<drain::EndPointRead> algo = drain::EndPointRead::create(); std11::shared_ptr<drain::EndPointRead> algo = drain::EndPointRead::create();
m_process.pushBack(algo); m_process.pushBack(algo);
} else { } else {
m_process.removeIfFirst<drain::EndPoint>(); m_process.removeIfFirst<drain::EndPoint>();
std::shared_ptr<drain::EndPointWrite> algo = drain::EndPointWrite::create(); std11::shared_ptr<drain::EndPointWrite> algo = drain::EndPointWrite::create();
m_process.pushFront(algo); m_process.pushFront(algo);
} }
} }
void river::Interface::setOutputCallback(drain::playbackFunction _function) { void river::Interface::setOutputCallback(drain::playbackFunction _function) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
m_process.removeAlgoDynamic(); m_process.removeAlgoDynamic();
m_process.removeIfFirst<drain::EndPoint>(); m_process.removeIfFirst<drain::EndPoint>();
std::shared_ptr<drain::Algo> algo = drain::EndPointCallback::create(_function); std11::shared_ptr<drain::Algo> algo = drain::EndPointCallback::create(_function);
m_process.pushFront(algo); m_process.pushFront(algo);
} }
void river::Interface::setInputCallback(drain::recordFunction _function) { void river::Interface::setInputCallback(drain::recordFunction _function) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
m_process.removeAlgoDynamic(); m_process.removeAlgoDynamic();
m_process.removeIfLast<drain::EndPoint>(); m_process.removeIfLast<drain::EndPoint>();
std::shared_ptr<drain::Algo> algo = drain::EndPointCallback::create(_function); std11::shared_ptr<drain::Algo> algo = drain::EndPointCallback::create(_function);
m_process.pushBack(algo); m_process.pushBack(algo);
} }
void river::Interface::setWriteCallback(drain::playbackFunctionWrite _function) { void river::Interface::setWriteCallback(drain::playbackFunctionWrite _function) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
m_process.removeAlgoDynamic(); m_process.removeAlgoDynamic();
std::shared_ptr<drain::EndPointWrite> algo = m_process.get<drain::EndPointWrite>(0); std11::shared_ptr<drain::EndPointWrite> algo = m_process.get<drain::EndPointWrite>(0);
if (algo == nullptr) { if (algo == nullptr) {
return; return;
} }
algo->setCallback(_function); algo->setCallback(_function);
} }
void river::Interface::start(const std::chrono::system_clock::time_point& _time) { void river::Interface::start(const std11::chrono::system_clock::time_point& _time) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
RIVER_DEBUG("start [BEGIN]"); RIVER_DEBUG("start [BEGIN]");
m_process.updateInterAlgo(); m_process.updateInterAlgo();
m_node->interfaceAdd(shared_from_this()); m_node->interfaceAdd(shared_from_this());
@ -168,14 +168,14 @@ void river::Interface::start(const std::chrono::system_clock::time_point& _time)
} }
void river::Interface::stop(bool _fast, bool _abort) { void river::Interface::stop(bool _fast, bool _abort) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
RIVER_DEBUG("stop [BEGIN]"); RIVER_DEBUG("stop [BEGIN]");
m_node->interfaceRemove(shared_from_this()); m_node->interfaceRemove(shared_from_this());
RIVER_DEBUG("stop [ END]"); RIVER_DEBUG("stop [ END]");
} }
void river::Interface::abort() { void river::Interface::abort() {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
RIVER_DEBUG("abort [BEGIN]"); RIVER_DEBUG("abort [BEGIN]");
// TODO :... // TODO :...
RIVER_DEBUG("abort [ END ]"); RIVER_DEBUG("abort [ END ]");
@ -189,7 +189,7 @@ bool river::Interface::setParameter(const std::string& _filter, const std::strin
RIVER_ERROR("Interface is not allowed to modify '" << _parameter << "' Volume just allowed to modify 'FLOW' volume"); RIVER_ERROR("Interface is not allowed to modify '" << _parameter << "' Volume just allowed to modify 'FLOW' volume");
return false; return false;
} }
std::shared_ptr<drain::Algo> algo = m_process.get<drain::Algo>(_filter); std11::shared_ptr<drain::Algo> algo = m_process.get<drain::Algo>(_filter);
if (algo == nullptr) { if (algo == nullptr) {
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ..."); RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
return false; return false;
@ -201,7 +201,7 @@ bool river::Interface::setParameter(const std::string& _filter, const std::strin
std::string river::Interface::getParameter(const std::string& _filter, const std::string& _parameter) const { std::string river::Interface::getParameter(const std::string& _filter, const std::string& _parameter) const {
RIVER_DEBUG("getParameter [BEGIN] : '" << _filter << "':'" << _parameter << "'"); RIVER_DEBUG("getParameter [BEGIN] : '" << _filter << "':'" << _parameter << "'");
std::string out; std::string out;
std::shared_ptr<const drain::Algo> algo = m_process.get<const drain::Algo>(_filter); std11::shared_ptr<const drain::Algo> algo = m_process.get<const drain::Algo>(_filter);
if (algo == nullptr) { if (algo == nullptr) {
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ..."); RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
return "[ERROR]"; return "[ERROR]";
@ -213,7 +213,7 @@ std::string river::Interface::getParameter(const std::string& _filter, const std
std::string river::Interface::getParameterProperty(const std::string& _filter, const std::string& _parameter) const { std::string river::Interface::getParameterProperty(const std::string& _filter, const std::string& _parameter) const {
RIVER_DEBUG("getParameterProperty [BEGIN] : '" << _filter << "':'" << _parameter << "'"); RIVER_DEBUG("getParameterProperty [BEGIN] : '" << _filter << "':'" << _parameter << "'");
std::string out; std::string out;
std::shared_ptr<const drain::Algo> algo = m_process.get<const drain::Algo>(_filter); std11::shared_ptr<const drain::Algo> algo = m_process.get<const drain::Algo>(_filter);
if (algo == nullptr) { if (algo == nullptr) {
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ..."); RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
return "[ERROR]"; return "[ERROR]";
@ -224,9 +224,9 @@ std::string river::Interface::getParameterProperty(const std::string& _filter, c
} }
void river::Interface::write(const void* _value, size_t _nbChunk) { void river::Interface::write(const void* _value, size_t _nbChunk) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
m_process.updateInterAlgo(); m_process.updateInterAlgo();
std::shared_ptr<drain::EndPointWrite> algo = m_process.get<drain::EndPointWrite>(0); std11::shared_ptr<drain::EndPointWrite> algo = m_process.get<drain::EndPointWrite>(0);
if (algo == nullptr) { if (algo == nullptr) {
return; return;
} }
@ -259,78 +259,78 @@ std::vector<int16_t> river::Interface::read(size_t _nbChunk) {
#endif #endif
void river::Interface::read(void* _value, size_t _nbChunk) { void river::Interface::read(void* _value, size_t _nbChunk) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
m_process.updateInterAlgo(); m_process.updateInterAlgo();
// TODO :... // TODO :...
} }
size_t river::Interface::size() const { size_t river::Interface::size() const {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
// TODO :... // TODO :...
return 0; return 0;
} }
void river::Interface::setBufferSize(size_t _nbChunk) { void river::Interface::setBufferSize(size_t _nbChunk) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
m_process.updateInterAlgo(); m_process.updateInterAlgo();
// TODO :... // TODO :...
} }
void river::Interface::setBufferSize(const std::chrono::duration<int64_t, std::micro>& _time) { void river::Interface::setBufferSize(const std11::chrono::microseconds& _time) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
m_process.updateInterAlgo(); m_process.updateInterAlgo();
// TODO :... // TODO :...
} }
void river::Interface::clearInternalBuffer() { void river::Interface::clearInternalBuffer() {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
m_process.updateInterAlgo(); m_process.updateInterAlgo();
// TODO :... // TODO :...
} }
std::chrono::system_clock::time_point river::Interface::getCurrentTime() const { std11::chrono::system_clock::time_point river::Interface::getCurrentTime() const {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
// TODO :... // TODO :...
return std::chrono::system_clock::time_point(); return std11::chrono::system_clock::time_point();
return std::chrono::system_clock::now(); return std11::chrono::system_clock::now();
} }
void river::Interface::addVolumeGroup(const std::string& _name) { void river::Interface::addVolumeGroup(const std::string& _name) {
std::unique_lock<std::recursive_mutex> lock(m_mutex); std11::unique_lock<std11::recursive_mutex> lock(m_mutex);
RIVER_DEBUG("addVolumeGroup(" << _name << ")"); RIVER_DEBUG("addVolumeGroup(" << _name << ")");
std::shared_ptr<drain::Volume> algo = m_process.get<drain::Volume>("volume"); std11::shared_ptr<drain::Volume> algo = m_process.get<drain::Volume>("volume");
if (algo == nullptr) { if (algo == nullptr) {
RIVER_ERROR("addVolumeGroup(" << _name << ") ==> no volume stage ... can not add it ..."); RIVER_ERROR("addVolumeGroup(" << _name << ") ==> no volume stage ... can not add it ...");
return; return;
} }
if (_name == "FLOW") { if (_name == "FLOW") {
// Local volume name // Local volume name
algo->addVolumeStage(std::make_shared<drain::VolumeElement>(_name)); algo->addVolumeStage(std11::make_shared<drain::VolumeElement>(_name));
} else { } else {
// get manager unique instance: // get manager unique instance:
std::shared_ptr<river::io::Manager> mng = river::io::Manager::getInstance(); std11::shared_ptr<river::io::Manager> mng = river::io::Manager::getInstance();
algo->addVolumeStage(mng->getVolumeGroup(_name)); algo->addVolumeStage(mng->getVolumeGroup(_name));
} }
} }
void river::Interface::systemNewInputData(std::chrono::system_clock::time_point _time, const void* _data, size_t _nbChunk) { void river::Interface::systemNewInputData(std11::chrono::system_clock::time_point _time, const void* _data, size_t _nbChunk) {
std::unique_lock<std::recursive_mutex> lockProcess(m_mutex); std11::unique_lock<std11::recursive_mutex> lockProcess(m_mutex);
void * tmpData = const_cast<void*>(_data); void * tmpData = const_cast<void*>(_data);
m_process.push(_time, tmpData, _nbChunk); m_process.push(_time, tmpData, _nbChunk);
} }
void river::Interface::systemNeedOutputData(std::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk, size_t _chunkSize) { void river::Interface::systemNeedOutputData(std11::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk, size_t _chunkSize) {
std::unique_lock<std::recursive_mutex> lockProcess(m_mutex); std11::unique_lock<std11::recursive_mutex> lockProcess(m_mutex);
m_process.pull(_time, _data, _nbChunk, _chunkSize); m_process.pull(_time, _data, _nbChunk, _chunkSize);
} }
void river::Interface::systemVolumeChange() { void river::Interface::systemVolumeChange() {
std::unique_lock<std::recursive_mutex> lockProcess(m_mutex); std11::unique_lock<std11::recursive_mutex> lockProcess(m_mutex);
std::shared_ptr<drain::Volume> algo = m_process.get<drain::Volume>("volume"); std11::shared_ptr<drain::Volume> algo = m_process.get<drain::Volume>("volume");
if (algo == nullptr) { if (algo == nullptr) {
return; return;
} }

View File

@ -10,15 +10,22 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <stdint.h> #include <stdint.h>
#include <chrono> #if __cplusplus >= 201103L
#include <functional> #include <mutex>
#include <mutex> #include <chrono>
#include <functional>
#include <memory>
#else
#include <etk/mutex.h>
#include <etk/chrono.h>
#include <etk/functional.h>
#include <etk/memory.h>
#endif
#include <audio/format.h> #include <audio/format.h>
#include <audio/channel.h> #include <audio/channel.h>
#include <drain/Process.h> #include <drain/Process.h>
#include <drain/EndPointCallback.h> #include <drain/EndPointCallback.h>
#include <drain/EndPointWrite.h> #include <drain/EndPointWrite.h>
#include <memory>
#include <ejson/ejson.h> #include <ejson/ejson.h>
#include <etk/os/FSNode.h> #include <etk/os/FSNode.h>
@ -34,7 +41,7 @@ namespace river {
modeInterface_output, modeInterface_output,
modeInterface_feedback, modeInterface_feedback,
}; };
class Interface : public std::enable_shared_from_this<Interface> { class Interface : public std11::enable_shared_from_this<Interface> {
friend class io::Node; friend class io::Node;
friend class io::NodeAirTAudio; friend class io::NodeAirTAudio;
friend class io::NodeAEC; friend class io::NodeAEC;
@ -50,23 +57,23 @@ namespace river {
float _freq, float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::shared_ptr<river::io::Node>& _node, const std11::shared_ptr<river::io::Node>& _node,
const std::shared_ptr<const ejson::Object>& _config); const std11::shared_ptr<const ejson::Object>& _config);
public: public:
/** /**
* @brief Destructor * @brief Destructor
*/ */
virtual ~Interface(); virtual ~Interface();
static std::shared_ptr<Interface> create(const std::string& _name, static std11::shared_ptr<Interface> create(const std::string& _name,
float _freq, float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::shared_ptr<river::io::Node>& _node, const std11::shared_ptr<river::io::Node>& _node,
const std::shared_ptr<const ejson::Object>& _config); const std11::shared_ptr<const ejson::Object>& _config);
protected: protected:
mutable std::recursive_mutex m_mutex; mutable std11::recursive_mutex m_mutex;
std::shared_ptr<const ejson::Object> m_config; std11::shared_ptr<const ejson::Object> m_config;
protected: protected:
enum modeInterface m_mode; enum modeInterface m_mode;
public: public:
@ -85,7 +92,7 @@ namespace river {
} }
protected: protected:
std::shared_ptr<river::io::Node> m_node; std11::shared_ptr<river::io::Node> m_node;
protected: protected:
std::string m_name; std::string m_name;
public: public:
@ -122,7 +129,7 @@ namespace river {
* @note _time to play buffer when output interface (if possible) * @note _time to play buffer when output interface (if possible)
* @note _time to read buffer when inut interface (if possible) * @note _time to read buffer when inut interface (if possible)
*/ */
virtual void start(const std::chrono::system_clock::time_point& _time = std::chrono::system_clock::time_point()); virtual void start(const std11::chrono::system_clock::time_point& _time = std11::chrono::system_clock::time_point());
/** /**
* @brief Stop the current flow. * @brief Stop the current flow.
* @param[in] _fast The stream stop as fast as possible (not write all the buffer in speaker) but apply cross fade out. * @param[in] _fast The stream stop as fast as possible (not write all the buffer in speaker) but apply cross fade out.
@ -190,7 +197,7 @@ namespace river {
* @brief Set buffer size in chunk number * @brief Set buffer size in chunk number
* @param[in] _nbChunk Number of chunk in the buffer * @param[in] _nbChunk Number of chunk in the buffer
*/ */
virtual void setBufferSize(const std::chrono::duration<int64_t, std::micro>& _time); virtual void setBufferSize(const std11::chrono::microseconds& _time);
/** /**
* @brief Remove internal Buffer * @brief Remove internal Buffer
*/ */
@ -199,10 +206,10 @@ namespace river {
* @brief Write : Get the time of the next sample time to write in the local buffer * @brief Write : Get the time of the next sample time to write in the local buffer
* @brief Read : Get the time of the next sample time to read in the local buffer * @brief Read : Get the time of the next sample time to read in the local buffer
*/ */
virtual std::chrono::system_clock::time_point getCurrentTime() const; virtual std11::chrono::system_clock::time_point getCurrentTime() const;
private: private:
virtual void systemNewInputData(std::chrono::system_clock::time_point _time, const void* _data, size_t _nbChunk); virtual void systemNewInputData(std11::chrono::system_clock::time_point _time, const void* _data, size_t _nbChunk);
virtual void systemNeedOutputData(std::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk, size_t _chunkSize); virtual void systemNeedOutputData(std11::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk, size_t _chunkSize);
virtual void systemVolumeChange(); virtual void systemVolumeChange();
float m_volume; //!< Local channel Volume float m_volume; //!< Local channel Volume
public: public:

View File

@ -6,7 +6,6 @@
#include "Manager.h" #include "Manager.h"
#include "Interface.h" #include "Interface.h"
#include <memory>
#include <stdexcept> #include <stdexcept>
#include "io/Manager.h" #include "io/Manager.h"
@ -33,8 +32,8 @@ static std::string basicAutoConfig =
"}\n"; "}\n";
std::shared_ptr<river::Manager> river::Manager::create(const std::string& _applicationUniqueId) { std11::shared_ptr<river::Manager> river::Manager::create(const std::string& _applicationUniqueId) {
return std::shared_ptr<river::Manager>(new river::Manager(_applicationUniqueId)); return std11::shared_ptr<river::Manager>(new river::Manager(_applicationUniqueId));
} }
river::Manager::Manager(const std::string& _applicationUniqueId) : river::Manager::Manager(const std::string& _applicationUniqueId) :
@ -54,13 +53,14 @@ river::Manager::~Manager() {
std::vector<std::pair<std::string,std::string> > river::Manager::getListStreamInput() { std::vector<std::pair<std::string,std::string> > river::Manager::getListStreamInput() {
std::vector<std::pair<std::string,std::string> > output; std::vector<std::pair<std::string,std::string> > output;
for (auto &it : m_config.getKeys()) { std::vector<std::string> keys = m_config.getKeys();
const std::shared_ptr<const ejson::Object> tmppp = m_config.getObject(it); for (size_t iii=0; iii<keys.size(); ++iii) {
const std11::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
if (tmppp != nullptr) { if (tmppp != nullptr) {
std::string type = tmppp->getStringValue("io", "error"); std::string type = tmppp->getStringValue("io", "error");
if ( type == "input" if ( type == "input"
|| type == "feedback") { || type == "feedback") {
output.push_back(std::make_pair<std::string,std::string>(std::string(it), std::string("---"))); output.push_back(std::make_pair<std::string,std::string>(keys[iii], std::string("---")));
} }
} }
} }
@ -69,12 +69,13 @@ std::vector<std::pair<std::string,std::string> > river::Manager::getListStreamIn
std::vector<std::pair<std::string,std::string> > river::Manager::getListStreamOutput() { std::vector<std::pair<std::string,std::string> > river::Manager::getListStreamOutput() {
std::vector<std::pair<std::string,std::string> > output; std::vector<std::pair<std::string,std::string> > output;
for (auto &it : m_config.getKeys()) { std::vector<std::string> keys = m_config.getKeys();
const std::shared_ptr<const ejson::Object> tmppp = m_config.getObject(it); for (size_t iii=0; iii<keys.size(); ++iii) {
const std11::shared_ptr<const ejson::Object> tmppp = m_config.getObject(keys[iii]);
if (tmppp != nullptr) { if (tmppp != nullptr) {
std::string type = tmppp->getStringValue("io", "error"); std::string type = tmppp->getStringValue("io", "error");
if (type == "output") { if (type == "output") {
output.push_back(std::make_pair<std::string,std::string>(std::string(it), std::string("---"))); output.push_back(std::make_pair<std::string,std::string>(keys[iii], std::string("---")));
} }
} }
} }
@ -94,60 +95,60 @@ std::pair<float,float> river::Manager::getVolumeRange(const std::string& _volume
return river::io::Manager::getInstance()->getVolumeRange(_volumeName); return river::io::Manager::getInstance()->getVolumeRange(_volumeName);
} }
std::shared_ptr<river::Interface> river::Manager::createOutput(float _freq, std11::shared_ptr<river::Interface> river::Manager::createOutput(float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::string& _streamName, const std::string& _streamName,
const std::string& _name) { const std::string& _name) {
// check if the output exist // check if the output exist
const std::shared_ptr<const ejson::Object> tmppp = m_config.getObject(_streamName); const std11::shared_ptr<const ejson::Object> tmppp = m_config.getObject(_streamName);
if (tmppp == nullptr) { if (tmppp == nullptr) {
RIVER_ERROR("can not open a non existance virtual input: '" << _streamName << "' not present in : " << m_config.getKeys()); RIVER_ERROR("can not open a non existance virtual input: '" << _streamName << "' not present in : " << m_config.getKeys());
return nullptr; return std11::shared_ptr<river::Interface>();
} }
// check if it is an Output: // check if it is an Output:
std::string type = tmppp->getStringValue("io", "error"); std::string type = tmppp->getStringValue("io", "error");
if (type != "output") { if (type != "output") {
RIVER_ERROR("can not open in output a virtual interface: '" << _streamName << "' configured has : " << type); RIVER_ERROR("can not open in output a virtual interface: '" << _streamName << "' configured has : " << type);
return nullptr; return std11::shared_ptr<river::Interface>();
} }
// get global hardware interface: // get global hardware interface:
std::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance(); std11::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance();
// get the output or input channel : // get the output or input channel :
std::shared_ptr<river::io::Node> node = manager->getNode(_streamName); std11::shared_ptr<river::io::Node> node = manager->getNode(_streamName);
// create user iterface: // create user iterface:
std::shared_ptr<river::Interface> interface; std11::shared_ptr<river::Interface> interface;
interface = river::Interface::create(_name, _freq, _map, _format, node, tmppp); interface = river::Interface::create(_name, _freq, _map, _format, node, tmppp);
// store it in a list (needed to apply some parameters). // store it in a list (needed to apply some parameters).
m_listOpenInterface.push_back(interface); m_listOpenInterface.push_back(interface);
return interface; return interface;
} }
std::shared_ptr<river::Interface> river::Manager::createInput(float _freq, std11::shared_ptr<river::Interface> river::Manager::createInput(float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::string& _streamName, const std::string& _streamName,
const std::string& _name) { const std::string& _name) {
// check if the output exist // check if the output exist
const std::shared_ptr<const ejson::Object> tmppp = m_config.getObject(_streamName); const std11::shared_ptr<const ejson::Object> tmppp = m_config.getObject(_streamName);
if (tmppp == nullptr) { if (tmppp == nullptr) {
RIVER_ERROR("can not open a non existance virtual interface: '" << _streamName << "' not present in : " << m_config.getKeys()); RIVER_ERROR("can not open a non existance virtual interface: '" << _streamName << "' not present in : " << m_config.getKeys());
return nullptr; return std11::shared_ptr<river::Interface>();
} }
// check if it is an Output: // check if it is an Output:
std::string type = tmppp->getStringValue("io", "error"); std::string type = tmppp->getStringValue("io", "error");
if ( type != "input" if ( type != "input"
&& type != "feedback") { && type != "feedback") {
RIVER_ERROR("can not open in output a virtual interface: '" << _streamName << "' configured has : " << type); RIVER_ERROR("can not open in output a virtual interface: '" << _streamName << "' configured has : " << type);
return nullptr; return std11::shared_ptr<river::Interface>();
} }
// get global hardware interface: // get global hardware interface:
std::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance(); std11::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance();
// get the output or input channel : // get the output or input channel :
std::shared_ptr<river::io::Node> node = manager->getNode(_streamName); std11::shared_ptr<river::io::Node> node = manager->getNode(_streamName);
// create user iterface: // create user iterface:
std::shared_ptr<river::Interface> interface; std11::shared_ptr<river::Interface> interface;
interface = river::Interface::create(_name, _freq, _map, _format, node, tmppp); interface = river::Interface::create(_name, _freq, _map, _format, node, tmppp);
// store it in a list (needed to apply some parameters). // store it in a list (needed to apply some parameters).
m_listOpenInterface.push_back(interface); m_listOpenInterface.push_back(interface);
@ -156,7 +157,7 @@ std::shared_ptr<river::Interface> river::Manager::createInput(float _freq,
void river::Manager::generateDotAll(const std::string& _filename) { void river::Manager::generateDotAll(const std::string& _filename) {
// get global hardware interface: // get global hardware interface:
std::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance(); std11::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance();
if (manager == nullptr) { if (manager == nullptr) {
RIVER_ERROR("Can not get the harware manager"); RIVER_ERROR("Can not get the harware manager");
return; return;

View File

@ -9,7 +9,11 @@
#include <string> #include <string>
#include <stdint.h> #include <stdint.h>
#include <memory> #if __cplusplus >= 201103L
#include <memory>
#else
#include <etk/memory.h>
#endif
#include <river/Interface.h> #include <river/Interface.h>
#include <audio/format.h> #include <audio/format.h>
#include <audio/channel.h> #include <audio/channel.h>
@ -23,14 +27,14 @@ namespace river {
private: private:
ejson::Document m_config; // virtual configuration ejson::Document m_config; // virtual configuration
const std::string& m_applicationUniqueId; //!< name of the application that open the Audio Interface. const std::string& m_applicationUniqueId; //!< name of the application that open the Audio Interface.
std::vector<std::weak_ptr<river::Interface> > m_listOpenInterface; //!< List of all open Stream. std::vector<std11::weak_ptr<river::Interface> > m_listOpenInterface; //!< List of all open Stream.
protected: protected:
/** /**
* @brief Constructor * @brief Constructor
*/ */
Manager(const std::string& _applicationUniqueId); Manager(const std::string& _applicationUniqueId);
public: public:
static std::shared_ptr<river::Manager> create(const std::string& _applicationUniqueId); static std11::shared_ptr<river::Manager> create(const std::string& _applicationUniqueId);
/** /**
* @brief Destructor * @brief Destructor
*/ */
@ -80,7 +84,7 @@ namespace river {
* @param[in] _name Name of this interface * @param[in] _name Name of this interface
* @return a pointer on the interface * @return a pointer on the interface
*/ */
virtual std::shared_ptr<Interface> createOutput(float _freq, virtual std11::shared_ptr<Interface> createOutput(float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::string& _streamName = "", const std::string& _streamName = "",
@ -94,7 +98,7 @@ namespace river {
* @param[in] _name Name of this interface * @param[in] _name Name of this interface
* @return a pointer on the interface * @return a pointer on the interface
*/ */
virtual std::shared_ptr<Interface> createInput(float _freq, virtual std11::shared_ptr<Interface> createInput(float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::string& _streamName = "", const std::string& _streamName = "",

View File

@ -5,7 +5,6 @@
*/ */
#include "Manager.h" #include "Manager.h"
#include <memory>
#include <river/debug.h> #include <river/debug.h>
#include "Node.h" #include "Node.h"
#include "NodeAEC.h" #include "NodeAEC.h"
@ -78,15 +77,15 @@ river::io::Manager::~Manager() {
}; };
std::shared_ptr<river::io::Manager> river::io::Manager::getInstance() { std11::shared_ptr<river::io::Manager> river::io::Manager::getInstance() {
static std::shared_ptr<river::io::Manager> manager(new Manager()); static std11::shared_ptr<river::io::Manager> manager(new Manager());
return manager; return manager;
} }
std::shared_ptr<river::io::Node> river::io::Manager::getNode(const std::string& _name) { std11::shared_ptr<river::io::Node> river::io::Manager::getNode(const std::string& _name) {
RIVER_WARNING("Get node : " << _name); RIVER_WARNING("Get node : " << _name);
for (auto &it : m_list) { for (size_t iii=0; iii<m_list.size(); ++iii) {
std::shared_ptr<river::io::Node> tmppp = it.lock(); std11::shared_ptr<river::io::Node> tmppp = m_list[iii].lock();
if ( tmppp != nullptr if ( tmppp != nullptr
&& _name == tmppp->getName()) { && _name == tmppp->getName()) {
RIVER_WARNING(" find it ... "); RIVER_WARNING(" find it ... ");
@ -95,14 +94,14 @@ std::shared_ptr<river::io::Node> river::io::Manager::getNode(const std::string&
} }
RIVER_WARNING("Create a new one : " << _name); RIVER_WARNING("Create a new one : " << _name);
// check if the node can be open : // check if the node can be open :
const std::shared_ptr<const ejson::Object> tmpObject = m_config.getObject(_name); const std11::shared_ptr<const ejson::Object> tmpObject = m_config.getObject(_name);
if (tmpObject != nullptr) { if (tmpObject != nullptr) {
// get type : io // get type : io
std::string ioType = tmpObject->getStringValue("io", "error"); std::string ioType = tmpObject->getStringValue("io", "error");
#ifdef __AIRTAUDIO_INFERFACE__ #ifdef __AIRTAUDIO_INFERFACE__
if ( ioType == "input" if ( ioType == "input"
|| ioType == "output") { || ioType == "output") {
std::shared_ptr<river::io::Node> tmp = river::io::NodeAirTAudio::create(_name, tmpObject); std11::shared_ptr<river::io::Node> tmp = river::io::NodeAirTAudio::create(_name, tmpObject);
m_list.push_back(tmp); m_list.push_back(tmp);
return tmp; return tmp;
} else } else
@ -110,42 +109,42 @@ std::shared_ptr<river::io::Node> river::io::Manager::getNode(const std::string&
#ifdef __PORTAUDIO_INFERFACE__ #ifdef __PORTAUDIO_INFERFACE__
if ( ioType == "PAinput" if ( ioType == "PAinput"
|| ioType == "PAoutput") { || ioType == "PAoutput") {
std::shared_ptr<river::io::Node> tmp = river::io::NodePortAudio::create(_name, tmpObject); std11::shared_ptr<river::io::Node> tmp = river::io::NodePortAudio::create(_name, tmpObject);
m_list.push_back(tmp); m_list.push_back(tmp);
return tmp; return tmp;
} else } else
#endif #endif
if (ioType == "aec") { if (ioType == "aec") {
std::shared_ptr<river::io::Node> tmp = river::io::NodeAEC::create(_name, tmpObject); std11::shared_ptr<river::io::Node> tmp = river::io::NodeAEC::create(_name, tmpObject);
m_list.push_back(tmp); m_list.push_back(tmp);
return tmp; return tmp;
} }
} }
RIVER_ERROR("Can not create the interface : '" << _name << "' the node is not DEFINED in the configuration file availlable : " << m_config.getKeys()); RIVER_ERROR("Can not create the interface : '" << _name << "' the node is not DEFINED in the configuration file availlable : " << m_config.getKeys());
return nullptr; return std11::shared_ptr<river::io::Node>();
} }
std::shared_ptr<drain::VolumeElement> river::io::Manager::getVolumeGroup(const std::string& _name) { std11::shared_ptr<drain::VolumeElement> river::io::Manager::getVolumeGroup(const std::string& _name) {
if (_name == "") { if (_name == "") {
RIVER_ERROR("Try to create an audio group with no name ..."); RIVER_ERROR("Try to create an audio group with no name ...");
return nullptr; return std11::shared_ptr<drain::VolumeElement>();
} }
for (auto &it : m_volumeGroup) { for (size_t iii=0; iii<m_volumeGroup.size(); ++iii) {
if (it == nullptr) { if (m_volumeGroup[iii] == nullptr) {
continue; continue;
} }
if (it->getName() == _name) { if (m_volumeGroup[iii]->getName() == _name) {
return it; return m_volumeGroup[iii];
} }
} }
RIVER_DEBUG("Add a new volume group : '" << _name << "'"); RIVER_DEBUG("Add a new volume group : '" << _name << "'");
std::shared_ptr<drain::VolumeElement> tmpVolume = std::make_shared<drain::VolumeElement>(_name); std11::shared_ptr<drain::VolumeElement> tmpVolume = std11::make_shared<drain::VolumeElement>(_name);
m_volumeGroup.push_back(tmpVolume); m_volumeGroup.push_back(tmpVolume);
return tmpVolume; return tmpVolume;
} }
bool river::io::Manager::setVolume(const std::string& _volumeName, float _valuedB) { bool river::io::Manager::setVolume(const std::string& _volumeName, float _valuedB) {
std::shared_ptr<drain::VolumeElement> volume = getVolumeGroup(_volumeName); std11::shared_ptr<drain::VolumeElement> volume = getVolumeGroup(_volumeName);
if (volume == nullptr) { if (volume == nullptr) {
RIVER_ERROR("Can not set volume ... : '" << _volumeName << "'"); RIVER_ERROR("Can not set volume ... : '" << _volumeName << "'");
return false; return false;
@ -156,8 +155,8 @@ bool river::io::Manager::setVolume(const std::string& _volumeName, float _valued
return false; return false;
} }
volume->setVolume(_valuedB); volume->setVolume(_valuedB);
for (auto &it2 : m_list) { for (size_t iii=0; iii<m_list.size(); ++iii) {
std::shared_ptr<river::io::Node> val = it2.lock(); std11::shared_ptr<river::io::Node> val = m_list[iii].lock();
if (val != nullptr) { if (val != nullptr) {
val->volumeChange(); val->volumeChange();
} }
@ -166,7 +165,7 @@ bool river::io::Manager::setVolume(const std::string& _volumeName, float _valued
} }
float river::io::Manager::getVolume(const std::string& _volumeName) { float river::io::Manager::getVolume(const std::string& _volumeName) {
std::shared_ptr<drain::VolumeElement> volume = getVolumeGroup(_volumeName); std11::shared_ptr<drain::VolumeElement> volume = getVolumeGroup(_volumeName);
if (volume == nullptr) { if (volume == nullptr) {
RIVER_ERROR("Can not get volume ... : '" << _volumeName << "'"); RIVER_ERROR("Can not get volume ... : '" << _volumeName << "'");
return 0.0f; return 0.0f;
@ -187,12 +186,10 @@ void river::io::Manager::generateDot(const std::string& _filename) {
} }
node << "digraph G {" << "\n"; node << "digraph G {" << "\n";
node << " rankdir=\"LR\";\n"; node << " rankdir=\"LR\";\n";
int32_t id = 0; for (size_t iii=0; iii<m_list.size(); ++iii) {
for (auto &it2 : m_list) { std11::shared_ptr<river::io::Node> val = m_list[iii].lock();
std::shared_ptr<river::io::Node> val = it2.lock();
if (val != nullptr) { if (val != nullptr) {
val->generateDot(node); val->generateDot(node);
id++;
} }
} }
node << "}" << "\n"; node << "}" << "\n";

View File

@ -11,12 +11,18 @@
#include <vector> #include <vector>
#include <list> #include <list>
#include <stdint.h> #include <stdint.h>
#include <chrono> #if __cplusplus >= 201103L
#include <functional> #include <chrono>
#include <functional>
#include <memory>
#else
#include <etk/chrono.h>
#include <etk/functional.h>
#include <etk/memory.h>
#endif
#include <audio/format.h> #include <audio/format.h>
#include <audio/channel.h> #include <audio/channel.h>
#include <ejson/ejson.h> #include <ejson/ejson.h>
#include <memory>
#include <drain/Volume.h> #include <drain/Volume.h>
namespace river { namespace river {
@ -29,21 +35,21 @@ namespace river {
*/ */
Manager(); Manager();
public: public:
static std::shared_ptr<Manager> getInstance(); static std11::shared_ptr<Manager> getInstance();
/** /**
* @brief Destructor * @brief Destructor
*/ */
virtual ~Manager(); virtual ~Manager();
private: private:
ejson::Document m_config; // harware configuration ejson::Document m_config; // harware configuration
std::vector<std::shared_ptr<river::io::Node> > m_listKeepAlive; //!< list of all Node that might be keep alive sone time std::vector<std11::shared_ptr<river::io::Node> > m_listKeepAlive; //!< list of all Node that might be keep alive sone time
std::vector<std::weak_ptr<river::io::Node> > m_list; //!< List of all IO node std::vector<std11::weak_ptr<river::io::Node> > m_list; //!< List of all IO node
public: public:
std::shared_ptr<river::io::Node> getNode(const std::string& _name); std11::shared_ptr<river::io::Node> getNode(const std::string& _name);
private: private:
std::vector<std::shared_ptr<drain::VolumeElement>> m_volumeGroup; std::vector<std11::shared_ptr<drain::VolumeElement> > m_volumeGroup;
public: public:
std::shared_ptr<drain::VolumeElement> getVolumeGroup(const std::string& _name); std11::shared_ptr<drain::VolumeElement> getVolumeGroup(const std::string& _name);
/** /**
* @brief Set a volume for a specific group * @brief Set a volume for a specific group

View File

@ -7,13 +7,11 @@
#include "Node.h" #include "Node.h"
#include <river/debug.h> #include <river/debug.h>
#include <memory>
#undef __class__ #undef __class__
#define __class__ "io::Node" #define __class__ "io::Node"
river::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) : river::io::Node::Node(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) :
m_config(_config), m_config(_config),
m_name(_name), m_name(_name),
m_isInput(false) { m_isInput(false) {
@ -58,7 +56,7 @@ river::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejso
} }
// Get map type : // Get map type :
std::vector<audio::channel> map; std::vector<audio::channel> map;
const std::shared_ptr<const ejson::Array> listChannelMap = m_config->getArray("channel-map"); const std11::shared_ptr<const ejson::Array> listChannelMap = m_config->getArray("channel-map");
if ( listChannelMap == nullptr if ( listChannelMap == nullptr
|| listChannelMap->size() == 0) { || listChannelMap->size() == 0) {
// set default channel property: // set default channel property:
@ -105,19 +103,19 @@ river::io::Node::~Node() {
size_t river::io::Node::getNumberOfInterface(enum river::modeInterface _interfaceType) { size_t river::io::Node::getNumberOfInterface(enum river::modeInterface _interfaceType) {
size_t out = 0; size_t out = 0;
for (auto &it : m_list) { for (size_t iii=0; iii<m_list.size(); ++iii) {
if (it == nullptr) { if (m_list[iii] == nullptr) {
continue; continue;
} }
if (it->getMode() == _interfaceType) { if (m_list[iii]->getMode() == _interfaceType) {
out++; out++;
} }
} }
return out; return out;
} }
void river::io::Node::registerAsRemote(const std::shared_ptr<river::Interface>& _interface) { void river::io::Node::registerAsRemote(const std11::shared_ptr<river::Interface>& _interface) {
auto it = m_listAvaillable.begin(); std::vector<std11::weak_ptr<river::Interface> >::iterator it = m_listAvaillable.begin();
while (it != m_listAvaillable.end()) { while (it != m_listAvaillable.end()) {
if (it->expired() == true) { if (it->expired() == true) {
it = m_listAvaillable.erase(it); it = m_listAvaillable.erase(it);
@ -127,11 +125,11 @@ void river::io::Node::registerAsRemote(const std::shared_ptr<river::Interface>&
m_listAvaillable.push_back(_interface); m_listAvaillable.push_back(_interface);
} }
void river::io::Node::interfaceAdd(const std::shared_ptr<river::Interface>& _interface) { void river::io::Node::interfaceAdd(const std11::shared_ptr<river::Interface>& _interface) {
{ {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
for (auto &it : m_list) { for (size_t iii=0; iii<m_list.size(); ++iii) {
if (_interface == it) { if (_interface == m_list[iii]) {
return; return;
} }
} }
@ -143,9 +141,9 @@ void river::io::Node::interfaceAdd(const std::shared_ptr<river::Interface>& _int
} }
} }
void river::io::Node::interfaceRemove(const std::shared_ptr<river::Interface>& _interface) { void river::io::Node::interfaceRemove(const std11::shared_ptr<river::Interface>& _interface) {
{ {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
for (size_t iii=0; iii< m_list.size(); ++iii) { for (size_t iii=0; iii< m_list.size(); ++iii) {
if (_interface == m_list[iii]) { if (_interface == m_list[iii]) {
m_list.erase(m_list.begin()+iii); m_list.erase(m_list.begin()+iii);
@ -162,8 +160,8 @@ void river::io::Node::interfaceRemove(const std::shared_ptr<river::Interface>& _
void river::io::Node::volumeChange() { void river::io::Node::volumeChange() {
for (auto &it : m_listAvaillable) { for (size_t iii=0; iii< m_listAvaillable.size(); ++iii) {
std::shared_ptr<river::Interface> node = it.lock(); std11::shared_ptr<river::Interface> node = m_listAvaillable[iii].lock();
if (node != nullptr) { if (node != nullptr) {
node->systemVolumeChange(); node->systemVolumeChange();
} }
@ -172,20 +170,20 @@ void river::io::Node::volumeChange() {
int32_t river::io::Node::newInput(const void* _inputBuffer, int32_t river::io::Node::newInput(const void* _inputBuffer,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::chrono::system_clock::time_point& _time) { const std11::chrono::system_clock::time_point& _time) {
if (_inputBuffer == nullptr) { if (_inputBuffer == nullptr) {
return -1; return -1;
} }
const int16_t* inputBuffer = static_cast<const int16_t *>(_inputBuffer); const int16_t* inputBuffer = static_cast<const int16_t *>(_inputBuffer);
for (auto &it : m_list) { for (size_t iii=0; iii< m_list.size(); ++iii) {
if (it == nullptr) { if (m_list[iii] == nullptr) {
continue; continue;
} }
if (it->getMode() != river::modeInterface_input) { if (m_list[iii]->getMode() != river::modeInterface_input) {
continue; continue;
} }
RIVER_VERBOSE(" IO name="<< it->getName()); RIVER_VERBOSE(" IO name="<< m_list[iii]->getName());
it->systemNewInputData(_time, inputBuffer, _nbChunk); m_list[iii]->systemNewInputData(_time, inputBuffer, _nbChunk);
} }
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [ END ]"); RIVER_VERBOSE("data Input size request :" << _nbChunk << " [ END ]");
return 0; return 0;
@ -193,7 +191,7 @@ int32_t river::io::Node::newInput(const void* _inputBuffer,
int32_t river::io::Node::newOutput(void* _outputBuffer, int32_t river::io::Node::newOutput(void* _outputBuffer,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::chrono::system_clock::time_point& _time) { const std11::chrono::system_clock::time_point& _time) {
if (_outputBuffer == nullptr) { if (_outputBuffer == nullptr) {
return -1; return -1;
} }
@ -204,18 +202,18 @@ int32_t river::io::Node::newOutput(void* _outputBuffer,
std::vector<uint8_t> outputTmp2; std::vector<uint8_t> outputTmp2;
RIVER_VERBOSE("resize=" << sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk); RIVER_VERBOSE("resize=" << sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk);
outputTmp2.resize(sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk, 0); outputTmp2.resize(sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk, 0);
for (auto &it : m_list) { for (size_t iii=0; iii< m_list.size(); ++iii) {
if (it == nullptr) { if (m_list[iii] == nullptr) {
continue; continue;
} }
if (it->getMode() != river::modeInterface_output) { if (m_list[iii]->getMode() != river::modeInterface_output) {
continue; continue;
} }
RIVER_VERBOSE(" IO name="<< it->getName()); RIVER_VERBOSE(" IO name="<< m_list[iii]->getName());
// clear datas ... // clear datas ...
memset(&outputTmp2[0], 0, sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk); memset(&outputTmp2[0], 0, sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nbChunk);
RIVER_VERBOSE(" request Data="<< _nbChunk); RIVER_VERBOSE(" request Data="<< _nbChunk);
it->systemNeedOutputData(_time, &outputTmp2[0], _nbChunk, sizeof(int32_t)*m_process.getInputConfig().getMap().size()); m_list[iii]->systemNeedOutputData(_time, &outputTmp2[0], _nbChunk, sizeof(int32_t)*m_process.getInputConfig().getMap().size());
RIVER_VERBOSE(" Mix it ..."); RIVER_VERBOSE(" Mix it ...");
outputTmp = reinterpret_cast<const int32_t*>(&outputTmp2[0]); outputTmp = reinterpret_cast<const int32_t*>(&outputTmp2[0]);
// Add data to the output tmp buffer : // Add data to the output tmp buffer :
@ -226,15 +224,15 @@ int32_t river::io::Node::newOutput(void* _outputBuffer,
RIVER_VERBOSE(" End stack process data ..."); RIVER_VERBOSE(" End stack process data ...");
m_process.processIn(&outputTmp2[0], _nbChunk, _outputBuffer, _nbChunk); m_process.processIn(&outputTmp2[0], _nbChunk, _outputBuffer, _nbChunk);
RIVER_VERBOSE(" Feedback :"); RIVER_VERBOSE(" Feedback :");
for (auto &it : m_list) { for (size_t iii=0; iii< m_list.size(); ++iii) {
if (it == nullptr) { if (m_list[iii] == nullptr) {
continue; continue;
} }
if (it->getMode() != river::modeInterface_feedback) { if (m_list[iii]->getMode() != river::modeInterface_feedback) {
continue; continue;
} }
RIVER_VERBOSE(" IO name="<< it->getName() << " (feedback)"); RIVER_VERBOSE(" IO name="<< m_list[iii]->getName() << " (feedback)");
it->systemNewInputData(_time, _outputBuffer, _nbChunk); m_list[iii]->systemNewInputData(_time, _outputBuffer, _nbChunk);
} }
RIVER_VERBOSE("data Output size request :" << _nbChunk << " [ END ]"); RIVER_VERBOSE("data Output size request :" << _nbChunk << " [ END ]");
return 0; return 0;
@ -307,14 +305,14 @@ void river::io::Node::generateDot(etk::FSNode& _node) {
} }
_node << "}\n"; _node << "}\n";
for (auto &it : m_list) { for (size_t iii=0; iii< m_list.size(); ++iii) {
if (it != nullptr) { if (m_list[iii] != nullptr) {
if (it->getMode() == modeInterface_input) { if (m_list[iii]->getMode() == modeInterface_input) {
it->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_demuxer"); m_list[iii]->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_demuxer");
} else if (it->getMode() == modeInterface_output) { } else if (m_list[iii]->getMode() == modeInterface_output) {
it->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_muxer"); m_list[iii]->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_muxer");
} else if (it->getMode() == modeInterface_feedback) { } else if (m_list[iii]->getMode() == modeInterface_feedback) {
it->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_demuxer"); m_list[iii]->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_demuxer");
} else { } else {
} }

View File

@ -11,12 +11,19 @@
#include <vector> #include <vector>
#include <list> #include <list>
#include <stdint.h> #include <stdint.h>
#include <chrono>
#include <functional> #if __cplusplus >= 201103L
#include <chrono>
#include <functional>
#include <memory>
#else
#include <etk/chrono.h>
#include <etk/functional.h>
#include <etk/memory.h>
#endif
#include <audio/format.h> #include <audio/format.h>
#include <audio/channel.h> #include <audio/channel.h>
#include "Manager.h" #include "Manager.h"
#include <memory>
#include <river/Interface.h> #include <river/Interface.h>
#include <airtaudio/Interface.h> #include <airtaudio/Interface.h>
#include <drain/IOFormatInterface.h> #include <drain/IOFormatInterface.h>
@ -26,14 +33,14 @@
namespace river { namespace river {
namespace io { namespace io {
class Manager; class Manager;
class Node : public std::enable_shared_from_this<Node> { class Node : public std11::enable_shared_from_this<Node> {
protected: protected:
uint32_t m_uid; // uniqueNodeID uint32_t m_uid; // uniqueNodeID
protected: protected:
/** /**
* @brief Constructor * @brief Constructor
*/ */
Node(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config); Node(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
public: public:
/** /**
* @brief Destructor * @brief Destructor
@ -41,8 +48,8 @@ namespace river {
virtual ~Node(); virtual ~Node();
protected: protected:
mutable std::mutex m_mutex; mutable std11::mutex m_mutex;
std::shared_ptr<const ejson::Object> m_config; std11::shared_ptr<const ejson::Object> m_config;
protected: protected:
drain::Process m_process; drain::Process m_process;
public: public:
@ -62,16 +69,16 @@ namespace river {
} }
protected: protected:
std::shared_ptr<drain::VolumeElement> m_volume; //!< if a volume is set it is set here ... std11::shared_ptr<drain::VolumeElement> m_volume; //!< if a volume is set it is set here ...
protected: protected:
std::vector<std::weak_ptr<river::Interface> > m_listAvaillable; //!< List of all interface that exist on this Node std::vector<std11::weak_ptr<river::Interface> > m_listAvaillable; //!< List of all interface that exist on this Node
std::vector<std::shared_ptr<river::Interface> > m_list; std::vector<std11::shared_ptr<river::Interface> > m_list;
size_t getNumberOfInterface(enum river::modeInterface _interfaceType); size_t getNumberOfInterface(enum river::modeInterface _interfaceType);
public: public:
void registerAsRemote(const std::shared_ptr<river::Interface>& _interface); void registerAsRemote(const std11::shared_ptr<river::Interface>& _interface);
void interfaceAdd(const std::shared_ptr<river::Interface>& _interface); void interfaceAdd(const std11::shared_ptr<river::Interface>& _interface);
void interfaceRemove(const std::shared_ptr<river::Interface>& _interface); void interfaceRemove(const std11::shared_ptr<river::Interface>& _interface);
protected: protected:
std::string m_name; //!< Harware.json configuration name std::string m_name; //!< Harware.json configuration name
public: public:
@ -91,7 +98,7 @@ namespace river {
virtual void start() = 0; virtual void start() = 0;
virtual void stop() = 0; virtual void stop() = 0;
public: public:
const std::shared_ptr<drain::VolumeElement>& getVolume() { const std11::shared_ptr<drain::VolumeElement>& getVolume() {
return m_volume; return m_volume;
} }
public: public:
@ -99,10 +106,10 @@ namespace river {
protected: protected:
int32_t newInput(const void* _inputBuffer, int32_t newInput(const void* _inputBuffer,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::chrono::system_clock::time_point& _time); const std11::chrono::system_clock::time_point& _time);
int32_t newOutput(void* _outputBuffer, int32_t newOutput(void* _outputBuffer,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::chrono::system_clock::time_point& _time); const std11::chrono::system_clock::time_point& _time);
public: public:
virtual void generateDot(etk::FSNode& _node); virtual void generateDot(etk::FSNode& _node);

View File

@ -6,8 +6,15 @@
#include <river/io/NodeAEC.h> #include <river/io/NodeAEC.h>
#include <river/debug.h> #include <river/debug.h>
#include <etk/types.h>
#include <memory> #if __cplusplus >= 201103L
#include <memory>
#include <functional>
#else
#include <etk/memory.h>
#include <etk/functional.h>
#endif
#undef __class__ #undef __class__
#define __class__ "io::NodeAEC" #define __class__ "io::NodeAEC"
@ -16,9 +23,9 @@
int32_t river::io::NodeAEC::airtAudioCallback(void* _outputBuffer, int32_t river::io::NodeAEC::airtAudioCallback(void* _outputBuffer,
void* _inputBuffer, void* _inputBuffer,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::chrono::system_clock::time_point& _time, const std11::chrono::system_clock::time_point& _time,
airtaudio::status _status) { airtaudio::status _status) {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
//RIVER_INFO("Time=" << _time); //RIVER_INFO("Time=" << _time);
/* /*
for (int32_t iii=0; iii<400; ++iii) { for (int32_t iii=0; iii<400; ++iii) {
@ -87,20 +94,20 @@ int32_t river::io::NodeAEC::airtAudioCallback(void* _outputBuffer,
} }
#endif #endif
std::shared_ptr<river::io::NodeAEC> river::io::NodeAEC::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) { std11::shared_ptr<river::io::NodeAEC> river::io::NodeAEC::create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) {
return std::shared_ptr<river::io::NodeAEC>(new river::io::NodeAEC(_name, _config)); return std11::shared_ptr<river::io::NodeAEC>(new river::io::NodeAEC(_name, _config));
} }
std::shared_ptr<river::Interface> river::io::NodeAEC::createInput(float _freq, std11::shared_ptr<river::Interface> river::io::NodeAEC::createInput(float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::string& _objectName, const std::string& _objectName,
const std::string& _name) { const std::string& _name) {
// check if the output exist // check if the output exist
const std::shared_ptr<const ejson::Object> tmppp = m_config->getObject(_objectName); const std11::shared_ptr<const ejson::Object> tmppp = m_config->getObject(_objectName);
if (tmppp == nullptr) { if (tmppp == nullptr) {
RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config->getKeys()); RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config->getKeys());
return nullptr; return std11::shared_ptr<river::Interface>();
} }
std::string streamName = tmppp->getStringValue("map-on", "error"); std::string streamName = tmppp->getStringValue("map-on", "error");
@ -110,24 +117,24 @@ std::shared_ptr<river::Interface> river::io::NodeAEC::createInput(float _freq,
if ( type != "input" if ( type != "input"
&& type != "feedback") { && type != "feedback") {
RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type); RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type);
return nullptr; return std11::shared_ptr<river::Interface>();
} }
// get global hardware interface: // get global hardware interface:
std::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance(); std11::shared_ptr<river::io::Manager> manager = river::io::Manager::getInstance();
// get the output or input channel : // get the output or input channel :
std::shared_ptr<river::io::Node> node = manager->getNode(streamName); std11::shared_ptr<river::io::Node> node = manager->getNode(streamName);
// create user iterface: // create user iterface:
std::shared_ptr<river::Interface> interface; std11::shared_ptr<river::Interface> interface;
interface = river::Interface::create(_name, _freq, _map, _format, node, tmppp); interface = river::Interface::create(_name, _freq, _map, _format, node, tmppp);
return interface; return interface;
} }
river::io::NodeAEC::NodeAEC(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) : river::io::NodeAEC::NodeAEC(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) :
Node(_name, _config) { Node(_name, _config) {
drain::IOFormatInterface interfaceFormat = getInterfaceFormat(); drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
drain::IOFormatInterface hardwareFormat = getHarwareFormat(); drain::IOFormatInterface hardwareFormat = getHarwareFormat();
m_sampleTime = std::chrono::nanoseconds(1000000000/int64_t(hardwareFormat.getFrequency())); m_sampleTime = std11::chrono::nanoseconds(1000000000/int64_t(hardwareFormat.getFrequency()));
/** /**
# connect in input mode # connect in input mode
map-on-microphone:{ map-on-microphone:{
@ -172,28 +179,36 @@ river::io::NodeAEC::NodeAEC(const std::string& _name, const std::shared_ptr<cons
} }
// set callback mode ... // set callback mode ...
m_interfaceFeedBack->setInputCallback(std::bind(&river::io::NodeAEC::onDataReceivedFeedBack, m_interfaceFeedBack->setInputCallback(std11::bind(&river::io::NodeAEC::onDataReceivedFeedBack,
this, this,
std::placeholders::_1, #if __cplusplus >= 201103L
std::placeholders::_2, std11::placeholders::_1,
std::placeholders::_3, std11::placeholders::_2,
std::placeholders::_4, std11::placeholders::_3,
std::placeholders::_5, std11::placeholders::_4,
std::placeholders::_6)); std11::placeholders::_5,
std11::placeholders::_6));
#else
_1, _2, _3, _4, _5, _6));
#endif
// set callback mode ... // set callback mode ...
m_interfaceMicrophone->setInputCallback(std::bind(&river::io::NodeAEC::onDataReceivedMicrophone, m_interfaceMicrophone->setInputCallback(std11::bind(&river::io::NodeAEC::onDataReceivedMicrophone,
this, this,
std::placeholders::_1, #if __cplusplus >= 201103L
std::placeholders::_2, std11::placeholders::_1,
std::placeholders::_3, std11::placeholders::_2,
std::placeholders::_4, std11::placeholders::_3,
std::placeholders::_5, std11::placeholders::_4,
std::placeholders::_6)); std11::placeholders::_5,
std11::placeholders::_6));
#else
_1, _2, _3, _4, _5, _6));
#endif
m_bufferMicrophone.setCapacity(std::chrono::milliseconds(1000), m_bufferMicrophone.setCapacity(std11::chrono::milliseconds(1000),
audio::getFormatBytes(hardwareFormat.getFormat())*hardwareFormat.getMap().size(), audio::getFormatBytes(hardwareFormat.getFormat())*hardwareFormat.getMap().size(),
hardwareFormat.getFrequency()); hardwareFormat.getFrequency());
m_bufferFeedBack.setCapacity(std::chrono::milliseconds(1000), m_bufferFeedBack.setCapacity(std11::chrono::milliseconds(1000),
audio::getFormatBytes(hardwareFormat.getFormat()), // only one channel ... audio::getFormatBytes(hardwareFormat.getFormat()), // only one channel ...
hardwareFormat.getFrequency()); hardwareFormat.getFrequency());
@ -208,7 +223,7 @@ river::io::NodeAEC::~NodeAEC() {
}; };
void river::io::NodeAEC::start() { void river::io::NodeAEC::start() {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") ); RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
if (m_interfaceFeedBack != nullptr) { if (m_interfaceFeedBack != nullptr) {
RIVER_INFO("Start FEEDBACK : "); RIVER_INFO("Start FEEDBACK : ");
@ -221,7 +236,7 @@ void river::io::NodeAEC::start() {
} }
void river::io::NodeAEC::stop() { void river::io::NodeAEC::stop() {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
if (m_interfaceFeedBack != nullptr) { if (m_interfaceFeedBack != nullptr) {
m_interfaceFeedBack->stop(); m_interfaceFeedBack->stop();
} }
@ -231,8 +246,8 @@ void river::io::NodeAEC::stop() {
} }
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;
@ -269,7 +284,7 @@ namespace std {
void river::io::NodeAEC::onDataReceivedMicrophone(const void* _data, void river::io::NodeAEC::onDataReceivedMicrophone(const void* _data,
const std::chrono::system_clock::time_point& _time, 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,
@ -279,14 +294,14 @@ void river::io::NodeAEC::onDataReceivedMicrophone(const void* _data,
RIVER_ERROR("call wrong type ... (need int16_t)"); RIVER_ERROR("call wrong type ... (need int16_t)");
} }
// push data synchronize // push data synchronize
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
m_bufferMicrophone.write(_data, _nbChunk, _time); m_bufferMicrophone.write(_data, _nbChunk, _time);
SAVE_FILE_MACRO(int16_t, "REC_Microphone.raw", _data, _nbChunk*_map.size()); SAVE_FILE_MACRO(int16_t, "REC_Microphone.raw", _data, _nbChunk*_map.size());
process(); process();
} }
void river::io::NodeAEC::onDataReceivedFeedBack(const void* _data, void river::io::NodeAEC::onDataReceivedFeedBack(const void* _data,
const std::chrono::system_clock::time_point& _time, 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,
@ -296,7 +311,7 @@ void river::io::NodeAEC::onDataReceivedFeedBack(const void* _data,
RIVER_ERROR("call wrong type ... (need int16_t)"); RIVER_ERROR("call wrong type ... (need int16_t)");
} }
// push data synchronize // push data synchronize
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
m_bufferFeedBack.write(_data, _nbChunk, _time); m_bufferFeedBack.write(_data, _nbChunk, _time);
SAVE_FILE_MACRO(int16_t, "REC_FeedBack.raw", _data, _nbChunk*_map.size()); SAVE_FILE_MACRO(int16_t, "REC_FeedBack.raw", _data, _nbChunk*_map.size());
process(); process();
@ -309,9 +324,9 @@ void river::io::NodeAEC::process() {
if (m_bufferFeedBack.getSize() <= 256) { if (m_bufferFeedBack.getSize() <= 256) {
return; return;
} }
std::chrono::system_clock::time_point MicTime = m_bufferMicrophone.getReadTimeStamp(); std11::chrono::system_clock::time_point MicTime = m_bufferMicrophone.getReadTimeStamp();
std::chrono::system_clock::time_point fbTime = m_bufferFeedBack.getReadTimeStamp(); std11::chrono::system_clock::time_point fbTime = m_bufferFeedBack.getReadTimeStamp();
std::chrono::nanoseconds delta; std11::chrono::nanoseconds delta;
if (MicTime < fbTime) { if (MicTime < fbTime) {
delta = fbTime - MicTime; delta = fbTime - MicTime;
} else { } else {
@ -373,7 +388,7 @@ void river::io::NodeAEC::process() {
} }
void river::io::NodeAEC::processAEC(void* _dataMic, void* _dataFB, uint32_t _nbChunk, const std::chrono::system_clock::time_point& _time) { void river::io::NodeAEC::processAEC(void* _dataMic, void* _dataFB, uint32_t _nbChunk, const std11::chrono::system_clock::time_point& _time) {
newInput(_dataMic, _nbChunk, _time); newInput(_dataMic, _nbChunk, _time);
} }
@ -407,14 +422,14 @@ void river::io::NodeAEC::generateDot(etk::FSNode& _node) {
_node << " API_" << m_interfaceFeedBack->m_uid << "_feedback -> NODE_" << m_uid << "_HW_AEC;\n"; _node << " API_" << m_interfaceFeedBack->m_uid << "_feedback -> NODE_" << m_uid << "_HW_AEC;\n";
} }
for (auto &it : m_list) { for (size_t iii=0; iii<m_list.size(); ++iii) {
if (it != nullptr) { if (m_list[iii] != nullptr) {
if (it->getMode() == modeInterface_input) { if (m_list[iii]->getMode() == modeInterface_input) {
it->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_demuxer"); m_list[iii]->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_demuxer");
} else if (it->getMode() == modeInterface_output) { } else if (m_list[iii]->getMode() == modeInterface_output) {
it->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_muxer"); m_list[iii]->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_muxer");
} else if (it->getMode() == modeInterface_feedback) { } else if (m_list[iii]->getMode() == modeInterface_feedback) {
it->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_demuxer"); m_list[iii]->generateDot(_node, "NODE_" + etk::to_string(m_uid) + "_demuxer");
} else { } else {
} }

View File

@ -19,9 +19,9 @@ namespace river {
/** /**
* @brief Constructor * @brief Constructor
*/ */
NodeAEC(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config); NodeAEC(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
public: public:
static std::shared_ptr<NodeAEC> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config); static std11::shared_ptr<NodeAEC> create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
/** /**
* @brief Destructor * @brief Destructor
*/ */
@ -29,30 +29,30 @@ namespace river {
protected: protected:
virtual void start(); virtual void start();
virtual void stop(); virtual void stop();
std::shared_ptr<river::Interface> m_interfaceMicrophone; std11::shared_ptr<river::Interface> m_interfaceMicrophone;
std::shared_ptr<river::Interface> m_interfaceFeedBack; std11::shared_ptr<river::Interface> m_interfaceFeedBack;
std::shared_ptr<river::Interface> createInput(float _freq, std11::shared_ptr<river::Interface> createInput(float _freq,
const std::vector<audio::channel>& _map, const std::vector<audio::channel>& _map,
audio::format _format, audio::format _format,
const std::string& _streamName, const std::string& _streamName,
const std::string& _name); const std::string& _name);
void onDataReceivedMicrophone(const void* _data, void onDataReceivedMicrophone(const void* _data,
const std::chrono::system_clock::time_point& _time, 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); const std::vector<audio::channel>& _map);
void onDataReceivedFeedBack(const void* _data, void onDataReceivedFeedBack(const void* _data,
const std::chrono::system_clock::time_point& _time, 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); const std::vector<audio::channel>& _map);
river::CircularBuffer m_bufferMicrophone; river::CircularBuffer m_bufferMicrophone;
river::CircularBuffer m_bufferFeedBack; river::CircularBuffer m_bufferFeedBack;
std::chrono::nanoseconds m_sampleTime; //!< represent the sample time at the specify frequency. std11::chrono::nanoseconds m_sampleTime; //!< represent the sample time at the specify frequency.
void process(); void process();
void processAEC(void* _dataMic, void* _dataFB, uint32_t _nbChunk, const std::chrono::system_clock::time_point& _time); void processAEC(void* _dataMic, void* _dataFB, uint32_t _nbChunk, const std11::chrono::system_clock::time_point& _time);
public: public:
virtual void generateDot(etk::FSNode& _node); virtual void generateDot(etk::FSNode& _node);
}; };

View File

@ -9,14 +9,18 @@
#include <river/io/NodeAirTAudio.h> #include <river/io/NodeAirTAudio.h>
#include <river/debug.h> #include <river/debug.h>
#include <memory> #if __cplusplus >= 201103L
#include <memory>
#else
#include <etk/memory.h>
#endif
#undef __class__ #undef __class__
#define __class__ "io::NodeAirTAudio" #define __class__ "io::NodeAirTAudio"
static std::string asString(const std::chrono::system_clock::time_point& tp) { static std::string asString(const std11::chrono::system_clock::time_point& tp) {
// convert to system time: // convert to system time:
std::time_t t = std::chrono::system_clock::to_time_t(tp); std::time_t t = std11::chrono::system_clock::to_time_t(tp);
// convert in human string // convert in human string
std::string ts = std::ctime(&t); std::string ts = std::ctime(&t);
// remove \n // remove \n
@ -25,8 +29,8 @@ static std::string asString(const std::chrono::system_clock::time_point& tp) {
} }
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::microseconds us = std::chrono::duration_cast<std::chrono::microseconds>(_obj.time_since_epoch()); std11::chrono::microseconds us = std11::chrono::duration_cast<std11::chrono::microseconds>(_obj.time_since_epoch());
_os << us.count(); _os << us.count();
return _os; return _os;
} }
@ -34,12 +38,12 @@ namespace std {
int32_t river::io::NodeAirTAudio::duplexCallback(const void* _inputBuffer, int32_t river::io::NodeAirTAudio::duplexCallback(const void* _inputBuffer,
const std::chrono::system_clock::time_point& _timeInput, const std11::chrono::system_clock::time_point& _timeInput,
void* _outputBuffer, void* _outputBuffer,
const std::chrono::system_clock::time_point& _timeOutput, const std11::chrono::system_clock::time_point& _timeOutput,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::vector<airtaudio::status>& _status) { const std::vector<airtaudio::status>& _status) {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
// TODO : Manage status ... // TODO : Manage status ...
if (_inputBuffer != nullptr) { if (_inputBuffer != nullptr) {
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size()); RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
@ -53,10 +57,10 @@ int32_t river::io::NodeAirTAudio::duplexCallback(const void* _inputBuffer,
} }
int32_t river::io::NodeAirTAudio::recordCallback(const void* _inputBuffer, int32_t river::io::NodeAirTAudio::recordCallback(const void* _inputBuffer,
const std::chrono::system_clock::time_point& _timeInput, const std11::chrono::system_clock::time_point& _timeInput,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::vector<airtaudio::status>& _status) { const std::vector<airtaudio::status>& _status) {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
// TODO : Manage status ... // TODO : Manage status ...
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size()); RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
newInput(_inputBuffer, _nbChunk, _timeInput); newInput(_inputBuffer, _nbChunk, _timeInput);
@ -64,10 +68,10 @@ int32_t river::io::NodeAirTAudio::recordCallback(const void* _inputBuffer,
} }
int32_t river::io::NodeAirTAudio::playbackCallback(void* _outputBuffer, int32_t river::io::NodeAirTAudio::playbackCallback(void* _outputBuffer,
const std::chrono::system_clock::time_point& _timeOutput, const std11::chrono::system_clock::time_point& _timeOutput,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::vector<airtaudio::status>& _status) { const std::vector<airtaudio::status>& _status) {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
// TODO : Manage status ... // TODO : Manage status ...
RIVER_VERBOSE("data Output size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size()); RIVER_VERBOSE("data Output size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
newOutput(_outputBuffer, _nbChunk, _timeOutput); newOutput(_outputBuffer, _nbChunk, _timeOutput);
@ -76,11 +80,11 @@ int32_t river::io::NodeAirTAudio::playbackCallback(void* _outputBuffer,
std::shared_ptr<river::io::NodeAirTAudio> river::io::NodeAirTAudio::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) { std11::shared_ptr<river::io::NodeAirTAudio> river::io::NodeAirTAudio::create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) {
return std::shared_ptr<river::io::NodeAirTAudio>(new river::io::NodeAirTAudio(_name, _config)); return std11::shared_ptr<river::io::NodeAirTAudio>(new river::io::NodeAirTAudio(_name, _config));
} }
river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) : river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) :
Node(_name, _config) { Node(_name, _config) {
drain::IOFormatInterface interfaceFormat = getInterfaceFormat(); drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
drain::IOFormatInterface hardwareFormat = getHarwareFormat(); drain::IOFormatInterface hardwareFormat = getHarwareFormat();
@ -93,7 +97,7 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std::sha
*/ */
enum airtaudio::type typeInterface = airtaudio::type_undefined; enum airtaudio::type typeInterface = airtaudio::type_undefined;
std::string streamName = "default"; std::string streamName = "default";
const std::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on"); const std11::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on");
if (tmpObject == nullptr) { if (tmpObject == nullptr) {
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'"); RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
} else { } else {
@ -214,22 +218,30 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std::sha
if (m_isInput == true) { if (m_isInput == true) {
err = m_adac.openStream(nullptr, &params, err = m_adac.openStream(nullptr, &params,
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize, hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
std::bind(&river::io::NodeAirTAudio::recordCallback, std11::bind(&river::io::NodeAirTAudio::recordCallback,
this, this,
#if __cplusplus >= 201103L
std::placeholders::_1, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_2,
std::placeholders::_5, std::placeholders::_5,
std::placeholders::_6) std::placeholders::_6)
#else
_1, _2, _5, _6)
#endif
); );
} else { } else {
err = m_adac.openStream(&params, nullptr, err = m_adac.openStream(&params, nullptr,
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize, hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
std::bind(&river::io::NodeAirTAudio::playbackCallback, std11::bind(&river::io::NodeAirTAudio::playbackCallback,
this, this,
#if __cplusplus >= 201103L
std::placeholders::_3, std::placeholders::_3,
std::placeholders::_4, std::placeholders::_4,
std::placeholders::_5, std::placeholders::_5,
std::placeholders::_6) std::placeholders::_6)
#else
_3, _4, _5, _6)
#endif
); );
} }
if (err != airtaudio::error_none) { if (err != airtaudio::error_none) {
@ -239,7 +251,7 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std::sha
} }
river::io::NodeAirTAudio::~NodeAirTAudio() { river::io::NodeAirTAudio::~NodeAirTAudio() {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
RIVER_INFO("close input stream"); RIVER_INFO("close input stream");
if (m_adac.isStreamOpen() ) { if (m_adac.isStreamOpen() ) {
m_adac.closeStream(); m_adac.closeStream();
@ -247,7 +259,7 @@ river::io::NodeAirTAudio::~NodeAirTAudio() {
}; };
void river::io::NodeAirTAudio::start() { void river::io::NodeAirTAudio::start() {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") ); RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
enum airtaudio::error err = m_adac.startStream(); enum airtaudio::error err = m_adac.startStream();
if (err != airtaudio::error_none) { if (err != airtaudio::error_none) {
@ -256,7 +268,7 @@ void river::io::NodeAirTAudio::start() {
} }
void river::io::NodeAirTAudio::stop() { void river::io::NodeAirTAudio::stop() {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
RIVER_INFO("Stop stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") ); RIVER_INFO("Stop stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
enum airtaudio::error err = m_adac.stopStream(); enum airtaudio::error err = m_adac.stopStream();
if (err != airtaudio::error_none) { if (err != airtaudio::error_none) {

View File

@ -19,9 +19,9 @@ namespace river {
/** /**
* @brief Constructor * @brief Constructor
*/ */
NodeAirTAudio(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config); NodeAirTAudio(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
public: public:
static std::shared_ptr<NodeAirTAudio> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config); static std11::shared_ptr<NodeAirTAudio> create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
/** /**
* @brief Destructor * @brief Destructor
*/ */
@ -32,17 +32,17 @@ namespace river {
unsigned int m_rtaudioFrameSize; unsigned int m_rtaudioFrameSize;
public: public:
int32_t duplexCallback(const void* _inputBuffer, int32_t duplexCallback(const void* _inputBuffer,
const std::chrono::system_clock::time_point& _timeInput, const std11::chrono::system_clock::time_point& _timeInput,
void* _outputBuffer, void* _outputBuffer,
const std::chrono::system_clock::time_point& _timeOutput, const std11::chrono::system_clock::time_point& _timeOutput,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::vector<airtaudio::status>& _status); const std::vector<airtaudio::status>& _status);
int32_t recordCallback(const void* _inputBuffer, int32_t recordCallback(const void* _inputBuffer,
const std::chrono::system_clock::time_point& _timeInput, const std11::chrono::system_clock::time_point& _timeInput,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::vector<airtaudio::status>& _status); const std::vector<airtaudio::status>& _status);
int32_t playbackCallback(void* _outputBuffer, int32_t playbackCallback(void* _outputBuffer,
const std::chrono::system_clock::time_point& _timeOutput, const std11::chrono::system_clock::time_point& _timeOutput,
uint32_t _nbChunk, uint32_t _nbChunk,
const std::vector<airtaudio::status>& _status); const std::vector<airtaudio::status>& _status);
protected: protected:

View File

@ -9,14 +9,18 @@
#include <river/io/NodePortAudio.h> #include <river/io/NodePortAudio.h>
#include <river/debug.h> #include <river/debug.h>
#include <memory> #if __cplusplus >= 201103L
#include <memory>
#else
#include <etk/memory.h>
#endif
#undef __class__ #undef __class__
#define __class__ "io::NodePortAudio" #define __class__ "io::NodePortAudio"
static std::string asString(const std::chrono::system_clock::time_point& tp) { static std::string asString(const std11::chrono::system_clock::time_point& tp) {
// convert to system time: // convert to system time:
std::time_t t = std::chrono::system_clock::to_time_t(tp); std::time_t t = std11::chrono::system_clock::to_time_t(tp);
// convert in human string // convert in human string
std::string ts = std::ctime(&t); std::string ts = std::ctime(&t);
// remove \n // remove \n
@ -25,8 +29,8 @@ static std::string asString(const std::chrono::system_clock::time_point& tp) {
} }
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::microseconds us = std::chrono::duration_cast<std::chrono::microseconds>(_obj.time_since_epoch()); std11::chrono::microseconds us = std11::chrono::duration_cast<std::chrono::microseconds>(_obj.time_since_epoch());
_os << us.count(); _os << us.count();
return _os; return _os;
} }
@ -41,10 +45,10 @@ static int portAudioStreamCallback(const void *_input,
river::io::NodePortAudio* myClass = reinterpret_cast<river::io::NodePortAudio*>(_userData); river::io::NodePortAudio* myClass = reinterpret_cast<river::io::NodePortAudio*>(_userData);
int64_t sec = int64_t(_timeInfo->inputBufferAdcTime); int64_t sec = int64_t(_timeInfo->inputBufferAdcTime);
int64_t nsec = (_timeInfo->inputBufferAdcTime-double(sec))*1000000000LL; int64_t nsec = (_timeInfo->inputBufferAdcTime-double(sec))*1000000000LL;
std::chrono::system_clock::time_point timeInput = std::chrono::system_clock::from_time_t(sec) + std::chrono::nanoseconds(nsec); std11::chrono::system_clock::time_point timeInput = std11::chrono::system_clock::from_time_t(sec) + std::chrono::nanoseconds(nsec);
sec = int64_t(_timeInfo->outputBufferDacTime); sec = int64_t(_timeInfo->outputBufferDacTime);
nsec = (_timeInfo->outputBufferDacTime-double(sec))*1000000000LL; nsec = (_timeInfo->outputBufferDacTime-double(sec))*1000000000LL;
std::chrono::system_clock::time_point timeOutput = std::chrono::system_clock::from_time_t(sec) + std::chrono::nanoseconds(nsec); std11::chrono::system_clock::time_point timeOutput = std11::chrono::system_clock::from_time_t(sec) + std::chrono::nanoseconds(nsec);
return myClass->duplexCallback(_input, return myClass->duplexCallback(_input,
timeInput, timeInput,
_output, _output,
@ -54,12 +58,12 @@ static int portAudioStreamCallback(const void *_input,
} }
int32_t river::io::NodePortAudio::duplexCallback(const void* _inputBuffer, int32_t river::io::NodePortAudio::duplexCallback(const void* _inputBuffer,
const std::chrono::system_clock::time_point& _timeInput, const std11::chrono::system_clock::time_point& _timeInput,
void* _outputBuffer, void* _outputBuffer,
const std::chrono::system_clock::time_point& _timeOutput, const std11::chrono::system_clock::time_point& _timeOutput,
uint32_t _nbChunk, uint32_t _nbChunk,
PaStreamCallbackFlags _status) { PaStreamCallbackFlags _status) {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
// TODO : Manage status ... // TODO : Manage status ...
if (_inputBuffer != nullptr) { if (_inputBuffer != nullptr) {
RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size()); RIVER_VERBOSE("data Input size request :" << _nbChunk << " [BEGIN] status=" << _status << " nbIO=" << m_list.size());
@ -73,11 +77,11 @@ int32_t river::io::NodePortAudio::duplexCallback(const void* _inputBuffer,
} }
std::shared_ptr<river::io::NodePortAudio> river::io::NodePortAudio::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) { std11::shared_ptr<river::io::NodePortAudio> river::io::NodePortAudio::create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) {
return std::shared_ptr<river::io::NodePortAudio>(new river::io::NodePortAudio(_name, _config)); return std11::shared_ptr<river::io::NodePortAudio>(new river::io::NodePortAudio(_name, _config));
} }
river::io::NodePortAudio::NodePortAudio(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) : river::io::NodePortAudio::NodePortAudio(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config) :
Node(_name, _config) { Node(_name, _config) {
drain::IOFormatInterface interfaceFormat = getInterfaceFormat(); drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
drain::IOFormatInterface hardwareFormat = getHarwareFormat(); drain::IOFormatInterface hardwareFormat = getHarwareFormat();
@ -90,7 +94,7 @@ river::io::NodePortAudio::NodePortAudio(const std::string& _name, const std::sha
*/ */
enum airtaudio::type typeInterface = airtaudio::type_undefined; enum airtaudio::type typeInterface = airtaudio::type_undefined;
std::string streamName = "default"; std::string streamName = "default";
const std::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on"); const std11::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on");
if (tmpObject == nullptr) { if (tmpObject == nullptr) {
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'"); RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
} else { } else {
@ -127,7 +131,7 @@ river::io::NodePortAudio::NodePortAudio(const std::string& _name, const std::sha
} }
river::io::NodePortAudio::~NodePortAudio() { river::io::NodePortAudio::~NodePortAudio() {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
RIVER_INFO("close input stream"); RIVER_INFO("close input stream");
PaError err = Pa_CloseStream( m_stream ); PaError err = Pa_CloseStream( m_stream );
if( err != paNoError ) { if( err != paNoError ) {
@ -136,7 +140,7 @@ river::io::NodePortAudio::~NodePortAudio() {
}; };
void river::io::NodePortAudio::start() { void river::io::NodePortAudio::start() {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") ); RIVER_INFO("Start stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
PaError err = Pa_StartStream(m_stream); PaError err = Pa_StartStream(m_stream);
if( err != paNoError ) { if( err != paNoError ) {
@ -145,7 +149,7 @@ void river::io::NodePortAudio::start() {
} }
void river::io::NodePortAudio::stop() { void river::io::NodePortAudio::stop() {
std::unique_lock<std::mutex> lock(m_mutex); std11::unique_lock<std11::mutex> lock(m_mutex);
RIVER_INFO("Stop stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") ); RIVER_INFO("Stop stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") );
PaError err = Pa_StopStream(m_stream); PaError err = Pa_StopStream(m_stream);
if( err != paNoError ) { if( err != paNoError ) {

View File

@ -21,9 +21,9 @@ namespace river {
/** /**
* @brief Constructor * @brief Constructor
*/ */
NodePortAudio(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config); NodePortAudio(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
public: public:
static std::shared_ptr<NodePortAudio> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config); static std11::shared_ptr<NodePortAudio> create(const std::string& _name, const std11::shared_ptr<const ejson::Object>& _config);
/** /**
* @brief Destructor * @brief Destructor
*/ */
@ -32,9 +32,9 @@ namespace river {
PaStream* m_stream; PaStream* m_stream;
public: public:
int32_t duplexCallback(const void* _inputBuffer, int32_t duplexCallback(const void* _inputBuffer,
const std::chrono::system_clock::time_point& _timeInput, const std11::chrono::system_clock::time_point& _timeInput,
void* _outputBuffer, void* _outputBuffer,
const std::chrono::system_clock::time_point& _timeOutput, const std11::chrono::system_clock::time_point& _timeOutput,
uint32_t _nbChunk, uint32_t _nbChunk,
PaStreamCallbackFlags _status); PaStreamCallbackFlags _status);
protected: protected:

View File

@ -21,10 +21,10 @@
class testOutWrite { class testOutWrite {
private: private:
std::vector<audio::channel> m_channelMap; std::vector<audio::channel> m_channelMap;
std::shared_ptr<river::Manager> m_manager; std11::shared_ptr<river::Manager> m_manager;
std::shared_ptr<river::Interface> m_interface; std11::shared_ptr<river::Interface> m_interface;
public: public:
testOutWrite(std::shared_ptr<river::Manager> _manager) : testOutWrite(std11::shared_ptr<river::Manager> _manager) :
m_manager(_manager) { m_manager(_manager) {
//Set stereo output: //Set stereo output:
m_channelMap.push_back(audio::channel_frontLeft); m_channelMap.push_back(audio::channel_frontLeft);
@ -74,11 +74,11 @@ class testOutWrite {
}; };
TEST(TestALL, testOutputWrite) { TEST(TestALL, testOutputWrite) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
APPL_INFO("test output (write mode)"); APPL_INFO("test output (write mode)");
std::shared_ptr<testOutWrite> process = std::make_shared<testOutWrite>(manager); std11::shared_ptr<testOutWrite> process = std::make_shared<testOutWrite>(manager);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -87,11 +87,11 @@ TEST(TestALL, testOutputWrite) {
class testOutWriteCallback { class testOutWriteCallback {
private: private:
std::shared_ptr<river::Manager> m_manager; std11::shared_ptr<river::Manager> m_manager;
std::shared_ptr<river::Interface> m_interface; std11::shared_ptr<river::Interface> m_interface;
double m_phase; double m_phase;
public: public:
testOutWriteCallback(std::shared_ptr<river::Manager> _manager) : testOutWriteCallback(std11::shared_ptr<river::Manager> _manager) :
m_manager(_manager), m_manager(_manager),
m_phase(0) { m_phase(0) {
std::vector<audio::channel> channelMap; std::vector<audio::channel> channelMap;
@ -112,7 +112,7 @@ class testOutWriteCallback {
std::placeholders::_4, std::placeholders::_4,
std::placeholders::_5)); std::placeholders::_5));
} }
void onDataNeeded(const std::chrono::system_clock::time_point& _time, void onDataNeeded(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,
@ -143,11 +143,11 @@ class testOutWriteCallback {
}; };
TEST(TestALL, testOutputWriteWithCallback) { TEST(TestALL, testOutputWriteWithCallback) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
APPL_INFO("test output (write with callback event mode)"); APPL_INFO("test output (write with callback event mode)");
std::shared_ptr<testOutWriteCallback> process = std::make_shared<testOutWriteCallback>(manager); std11::shared_ptr<testOutWriteCallback> process = std::make_shared<testOutWriteCallback>(manager);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -156,11 +156,11 @@ TEST(TestALL, testOutputWriteWithCallback) {
class testOutCallback { class testOutCallback {
private: private:
std::shared_ptr<river::Manager> m_manager; std11::shared_ptr<river::Manager> m_manager;
std::shared_ptr<river::Interface> m_interface; std11::shared_ptr<river::Interface> m_interface;
double m_phase; double m_phase;
public: public:
testOutCallback(std::shared_ptr<river::Manager> _manager, const std::string& _io="speaker") : testOutCallback(std11::shared_ptr<river::Manager> _manager, const std::string& _io="speaker") :
m_manager(_manager), m_manager(_manager),
m_phase(0) { m_phase(0) {
//Set stereo output: //Set stereo output:
@ -183,7 +183,7 @@ class testOutCallback {
std::placeholders::_6)); std::placeholders::_6));
} }
void onDataNeeded(void* _data, void onDataNeeded(void* _data,
const std::chrono::system_clock::time_point& _time, 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,
@ -212,33 +212,33 @@ class testOutCallback {
}; };
TEST(TestALL, testOutputCallBack) { TEST(TestALL, testOutputCallBack) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
APPL_INFO("test output (callback mode)"); APPL_INFO("test output (callback mode)");
std::shared_ptr<testOutCallback> process = std::make_shared<testOutCallback>(manager, "speaker"); std11::shared_ptr<testOutCallback> process = std::make_shared<testOutCallback>(manager, "speaker");
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
} }
TEST(TestALL, testOutputCallBackPulse) { TEST(TestALL, testOutputCallBackPulse) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
APPL_INFO("test output (callback mode)"); APPL_INFO("test output (callback mode)");
std::shared_ptr<testOutCallback> process = std::make_shared<testOutCallback>(manager, "speaker-pulse"); std11::shared_ptr<testOutCallback> process = std::make_shared<testOutCallback>(manager, "speaker-pulse");
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
} }
TEST(TestALL, testOutputCallBackJack) { TEST(TestALL, testOutputCallBackJack) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
APPL_INFO("test output (callback mode)"); APPL_INFO("test output (callback mode)");
std::shared_ptr<testOutCallback> process = std::make_shared<testOutCallback>(manager, "speaker-jack"); std11::shared_ptr<testOutCallback> process = std::make_shared<testOutCallback>(manager, "speaker-jack");
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -248,10 +248,10 @@ TEST(TestALL, testOutputCallBackJack) {
class testInRead { class testInRead {
private: private:
std::vector<audio::channel> m_channelMap; std::vector<audio::channel> m_channelMap;
std::shared_ptr<river::Manager> m_manager; std11::shared_ptr<river::Manager> m_manager;
std::shared_ptr<river::Interface> m_interface; std11::shared_ptr<river::Interface> m_interface;
public: public:
testInRead(std::shared_ptr<river::Manager> _manager) : testInRead(std11::shared_ptr<river::Manager> _manager) :
m_manager(_manager){ m_manager(_manager){
//Set stereo output: //Set stereo output:
m_channelMap.push_back(audio::channel_frontLeft); m_channelMap.push_back(audio::channel_frontLeft);
@ -280,10 +280,10 @@ class testInRead {
}; };
TEST(TestALL, testInputCallBack) { TEST(TestALL, testInputCallBack) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
APPL_INFO("test input (callback mode)"); APPL_INFO("test input (callback mode)");
std::shared_ptr<testInCallback> process = std::make_shared<testInCallback>(manager); std11::shared_ptr<testInCallback> process = std::make_shared<testInCallback>(manager);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -292,11 +292,11 @@ TEST(TestALL, testInputCallBack) {
class testInCallback { class testInCallback {
private: private:
std::shared_ptr<river::Manager> m_manager; std11::shared_ptr<river::Manager> m_manager;
std::shared_ptr<river::Interface> m_interface; std11::shared_ptr<river::Interface> m_interface;
double m_phase; double m_phase;
public: public:
testInCallback(std::shared_ptr<river::Manager> _manager, const std::string& _input="microphone") : testInCallback(std11::shared_ptr<river::Manager> _manager, const std::string& _input="microphone") :
m_manager(_manager), m_manager(_manager),
m_phase(0) { m_phase(0) {
//Set stereo output: //Set stereo output:
@ -319,7 +319,7 @@ class testInCallback {
std::placeholders::_6)); std::placeholders::_6));
} }
void onDataReceived(const void* _data, void onDataReceived(const void* _data,
const std::chrono::system_clock::time_point& _time, 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,
@ -346,10 +346,10 @@ class testInCallback {
}; };
TEST(TestALL, testInputCallBack) { TEST(TestALL, testInputCallBack) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
APPL_INFO("test input (callback mode)"); APPL_INFO("test input (callback mode)");
std::shared_ptr<testInCallback> process = std::make_shared<testInCallback>(manager); std11::shared_ptr<testInCallback> process = std::make_shared<testInCallback>(manager);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -359,15 +359,15 @@ TEST(TestALL, testInputCallBack) {
class testOutCallbackType { class testOutCallbackType {
private: private:
std::shared_ptr<river::Manager> m_manager; std11::shared_ptr<river::Manager> m_manager;
std::shared_ptr<river::Interface> m_interface; std11::shared_ptr<river::Interface> m_interface;
double m_phase; double m_phase;
float m_freq; float m_freq;
int32_t m_nbChannels; int32_t m_nbChannels;
float m_generateFreq; float m_generateFreq;
public: public:
testOutCallbackType(const std::shared_ptr<river::Manager>& _manager, testOutCallbackType(const std11::shared_ptr<river::Manager>& _manager,
float _freq=48000.0f, float _freq=48000.0f,
int32_t _nbChannels=2, int32_t _nbChannels=2,
audio::format _format=audio::format_int16) : audio::format _format=audio::format_int16) :
@ -408,7 +408,7 @@ class testOutCallbackType {
std::placeholders::_6)); std::placeholders::_6));
} }
void onDataNeeded(void* _data, void onDataNeeded(void* _data,
const std::chrono::system_clock::time_point& _time, 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,
@ -477,9 +477,9 @@ class testOutCallbackType {
class testResampling : public ::testing::TestWithParam<float> {}; class testResampling : public ::testing::TestWithParam<float> {};
TEST_P(testResampling, base) { TEST_P(testResampling, base) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
std::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, GetParam(), 2, audio::format_int16); std11::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, GetParam(), 2, audio::format_int16);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -492,9 +492,9 @@ INSTANTIATE_TEST_CASE_P(InstantiationName,
class testFormat : public ::testing::TestWithParam<audio::format> {}; class testFormat : public ::testing::TestWithParam<audio::format> {};
TEST_P(testFormat, base) { TEST_P(testFormat, base) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
std::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, 48000, 2, GetParam()); std11::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, 48000, 2, GetParam());
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -506,9 +506,9 @@ INSTANTIATE_TEST_CASE_P(InstantiationName,
class testChannels : public ::testing::TestWithParam<int32_t> {}; class testChannels : public ::testing::TestWithParam<int32_t> {};
TEST_P(testChannels, base) { TEST_P(testChannels, base) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
std::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, 48000, GetParam(), audio::format_int16); std11::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, 48000, GetParam(), audio::format_int16);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -521,11 +521,11 @@ INSTANTIATE_TEST_CASE_P(InstantiationName,
class testCallbackVolume { class testCallbackVolume {
private: private:
std::shared_ptr<river::Manager> m_manager; std11::shared_ptr<river::Manager> m_manager;
std::shared_ptr<river::Interface> m_interface; std11::shared_ptr<river::Interface> m_interface;
double m_phase; double m_phase;
public: public:
testCallbackVolume(std::shared_ptr<river::Manager> _manager) : testCallbackVolume(std11::shared_ptr<river::Manager> _manager) :
m_manager(_manager), m_manager(_manager),
m_phase(0) { m_phase(0) {
//Set stereo output: //Set stereo output:
@ -550,7 +550,7 @@ class testCallbackVolume {
m_interface->addVolumeGroup("FLOW"); m_interface->addVolumeGroup("FLOW");
} }
void onDataNeeded(void* _data, void onDataNeeded(void* _data,
const std::chrono::system_clock::time_point& _time, 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,
@ -608,22 +608,22 @@ class testCallbackVolume {
}; };
void threadVolume(void* _userData) { void threadVolume(void* _userData) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
std::shared_ptr<testCallbackVolume> process = std::make_shared<testCallbackVolume>(manager); std11::shared_ptr<testCallbackVolume> process = std::make_shared<testCallbackVolume>(manager);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
} }
TEST(TestALL, testInputCallBackMicClean) { TEST(TestALL, testInputCallBackMicClean) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
std::thread tmpThread(&threadVolume, nullptr); std11::thread tmpThread(&threadVolume, nullptr);
usleep(100000); usleep(100000);
APPL_INFO("test input (callback mode)"); APPL_INFO("test input (callback mode)");
std::shared_ptr<testInCallback> process = std::make_shared<testInCallback>(manager, "microphone-clean"); std11::shared_ptr<testInCallback> process = std::make_shared<testInCallback>(manager, "microphone-clean");
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -632,16 +632,16 @@ TEST(TestALL, testInputCallBackMicClean) {
TEST(TestALL, testVolume) { TEST(TestALL, testVolume) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
std::shared_ptr<testCallbackVolume> process = std::make_shared<testCallbackVolume>(manager); std11::shared_ptr<testCallbackVolume> process = std::make_shared<testCallbackVolume>(manager);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
} }
TEST(TestALL, testChannelsFormatResampling) { TEST(TestALL, testChannelsFormatResampling) {
std::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
APPL_INFO("test convert flaot to output (callback mode)"); APPL_INFO("test convert flaot to output (callback mode)");
std::vector<float> listFreq; std::vector<float> listFreq;
@ -670,7 +670,7 @@ TEST(TestALL, testChannelsFormatResampling) {
for (auto &itChannel : listChannel) { for (auto &itChannel : listChannel) {
for (auto &itFormat : listFormat) { for (auto &itFormat : listFormat) {
APPL_INFO("freq=" << itFreq << " channel=" << itChannel << " format=" << getFormatString(itFormat)); APPL_INFO("freq=" << itFreq << " channel=" << itChannel << " format=" << getFormatString(itFormat));
std::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, itFreq, itChannel, itFormat); std11::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, itFreq, itChannel, itFormat);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);