diff --git a/lutin_airtio.py b/lutin_river.py similarity index 50% rename from lutin_airtio.py rename to lutin_river.py index 2dfa515..7f4439a 100644 --- a/lutin_airtio.py +++ b/lutin_river.py @@ -4,21 +4,21 @@ import lutinTools as tools import lutinDebug as debug def get_desc(): - return "airtio : Multi-nodal audio interface" + return "river : Multi-nodal audio interface" def create(target): - myModule = module.Module(__file__, 'airtio', 'LIBRARY') + myModule = module.Module(__file__, 'river', 'LIBRARY') myModule.add_src_file([ - 'airtio/debug.cpp', - 'airtio/Manager.cpp', - 'airtio/Interface.cpp', - 'airtio/io/Node.cpp', - 'airtio/io/Manager.cpp' + 'river/debug.cpp', + 'river/Manager.cpp', + 'river/Interface.cpp', + 'river/io/Node.cpp', + 'river/io/Manager.cpp' ]) - myModule.add_module_depend(['airtaudio', 'airtalgo', 'ejson']) + myModule.add_module_depend(['audio', 'airtaudio', 'drain', 'ejson']) myModule.add_export_path(tools.get_current_path(__file__)) # add the currrent module at the diff --git a/lutin_airtio_test.py b/lutin_river_test.py similarity index 63% rename from lutin_airtio_test.py rename to lutin_river_test.py index 582b4c9..fad717c 100644 --- a/lutin_airtio_test.py +++ b/lutin_river_test.py @@ -4,11 +4,11 @@ import lutinTools as tools import lutinDebug as debug def get_desc(): - return "airtio_test : Multi-nodal audio interface test" + return "river_test : Multi-nodal audio interface test" def create(target): - myModule = module.Module(__file__, 'airtio_test', 'BINARY') + myModule = module.Module(__file__, 'river_test', 'BINARY') myModule.add_src_file([ 'test/main.cpp', @@ -16,7 +16,7 @@ def create(target): ]) myModule.copy_folder('data/*') - myModule.add_module_depend(['airtio', 'gtest', 'etk']) + myModule.add_module_depend(['river', 'gtest', 'etk']) # add the currrent module at the return myModule diff --git a/airtio/Interface.cpp b/river/Interface.cpp similarity index 59% rename from airtio/Interface.cpp rename to river/Interface.cpp index 964a77b..bda4cae 100644 --- a/airtio/Interface.cpp +++ b/river/Interface.cpp @@ -7,16 +7,16 @@ #include "debug.h" #include "Interface.h" #include "io/Node.h" -#include -#include -#include -#include +#include +#include +#include +#include #undef __class__ #define __class__ "Interface" -airtio::Interface::Interface(void) : +river::Interface::Interface(void) : m_node(nullptr), m_freq(8000), m_map(), @@ -26,41 +26,41 @@ airtio::Interface::Interface(void) : } -bool airtio::Interface::init(const std::string& _name, +bool river::Interface::init(const std::string& _name, float _freq, const std::vector& _map, audio::format _format, - const std::shared_ptr& _node) { + const std::shared_ptr& _node) { m_name = _name; m_node = _node; m_freq = _freq; m_map = _map; m_format = _format; - m_process = std::make_shared(); + m_process = std::make_shared(); m_volume = 0.0f; // register interface to be notify from the volume change. m_node->registerAsRemote(shared_from_this()); // Create convertion interface if (m_node->isInput() == true) { // add all time the volume stage : - std::shared_ptr algo = airtalgo::Volume::create(); + std::shared_ptr algo = drain::Volume::create(); algo->setInputFormat(m_node->getInterfaceFormat()); algo->setName("volume"); m_process->pushBack(algo); AIRTIO_INFO("add basic volume stage (1)"); - std::shared_ptr tmpVolume = m_node->getVolume(); + std::shared_ptr tmpVolume = m_node->getVolume(); if (tmpVolume != nullptr) { AIRTIO_INFO(" add volume for node"); algo->addVolumeStage(tmpVolume); } } else { // add all time the volume stage : - std::shared_ptr algo = airtalgo::Volume::create(); + std::shared_ptr algo = drain::Volume::create(); algo->setOutputFormat(m_node->getInterfaceFormat()); algo->setName("volume"); m_process->pushBack(algo); AIRTIO_INFO("add basic volume stage (2)"); - std::shared_ptr tmpVolume = m_node->getVolume(); + std::shared_ptr tmpVolume = m_node->getVolume(); if (tmpVolume != nullptr) { AIRTIO_INFO(" add volume for node"); algo->addVolumeStage(tmpVolume); @@ -69,81 +69,81 @@ bool airtio::Interface::init(const std::string& _name, return true; } -std::shared_ptr airtio::Interface::create(const std::string& _name, +std::shared_ptr river::Interface::create(const std::string& _name, float _freq, const std::vector& _map, audio::format _format, - const std::shared_ptr& _node) { - std::shared_ptr out = std::shared_ptr(new airtio::Interface()); + const std::shared_ptr& _node) { + std::shared_ptr out = std::shared_ptr(new river::Interface()); out->init(_name, _freq, _map, _format, _node); return out; } -airtio::Interface::~Interface() { +river::Interface::~Interface() { //stop(true, true); std::unique_lock lock(m_mutex); //m_node->interfaceRemove(shared_from_this()); m_process.reset(); } /* -bool airtio::Interface::hasEndPoint() { +bool river::Interface::hasEndPoint() { } */ -void airtio::Interface::setReadwrite() { +void river::Interface::setReadwrite() { std::unique_lock lock(m_mutex); m_process->removeAlgoDynamic(); - if (m_process->hasType() ) { + if (m_process->hasType() ) { AIRTIO_ERROR("Endpoint is already present ==> can not change"); return; } if (m_node->isInput() == true) { - m_process->removeIfLast(); - std::shared_ptr algo = airtalgo::EndPointRead::create(); - ///algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq)); - algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq)); + m_process->removeIfLast(); + std::shared_ptr algo = drain::EndPointRead::create(); + ///algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); + algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); m_process->pushBack(algo); } else { - m_process->removeIfFirst(); - std::shared_ptr algo = airtalgo::EndPointWrite::create(); - algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq)); - //algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq)); + m_process->removeIfFirst(); + std::shared_ptr algo = drain::EndPointWrite::create(); + algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); + //algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); m_process->pushFront(algo); } } -void airtio::Interface::setOutputCallback(size_t _chunkSize, airtalgo::needDataFunction _function) { +void river::Interface::setOutputCallback(size_t _chunkSize, drain::needDataFunction _function) { std::unique_lock lock(m_mutex); m_process->removeAlgoDynamic(); - m_process->removeIfFirst(); - std::shared_ptr algo = airtalgo::EndPointCallback::create(_function); + m_process->removeIfFirst(); + std::shared_ptr algo = drain::EndPointCallback::create(_function); AIRTIO_INFO("set property: " << m_map << " " << m_format << " " << m_freq); - algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq)); - //algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq)); + algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); + //algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); m_process->pushFront(algo); } -void airtio::Interface::setInputCallback(size_t _chunkSize, airtalgo::haveNewDataFunction _function) { +void river::Interface::setInputCallback(size_t _chunkSize, drain::haveNewDataFunction _function) { std::unique_lock lock(m_mutex); m_process->removeAlgoDynamic(); - m_process->removeIfLast(); - std::shared_ptr algo = airtalgo::EndPointCallback::create(_function); - //algo->setInputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq)); - algo->setOutputFormat(airtalgo::IOFormatInterface(m_map, m_format, m_freq)); + m_process->removeIfLast(); + std::shared_ptr 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)); m_process->pushBack(algo); } -void airtio::Interface::setWriteCallback(airtalgo::needDataFunctionWrite _function) { +void river::Interface::setWriteCallback(drain::needDataFunctionWrite _function) { std::unique_lock lock(m_mutex); m_process->removeAlgoDynamic(); - std::shared_ptr algo = m_process->get(0); + std::shared_ptr algo = m_process->get(0); if (algo == nullptr) { return; } algo->setCallback(_function); } -void airtio::Interface::start(const std::chrono::system_clock::time_point& _time) { +void river::Interface::start(const std::chrono::system_clock::time_point& _time) { std::unique_lock lock(m_mutex); AIRTIO_DEBUG("start [BEGIN]"); m_process->updateInterAlgo(); @@ -151,21 +151,21 @@ void airtio::Interface::start(const std::chrono::system_clock::time_point& _time AIRTIO_DEBUG("start [ END ]"); } -void airtio::Interface::stop(bool _fast, bool _abort) { +void river::Interface::stop(bool _fast, bool _abort) { std::unique_lock lock(m_mutex); AIRTIO_DEBUG("stop [BEGIN]"); m_node->interfaceRemove(shared_from_this()); AIRTIO_DEBUG("stop [ END]"); } -void airtio::Interface::abort() { +void river::Interface::abort() { std::unique_lock lock(m_mutex); AIRTIO_DEBUG("abort [BEGIN]"); // TODO :... AIRTIO_DEBUG("abort [ END ]"); } -bool airtio::Interface::setParameter(const std::string& _filter, const std::string& _parameter, const std::string& _value) { +bool river::Interface::setParameter(const std::string& _filter, const std::string& _parameter, const std::string& _value) { AIRTIO_DEBUG("setParameter [BEGIN] : '" << _filter << "':'" << _parameter << "':'" << _value << "'"); bool out = false; if ( _filter == "volume" @@ -173,7 +173,7 @@ bool airtio::Interface::setParameter(const std::string& _filter, const std::stri AIRTIO_ERROR("Interface is not allowed to modify '" << _parameter << "' Volume just allowed to modify 'FLOW' volume"); return false; } - std::shared_ptr algo = m_process->get(_filter); + std::shared_ptr algo = m_process->get(_filter); if (algo == nullptr) { AIRTIO_ERROR("setParameter(" << _filter << ") ==> no filter named like this ..."); return false; @@ -182,10 +182,10 @@ bool airtio::Interface::setParameter(const std::string& _filter, const std::stri AIRTIO_DEBUG("setParameter [ END ] : '" << out << "'"); return out; } -std::string airtio::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 { AIRTIO_DEBUG("getParameter [BEGIN] : '" << _filter << "':'" << _parameter << "'"); std::string out; - std::shared_ptr algo = m_process->get(_filter); + std::shared_ptr algo = m_process->get(_filter); if (algo == nullptr) { AIRTIO_ERROR("setParameter(" << _filter << ") ==> no filter named like this ..."); return "[ERROR]"; @@ -194,10 +194,10 @@ std::string airtio::Interface::getParameter(const std::string& _filter, const st AIRTIO_DEBUG("getParameter [ END ] : '" << out << "'"); return out; } -std::string airtio::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 { AIRTIO_DEBUG("getParameterProperty [BEGIN] : '" << _filter << "':'" << _parameter << "'"); std::string out; - std::shared_ptr algo = m_process->get(_filter); + std::shared_ptr algo = m_process->get(_filter); if (algo == nullptr) { AIRTIO_ERROR("setParameter(" << _filter << ") ==> no filter named like this ..."); return "[ERROR]"; @@ -207,10 +207,10 @@ std::string airtio::Interface::getParameterProperty(const std::string& _filter, return out; } -void airtio::Interface::write(const void* _value, size_t _nbChunk) { +void river::Interface::write(const void* _value, size_t _nbChunk) { std::unique_lock lock(m_mutex); m_process->updateInterAlgo(); - std::shared_ptr algo = m_process->get(0); + std::shared_ptr algo = m_process->get(0); if (algo == nullptr) { return; } @@ -219,7 +219,7 @@ void airtio::Interface::write(const void* _value, size_t _nbChunk) { #if 0 // TODO : add API aCCess mutex for Read and write... -std::vector airtio::Interface::read(size_t _nbChunk) { +std::vector river::Interface::read(size_t _nbChunk) { // TODO :... std::vector data; /* @@ -242,78 +242,78 @@ std::vector airtio::Interface::read(size_t _nbChunk) { } #endif -void airtio::Interface::read(void* _value, size_t _nbChunk) { +void river::Interface::read(void* _value, size_t _nbChunk) { std::unique_lock lock(m_mutex); m_process->updateInterAlgo(); // TODO :... } -size_t airtio::Interface::size() const { +size_t river::Interface::size() const { std::unique_lock lock(m_mutex); // TODO :... return 0; } -void airtio::Interface::setBufferSize(size_t _nbChunk) { +void river::Interface::setBufferSize(size_t _nbChunk) { std::unique_lock lock(m_mutex); m_process->updateInterAlgo(); // TODO :... } -void airtio::Interface::setBufferSize(const std::chrono::duration& _time) { +void river::Interface::setBufferSize(const std::chrono::duration& _time) { std::unique_lock lock(m_mutex); m_process->updateInterAlgo(); // TODO :... } -void airtio::Interface::clearInternalBuffer() { +void river::Interface::clearInternalBuffer() { std::unique_lock lock(m_mutex); m_process->updateInterAlgo(); // TODO :... } -std::chrono::system_clock::time_point airtio::Interface::getCurrentTime() const { +std::chrono::system_clock::time_point river::Interface::getCurrentTime() const { std::unique_lock lock(m_mutex); // TODO :... return std::chrono::system_clock::time_point(); return std::chrono::system_clock::now(); } -void airtio::Interface::addVolumeGroup(const std::string& _name) { +void river::Interface::addVolumeGroup(const std::string& _name) { std::unique_lock lock(m_mutex); AIRTIO_DEBUG("addVolumeGroup(" << _name << ")"); - std::shared_ptr algo = m_process->get("volume"); + std::shared_ptr algo = m_process->get("volume"); if (algo == nullptr) { AIRTIO_ERROR("addVolumeGroup(" << _name << ") ==> no volume stage ... can not add it ..."); return; } if (_name == "FLOW") { // Local volume name - algo->addVolumeStage(std::make_shared(_name)); + algo->addVolumeStage(std::make_shared(_name)); } else { // get manager unique instance: - std::shared_ptr mng = airtio::io::Manager::getInstance(); + std::shared_ptr mng = river::io::Manager::getInstance(); algo->addVolumeStage(mng->getVolumeGroup(_name)); } } -void airtio::Interface::systemNewInputData(std::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk) { +void river::Interface::systemNewInputData(std::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk) { std::unique_lock lockProcess(m_mutex); m_process->push(_time, _data, _nbChunk); } -void airtio::Interface::systemNeedOutputData(std::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk, size_t _chunkSize) { +void river::Interface::systemNeedOutputData(std::chrono::system_clock::time_point _time, void* _data, size_t _nbChunk, size_t _chunkSize) { std::unique_lock lockProcess(m_mutex); m_process->pull(_time, _data, _nbChunk, _chunkSize); } -void airtio::Interface::systemVolumeChange() { +void river::Interface::systemVolumeChange() { std::unique_lock lockProcess(m_mutex); - std::shared_ptr algo = m_process->get("volume"); + std::shared_ptr algo = m_process->get("volume"); if (algo == nullptr) { return; } diff --git a/airtio/Interface.h b/river/Interface.h similarity index 91% rename from airtio/Interface.h rename to river/Interface.h index 2617873..19e4ee9 100644 --- a/airtio/Interface.h +++ b/river/Interface.h @@ -15,12 +15,12 @@ #include #include