2015-01-25 22:17:06 +01:00
|
|
|
/** @file
|
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @copyright 2015, Edouard DUPIN, all right reserved
|
|
|
|
* @license APACHE v2.0 (see license file)
|
|
|
|
*/
|
|
|
|
|
2015-01-26 22:04:29 +01:00
|
|
|
#include "debug.h"
|
2015-01-25 22:17:06 +01:00
|
|
|
#include "Interface.h"
|
2015-01-26 22:04:29 +01:00
|
|
|
#include "io/Node.h"
|
2015-02-05 19:10:53 +01:00
|
|
|
#include <drain/EndPointCallback.h>
|
|
|
|
#include <drain/EndPointWrite.h>
|
|
|
|
#include <drain/EndPointRead.h>
|
|
|
|
#include <drain/Volume.h>
|
2015-01-25 22:17:06 +01:00
|
|
|
|
|
|
|
|
2015-01-27 21:01:52 +01:00
|
|
|
#undef __class__
|
|
|
|
#define __class__ "Interface"
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
river::Interface::Interface(void) :
|
2015-01-25 22:17:06 +01:00
|
|
|
m_node(nullptr),
|
|
|
|
m_freq(8000),
|
|
|
|
m_map(),
|
2015-02-04 22:39:05 +01:00
|
|
|
m_format(audio::format_int16),
|
2015-01-26 22:04:29 +01:00
|
|
|
m_name(""),
|
2015-01-25 22:17:06 +01:00
|
|
|
m_volume(0.0f) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
bool river::Interface::init(const std::string& _name,
|
2015-01-25 22:17:06 +01:00
|
|
|
float _freq,
|
2015-02-04 22:39:05 +01:00
|
|
|
const std::vector<audio::channel>& _map,
|
|
|
|
audio::format _format,
|
2015-02-05 19:10:53 +01:00
|
|
|
const std::shared_ptr<river::io::Node>& _node) {
|
2015-01-25 22:17:06 +01:00
|
|
|
m_name = _name;
|
|
|
|
m_node = _node;
|
|
|
|
m_freq = _freq;
|
|
|
|
m_map = _map;
|
|
|
|
m_format = _format;
|
2015-02-05 19:10:53 +01:00
|
|
|
m_process = std::make_shared<drain::Process>();
|
2015-01-25 22:17:06 +01:00
|
|
|
m_volume = 0.0f;
|
2015-02-04 21:08:06 +01:00
|
|
|
// register interface to be notify from the volume change.
|
|
|
|
m_node->registerAsRemote(shared_from_this());
|
2015-01-25 22:17:06 +01:00
|
|
|
// Create convertion interface
|
|
|
|
if (m_node->isInput() == true) {
|
2015-02-01 22:21:03 +01:00
|
|
|
// add all time the volume stage :
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::Volume> algo = drain::Volume::create();
|
2015-02-02 22:04:11 +01:00
|
|
|
algo->setInputFormat(m_node->getInterfaceFormat());
|
2015-02-01 22:21:03 +01:00
|
|
|
algo->setName("volume");
|
|
|
|
m_process->pushBack(algo);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_INFO("add basic volume stage (1)");
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::VolumeElement> tmpVolume = m_node->getVolume();
|
2015-02-03 21:29:23 +01:00
|
|
|
if (tmpVolume != nullptr) {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_INFO(" add volume for node");
|
2015-02-03 21:29:23 +01:00
|
|
|
algo->addVolumeStage(tmpVolume);
|
|
|
|
}
|
2015-01-25 22:17:06 +01:00
|
|
|
} else {
|
2015-02-01 22:21:03 +01:00
|
|
|
// add all time the volume stage :
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::Volume> algo = drain::Volume::create();
|
2015-02-02 22:04:11 +01:00
|
|
|
algo->setOutputFormat(m_node->getInterfaceFormat());
|
2015-02-01 22:21:03 +01:00
|
|
|
algo->setName("volume");
|
|
|
|
m_process->pushBack(algo);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_INFO("add basic volume stage (2)");
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::VolumeElement> tmpVolume = m_node->getVolume();
|
2015-02-03 21:29:23 +01:00
|
|
|
if (tmpVolume != nullptr) {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_INFO(" add volume for node");
|
2015-02-03 21:29:23 +01:00
|
|
|
algo->addVolumeStage(tmpVolume);
|
|
|
|
}
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
2015-01-26 22:04:29 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<river::Interface> river::Interface::create(const std::string& _name,
|
2015-01-26 22:04:29 +01:00
|
|
|
float _freq,
|
2015-02-04 22:39:05 +01:00
|
|
|
const std::vector<audio::channel>& _map,
|
|
|
|
audio::format _format,
|
2015-02-05 19:10:53 +01:00
|
|
|
const std::shared_ptr<river::io::Node>& _node) {
|
|
|
|
std::shared_ptr<river::Interface> out = std::shared_ptr<river::Interface>(new river::Interface());
|
2015-01-26 22:04:29 +01:00
|
|
|
out->init(_name, _freq, _map, _format, _node);
|
|
|
|
return out;
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
river::Interface::~Interface() {
|
2015-01-28 22:07:11 +01:00
|
|
|
//stop(true, true);
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-01-25 22:17:06 +01:00
|
|
|
//m_node->interfaceRemove(shared_from_this());
|
2015-01-28 22:07:11 +01:00
|
|
|
m_process.reset();
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
2015-02-01 22:21:03 +01:00
|
|
|
/*
|
2015-02-05 19:10:53 +01:00
|
|
|
bool river::Interface::hasEndPoint() {
|
2015-02-01 22:21:03 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::setReadwrite() {
|
2015-02-01 22:21:03 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->removeAlgoDynamic();
|
2015-02-05 19:10:53 +01:00
|
|
|
if (m_process->hasType<drain::EndPoint>() ) {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_ERROR("Endpoint is already present ==> can not change");
|
2015-02-01 22:21:03 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (m_node->isInput() == true) {
|
2015-02-05 19:10:53 +01:00
|
|
|
m_process->removeIfLast<drain::EndPoint>();
|
|
|
|
std::shared_ptr<drain::EndPointRead> algo = drain::EndPointRead::create();
|
|
|
|
///algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq));
|
|
|
|
algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq));
|
2015-02-01 22:21:03 +01:00
|
|
|
m_process->pushBack(algo);
|
|
|
|
} else {
|
2015-02-05 19:10:53 +01:00
|
|
|
m_process->removeIfFirst<drain::EndPoint>();
|
|
|
|
std::shared_ptr<drain::EndPointWrite> algo = drain::EndPointWrite::create();
|
|
|
|
algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq));
|
|
|
|
//algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq));
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->pushFront(algo);
|
2015-02-01 22:21:03 +01:00
|
|
|
}
|
|
|
|
}
|
2015-01-25 22:17:06 +01:00
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::setOutputCallback(size_t _chunkSize, drain::needDataFunction _function) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->removeAlgoDynamic();
|
2015-02-05 19:10:53 +01:00
|
|
|
m_process->removeIfFirst<drain::EndPoint>();
|
|
|
|
std::shared_ptr<drain::Algo> algo = drain::EndPointCallback::create(_function);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_INFO("set property: " << m_map << " " << m_format << " " << m_freq);
|
2015-02-05 19:10:53 +01:00
|
|
|
algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq));
|
|
|
|
//algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq));
|
2015-01-26 22:04:29 +01:00
|
|
|
m_process->pushFront(algo);
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::setInputCallback(size_t _chunkSize, drain::haveNewDataFunction _function) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->removeAlgoDynamic();
|
2015-02-05 19:10:53 +01:00
|
|
|
m_process->removeIfLast<drain::EndPoint>();
|
|
|
|
std::shared_ptr<drain::Algo> algo = drain::EndPointCallback::create(_function);
|
|
|
|
//algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq));
|
|
|
|
algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq));
|
2015-01-26 22:04:29 +01:00
|
|
|
m_process->pushBack(algo);
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::setWriteCallback(drain::needDataFunctionWrite _function) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->removeAlgoDynamic();
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::EndPointWrite> algo = m_process->get<drain::EndPointWrite>(0);
|
2015-01-27 22:47:09 +01:00
|
|
|
if (algo == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
algo->setCallback(_function);
|
|
|
|
}
|
2015-01-25 22:17:06 +01:00
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::start(const std::chrono::system_clock::time_point& _time) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("start [BEGIN]");
|
2015-02-01 22:21:03 +01:00
|
|
|
m_process->updateInterAlgo();
|
2015-01-25 22:17:06 +01:00
|
|
|
m_node->interfaceAdd(shared_from_this());
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("start [ END ]");
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::stop(bool _fast, bool _abort) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("stop [BEGIN]");
|
2015-01-25 22:17:06 +01:00
|
|
|
m_node->interfaceRemove(shared_from_this());
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("stop [ END]");
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::abort() {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("abort [BEGIN]");
|
2015-01-25 22:17:06 +01:00
|
|
|
// TODO :...
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("abort [ END ]");
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
bool river::Interface::setParameter(const std::string& _filter, const std::string& _parameter, const std::string& _value) {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("setParameter [BEGIN] : '" << _filter << "':'" << _parameter << "':'" << _value << "'");
|
2015-01-30 21:44:36 +01:00
|
|
|
bool out = false;
|
|
|
|
if ( _filter == "volume"
|
|
|
|
&& _parameter != "FLOW") {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_ERROR("Interface is not allowed to modify '" << _parameter << "' Volume just allowed to modify 'FLOW' volume");
|
2015-02-03 21:29:23 +01:00
|
|
|
return false;
|
2015-01-30 21:44:36 +01:00
|
|
|
}
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::Algo> algo = m_process->get<drain::Algo>(_filter);
|
2015-02-03 21:29:23 +01:00
|
|
|
if (algo == nullptr) {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
|
2015-02-03 21:29:23 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
out = algo->setParameter(_parameter, _value);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("setParameter [ END ] : '" << out << "'");
|
2015-01-30 21:44:36 +01:00
|
|
|
return out;
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
2015-02-05 19:10:53 +01:00
|
|
|
std::string river::Interface::getParameter(const std::string& _filter, const std::string& _parameter) const {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("getParameter [BEGIN] : '" << _filter << "':'" << _parameter << "'");
|
2015-01-30 21:44:36 +01:00
|
|
|
std::string out;
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::Algo> algo = m_process->get<drain::Algo>(_filter);
|
2015-02-03 21:29:23 +01:00
|
|
|
if (algo == nullptr) {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
|
2015-02-03 21:29:23 +01:00
|
|
|
return "[ERROR]";
|
|
|
|
}
|
|
|
|
out = algo->getParameter(_parameter);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("getParameter [ END ] : '" << out << "'");
|
2015-01-30 21:44:36 +01:00
|
|
|
return out;
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
2015-02-05 19:10:53 +01:00
|
|
|
std::string river::Interface::getParameterProperty(const std::string& _filter, const std::string& _parameter) const {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("getParameterProperty [BEGIN] : '" << _filter << "':'" << _parameter << "'");
|
2015-01-30 21:44:36 +01:00
|
|
|
std::string out;
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::Algo> algo = m_process->get<drain::Algo>(_filter);
|
2015-02-03 21:29:23 +01:00
|
|
|
if (algo == nullptr) {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_ERROR("setParameter(" << _filter << ") ==> no filter named like this ...");
|
2015-02-03 21:29:23 +01:00
|
|
|
return "[ERROR]";
|
|
|
|
}
|
|
|
|
out = algo->getParameterProperty(_parameter);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("getParameterProperty [ END ] : '" << out << "'");
|
2015-01-30 21:44:36 +01:00
|
|
|
return out;
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::write(const void* _value, size_t _nbChunk) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->updateInterAlgo();
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::EndPointWrite> algo = m_process->get<drain::EndPointWrite>(0);
|
2015-01-25 22:17:06 +01:00
|
|
|
if (algo == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
algo->write(_value, _nbChunk);
|
|
|
|
}
|
|
|
|
|
2015-01-27 21:01:52 +01:00
|
|
|
#if 0
|
2015-01-25 22:17:06 +01:00
|
|
|
// TODO : add API aCCess mutex for Read and write...
|
2015-02-05 19:10:53 +01:00
|
|
|
std::vector<int16_t> river::Interface::read(size_t _nbChunk) {
|
2015-01-25 22:17:06 +01:00
|
|
|
// TODO :...
|
|
|
|
std::vector<int16_t> data;
|
|
|
|
/*
|
|
|
|
data.resize(_nbChunk*m_map.size(), 0);
|
|
|
|
m_mutex.lock();
|
|
|
|
int32_t nbChunkBuffer = m_circularBuffer.size() / m_map.size();
|
|
|
|
m_mutex.unlock();
|
|
|
|
while (nbChunkBuffer < _nbChunk) {
|
|
|
|
usleep(1000);
|
|
|
|
nbChunkBuffer = m_circularBuffer.size() / m_map.size();
|
|
|
|
}
|
|
|
|
m_mutex.lock();
|
|
|
|
for (size_t iii = 0; iii<data.size(); ++iii) {
|
|
|
|
data[iii] = m_circularBuffer[iii];
|
|
|
|
}
|
|
|
|
m_circularBuffer.erase(m_circularBuffer.begin(), m_circularBuffer.begin()+data.size());
|
|
|
|
m_mutex.unlock();
|
|
|
|
*/
|
|
|
|
return data;
|
|
|
|
}
|
2015-01-27 21:01:52 +01:00
|
|
|
#endif
|
2015-01-25 22:17:06 +01:00
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::read(void* _value, size_t _nbChunk) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->updateInterAlgo();
|
2015-01-25 22:17:06 +01:00
|
|
|
// TODO :...
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
size_t river::Interface::size() const {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-01-25 22:17:06 +01:00
|
|
|
// TODO :...
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::setBufferSize(size_t _nbChunk) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->updateInterAlgo();
|
2015-01-25 22:17:06 +01:00
|
|
|
// TODO :...
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::setBufferSize(const std::chrono::duration<int64_t, std::micro>& _time) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->updateInterAlgo();
|
2015-01-25 22:17:06 +01:00
|
|
|
// TODO :...
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::clearInternalBuffer() {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-02 22:04:11 +01:00
|
|
|
m_process->updateInterAlgo();
|
2015-01-25 22:17:06 +01:00
|
|
|
// TODO :...
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
std::chrono::system_clock::time_point river::Interface::getCurrentTime() const {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-01-25 22:17:06 +01:00
|
|
|
// TODO :...
|
|
|
|
return std::chrono::system_clock::time_point();
|
|
|
|
return std::chrono::system_clock::now();
|
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::addVolumeGroup(const std::string& _name) {
|
2015-02-03 21:29:23 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lock(m_mutex);
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_DEBUG("addVolumeGroup(" << _name << ")");
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::Volume> algo = m_process->get<drain::Volume>("volume");
|
2015-02-03 21:29:23 +01:00
|
|
|
if (algo == nullptr) {
|
2015-02-05 21:33:12 +01:00
|
|
|
RIVER_ERROR("addVolumeGroup(" << _name << ") ==> no volume stage ... can not add it ...");
|
2015-02-03 21:29:23 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (_name == "FLOW") {
|
|
|
|
// Local volume name
|
2015-02-05 19:10:53 +01:00
|
|
|
algo->addVolumeStage(std::make_shared<drain::VolumeElement>(_name));
|
2015-02-03 21:29:23 +01:00
|
|
|
} else {
|
|
|
|
// get manager unique instance:
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<river::io::Manager> mng = river::io::Manager::getInstance();
|
2015-02-03 21:29:23 +01:00
|
|
|
algo->addVolumeStage(mng->getVolumeGroup(_name));
|
|
|
|
}
|
|
|
|
}
|
2015-01-25 22:17:06 +01:00
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::systemNewInputData(std::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lockProcess(m_mutex);
|
2015-01-26 22:04:29 +01:00
|
|
|
m_process->push(_time, _data, _nbChunk);
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::systemNeedOutputData(std::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk, size_t _chunkSize) {
|
2015-01-29 23:10:26 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lockProcess(m_mutex);
|
2015-01-30 21:44:36 +01:00
|
|
|
m_process->pull(_time, _data, _nbChunk, _chunkSize);
|
2015-01-25 22:17:06 +01:00
|
|
|
}
|
2015-01-30 21:44:36 +01:00
|
|
|
|
2015-02-05 19:10:53 +01:00
|
|
|
void river::Interface::systemVolumeChange() {
|
2015-02-04 21:08:06 +01:00
|
|
|
std::unique_lock<std::recursive_mutex> lockProcess(m_mutex);
|
2015-02-05 19:10:53 +01:00
|
|
|
std::shared_ptr<drain::Volume> algo = m_process->get<drain::Volume>("volume");
|
2015-02-04 21:08:06 +01:00
|
|
|
if (algo == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
algo->volumeChange();
|
2015-02-01 22:21:03 +01:00
|
|
|
}
|