diff --git a/audio/river/Interface.cpp b/audio/river/Interface.cpp index e2d55d3..8e25c70 100644 --- a/audio/river/Interface.cpp +++ b/audio/river/Interface.cpp @@ -28,12 +28,12 @@ bool audio::river::Interface::init(float _freq, const std::vector& _map, audio::format _format, const std::shared_ptr& _node, - const std::shared_ptr& _config) { + const ejson::Object& _config) { std::vector map(_map); m_node = _node; m_config = _config; m_mode = audio::river::modeInterface_unknow; - std::string type = m_config->getStringValue("io", "error"); + std::string type = m_config.getStringValue("io", "error"); static int32_t uid=0; m_name = _node->getName() + "__" + (_node->isInput()==true?"input":"output") + "__" + type + "__" + etk::to_string(uid++); if (type == "output") { @@ -99,7 +99,7 @@ std::shared_ptr audio::river::Interface::create(float _ const std::vector& _map, audio::format _format, const std::shared_ptr& _node, - const std::shared_ptr& _config) { + const ejson::Object& _config) { std::shared_ptr out = std::shared_ptr(new audio::river::Interface()); out->init(_freq, _map, _format, _node, _config); return out; diff --git a/audio/river/Interface.h b/audio/river/Interface.h index 91079d8..53cfb95 100644 --- a/audio/river/Interface.h +++ b/audio/river/Interface.h @@ -66,7 +66,7 @@ namespace audio { const std::vector& _map, audio::format _format, const std::shared_ptr& _node, - const std::shared_ptr& _config); + const ejson::Object& _config); /** * @brief Factory of this interface (called by class audio::river::Manager) * @param[in] _freq Frequency. @@ -81,7 +81,7 @@ namespace audio { const std::vector& _map, audio::format _format, const std::shared_ptr& _node, - const std::shared_ptr& _config); + const ejson::Object& _config); public: /** * @brief Destructor @@ -89,7 +89,7 @@ namespace audio { virtual ~Interface(); protected: mutable std::recursive_mutex m_mutex; //!< Local mutex to protect data - std::shared_ptr m_config; //!< configuration set by the user. + ejson::Object m_config; //!< configuration set by the user. protected: enum modeInterface m_mode; //!< interface type (input/output/feedback) public: diff --git a/audio/river/Manager.cpp b/audio/river/Manager.cpp index 51ff1a7..4ce15ad 100644 --- a/audio/river/Manager.cpp +++ b/audio/river/Manager.cpp @@ -13,8 +13,6 @@ #include "debug.h" #include -#undef __class__ -#define __class__ "Manager" static std::mutex g_mutex; static std::vector > g_listOfAllManager; @@ -165,8 +163,8 @@ std::shared_ptr audio::river::Manager::createOutput(flo } // create user iterface: std::shared_ptr interface; - std::shared_ptr tmpOption = ejson::Object::create(_options); - tmpOption->addString("io", "output"); + ejson::Object tmpOption = ejson::Object(_options); + tmpOption.addString("io", "output"); interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption); // store it in a list (needed to apply some parameters). m_listOpenInterface.push_back(interface); @@ -196,8 +194,8 @@ std::shared_ptr audio::river::Manager::createInput(floa } // create user iterface: std::shared_ptr interface; - std::shared_ptr tmpOption = ejson::Object::create(_options); - tmpOption->addString("io", "input"); + ejson::Object tmpOption = ejson::Object(_options); + tmpOption.addString("io", "input"); interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption); // store it in a list (needed to apply some parameters). m_listOpenInterface.push_back(interface); @@ -228,8 +226,8 @@ std::shared_ptr audio::river::Manager::createFeedback(f } // create user iterface: std::shared_ptr interface; - std::shared_ptr tmpOption = ejson::Object::create(_options); - tmpOption->addString("io", "feedback"); + ejson::Object tmpOption = ejson::Object(_options); + tmpOption.addString("io", "feedback"); interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption); // store it in a list (needed to apply some parameters). m_listOpenInterface.push_back(interface); diff --git a/audio/river/io/Group.cpp b/audio/river/io/Group.cpp index 4e6df55..b49c5e7 100644 --- a/audio/river/io/Group.cpp +++ b/audio/river/io/Group.cpp @@ -18,15 +18,15 @@ void audio::river::io::Group::createFrom(const ejson::Document& _obj, const std::string& _name) { RIVER_INFO("Create Group[" << _name << "] (START) ___________________________"); for (size_t iii=0; iii<_obj.size(); ++iii) { - const std::shared_ptr tmpObject = _obj.getObject(_obj.getKey(iii)); - if (tmpObject == nullptr) { + const ejson::Object tmpObject = _obj[iii].toObject(); + if (tmpObject.exist() == false) { continue; } - std::string groupName = tmpObject->getStringValue("group", ""); + std::string groupName = tmpObject.getStringValue("group", ""); if (groupName == _name) { RIVER_INFO("Add element in Group[" << _name << "]: " << _obj.getKey(iii)); // get type : io - std::string ioType = tmpObject->getStringValue("io", "error"); + std::string ioType = tmpObject.getStringValue("io", "error"); #ifdef AUDIO_RIVER_BUILD_ORCHESTRA if ( ioType == "input" || ioType == "output") { diff --git a/audio/river/io/Manager.cpp b/audio/river/io/Manager.cpp index acca8ec..fb03640 100644 --- a/audio/river/io/Manager.cpp +++ b/audio/river/io/Manager.cpp @@ -108,13 +108,13 @@ std::vector audio::river::io::Manager::getListStreamInput() { std::unique_lock lock(m_mutex); std::vector output; std::vector keys = m_config.getKeys(); - for (size_t iii=0; iii tmppp = m_config.getObject(keys[iii]); - if (tmppp != nullptr) { - std::string type = tmppp->getStringValue("io", "error"); + for (auto &it : keys) { + const ejson::Object tmppp = m_config[it].toObject(); + if (tmppp.exist() == true) { + std::string type = tmppp.getStringValue("io", "error"); if ( type == "input" || type == "PAinput") { - output.push_back(keys[iii]); + output.push_back(it); } } } @@ -125,13 +125,13 @@ std::vector audio::river::io::Manager::getListStreamOutput() { std::unique_lock lock(m_mutex); std::vector output; std::vector keys = m_config.getKeys(); - for (size_t iii=0; iii tmppp = m_config.getObject(keys[iii]); - if (tmppp != nullptr) { - std::string type = tmppp->getStringValue("io", "error"); + for (auto &it : keys) { + const ejson::Object tmppp = m_config[it].toObject(); + if (tmppp.exist() == true) { + std::string type = tmppp.getStringValue("io", "error"); if ( type == "output" || type == "PAoutput") { - output.push_back(keys[iii]); + output.push_back(it); } } } @@ -142,16 +142,16 @@ std::vector audio::river::io::Manager::getListStreamVirtual() { std::unique_lock lock(m_mutex); std::vector output; std::vector keys = m_config.getKeys(); - for (size_t iii=0; iii tmppp = m_config.getObject(keys[iii]); - if (tmppp != nullptr) { - std::string type = tmppp->getStringValue("io", "error"); + for (auto &it : keys) { + const ejson::Object tmppp = m_config[it].toObject(); + if (tmppp.exist() == true) { + std::string type = tmppp.getStringValue("io", "error"); if ( type != "input" && type != "PAinput" && type != "output" && type != "PAoutput" && type != "error") { - output.push_back(keys[iii]); + output.push_back(it); } } } @@ -162,12 +162,12 @@ std::vector audio::river::io::Manager::getListStream() { std::unique_lock lock(m_mutex); std::vector output; std::vector keys = m_config.getKeys(); - for (size_t iii=0; iii tmppp = m_config.getObject(keys[iii]); - if (tmppp != nullptr) { - std::string type = tmppp->getStringValue("io", "error"); + for (auto &it : keys) { + const ejson::Object tmppp = m_config[it].toObject(); + if (tmppp.exist() == true) { + std::string type = tmppp.getStringValue("io", "error"); if (type != "error") { - output.push_back(keys[iii]); + output.push_back(it); } } } @@ -202,12 +202,12 @@ std::shared_ptr audio::river::io::Manager::getNode(const } RIVER_WARNING("Try create a new one : " << _name); // check if the node can be open : - const std::shared_ptr tmpObject = m_config.getObject(_name); - if (tmpObject != nullptr) { + const ejson::Object tmpObject = m_config[_name].toObject(); + if (tmpObject.exist() == true) { //Check if it is in a group: - std::string groupName = tmpObject->getStringValue("group", ""); + std::string groupName = tmpObject.getStringValue("group", ""); // get type : io - std::string ioType = tmpObject->getStringValue("io", "error"); + std::string ioType = tmpObject.getStringValue("io", "error"); if ( groupName != "" && ( ioType == "input" || ioType == "output" diff --git a/audio/river/io/Node.cpp b/audio/river/io/Node.cpp index 3832873..6b98c6c 100644 --- a/audio/river/io/Node.cpp +++ b/audio/river/io/Node.cpp @@ -11,7 +11,7 @@ #define __class__ "io::Node" -audio::river::io::Node::Node(const std::string& _name, const std::shared_ptr& _config) : +audio::river::io::Node::Node(const std::string& _name, const ejson::Object& _config) : m_config(_config), m_name(_name), m_isInput(false) { @@ -34,7 +34,7 @@ audio::river::io::Node::Node(const std::string& _name, const std::shared_ptrgetStringValue("io"); + std::string interfaceType = m_config.getStringValue("io"); RIVER_INFO("interfaceType=" << interfaceType); if ( interfaceType == "input" || interfaceType == "PAinput" @@ -45,12 +45,12 @@ audio::river::io::Node::Node(const std::string& _name, const std::shared_ptrgetNumberValue("frequency", 1); + int32_t frequency = m_config.getNumberValue("frequency", 1); // Get audio format type: - std::string type = m_config->getStringValue("type", "int16"); + std::string type = m_config.getStringValue("type", "int16"); enum audio::format formatType = audio::getFormatFromString(type); // Get volume stage : - std::string volumeName = m_config->getStringValue("volume-name", ""); + std::string volumeName = m_config.getStringValue("volume-name", ""); if (volumeName != "") { RIVER_INFO("add node volume stage : '" << volumeName << "'"); // use global manager for volume ... @@ -58,15 +58,15 @@ audio::river::io::Node::Node(const std::string& _name, const std::shared_ptr map; - const std::shared_ptr listChannelMap = m_config->getArray("channel-map"); - if ( listChannelMap == nullptr - || listChannelMap->size() == 0) { + const ejson::Array listChannelMap = m_config["channel-map"].toArray(); + if ( listChannelMap.exist() == false + || listChannelMap.size() == 0) { // set default channel property: map.push_back(audio::channel_frontLeft); map.push_back(audio::channel_frontRight); } else { - for (size_t iii=0; iiisize(); ++iii) { - std::string value = listChannelMap->getStringValue(iii); + for (auto it : listChannelMap) { + std::string value = it.toString().get(); map.push_back(audio::getChannelFromString(value)); } } @@ -75,9 +75,9 @@ audio::river::io::Node::Node(const std::string& _name, const std::shared_ptrgetStringValue("mux-demux-type", "int16"); + muxerDemuxerConfig = m_config.getStringValue("mux-demux-type", "int16"); } else { - muxerDemuxerConfig = m_config->getStringValue("mux-demux-type", "int16-on-int32"); + muxerDemuxerConfig = m_config.getStringValue("mux-demux-type", "int16-on-int32"); } enum audio::format muxerFormatType = audio::getFormatFromString(muxerDemuxerConfig); if (m_isInput == true) { diff --git a/audio/river/io/Node.h b/audio/river/io/Node.h index 8189f73..589a7bf 100644 --- a/audio/river/io/Node.h +++ b/audio/river/io/Node.h @@ -39,7 +39,7 @@ namespace audio { * @param[in] _name Name of the node. * @param[in] _config Configuration of the node. */ - Node(const std::string& _name, const std::shared_ptr& _config); + Node(const std::string& _name, const ejson::Object& _config); public: /** * @brief Destructor @@ -55,7 +55,7 @@ namespace audio { }; protected: mutable std::mutex m_mutex; //!< prevent open/close/write/read access that is multi-threaded. - std::shared_ptr m_config; //!< configuration description. + const ejson::Object m_config; //!< configuration description. protected: audio::drain::Process m_process; //!< Low level algorithms public: diff --git a/audio/river/io/NodeAEC.cpp b/audio/river/io/NodeAEC.cpp index bf4147b..eb8f17e 100644 --- a/audio/river/io/NodeAEC.cpp +++ b/audio/river/io/NodeAEC.cpp @@ -13,7 +13,7 @@ #undef __class__ #define __class__ "io::NodeAEC" -std::shared_ptr audio::river::io::NodeAEC::create(const std::string& _name, const std::shared_ptr& _config) { +std::shared_ptr audio::river::io::NodeAEC::create(const std::string& _name, const ejson::Object& _config) { return std::shared_ptr(new audio::river::io::NodeAEC(_name, _config)); } @@ -23,16 +23,16 @@ std::shared_ptr audio::river::io::NodeAEC::createInput( const std::string& _objectName, const std::string& _name) { // check if the output exist - const std::shared_ptr tmppp = m_config->getObject(_objectName); - if (tmppp == nullptr) { - RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config->getKeys()); + const ejson::Object tmppp = m_config[_objectName].toObject(); + if (tmppp.exist() == false) { + RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config.getKeys()); return std::shared_ptr(); } - std::string streamName = tmppp->getStringValue("map-on", "error"); + std::string streamName = tmppp.getStringValue("map-on", "error"); - m_nbChunk = m_config->getNumberValue("nb-chunk", 1024); + m_nbChunk = m_config.getNumberValue("nb-chunk", 1024); // check if it is an Output: - std::string type = tmppp->getStringValue("io", "error"); + std::string type = tmppp.getStringValue("io", "error"); if ( type != "input" && type != "feedback") { RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type); @@ -52,7 +52,7 @@ std::shared_ptr audio::river::io::NodeAEC::createInput( } -audio::river::io::NodeAEC::NodeAEC(const std::string& _name, const std::shared_ptr& _config) : +audio::river::io::NodeAEC::NodeAEC(const std::string& _name, const ejson::Object& _config) : Node(_name, _config), m_P_attaqueTime(1), m_P_releaseTime(100), diff --git a/audio/river/io/NodeAEC.h b/audio/river/io/NodeAEC.h index 0577ba6..ad88890 100644 --- a/audio/river/io/NodeAEC.h +++ b/audio/river/io/NodeAEC.h @@ -18,14 +18,14 @@ namespace audio { /** * @brief Constructor */ - NodeAEC(const std::string& _name, const std::shared_ptr& _config); + NodeAEC(const std::string& _name, const ejson::Object& _config); public: /** * @brief Factory of this Virtual Node. * @param[in] _name Name of the node. * @param[in] _config Configuration of the node. */ - static std::shared_ptr create(const std::string& _name, const std::shared_ptr& _config); + static std::shared_ptr create(const std::string& _name, const ejson::Object& _config); /** * @brief Destructor */ diff --git a/audio/river/io/NodeFile.cpp b/audio/river/io/NodeFile.cpp index aea25b1..5196bf9 100644 --- a/audio/river/io/NodeFile.cpp +++ b/audio/river/io/NodeFile.cpp @@ -37,11 +37,11 @@ int32_t audio::river::io::NodeFile::playbackCallback(void* _outputBuffer, -std::shared_ptr audio::river::io::NodeFile::create(const std::string& _name, const std::shared_ptr& _config) { +std::shared_ptr audio::river::io::NodeFile::create(const std::string& _name, const ejson::Object& _config) { return std::shared_ptr(new audio::river::io::NodeFile(_name, _config)); } -audio::river::io::NodeFile::NodeFile(const std::string& _name, const std::shared_ptr& _config) : +audio::river::io::NodeFile::NodeFile(const std::string& _name, const ejson::Object& _config) : Node(_name, _config) { audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat(); audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat(); @@ -54,23 +54,23 @@ audio::river::io::NodeFile::NodeFile(const std::string& _name, const std::shared */ std::string typeInterface = audio::orchestra::type_undefined; std::string streamName = "default"; - const std::shared_ptr tmpObject = m_config->getObject("map-on"); - if (tmpObject == nullptr) { + const ejson::Object tmpObject = m_config["map-on"].toObject(); + if (tmpObject.exist() == false) { RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'"); } else { - typeInterface = tmpObject->getStringValue("interface", audio::orchestra::type_undefined); + typeInterface = tmpObject.getStringValue("interface", audio::orchestra::type_undefined); if (typeInterface == "auto") { typeInterface = audio::orchestra::type_undefined; } - streamName = tmpObject->getStringValue("name", "default"); + streamName = tmpObject.getStringValue("name", "default"); } - int32_t nbChunk = m_config->getNumberValue("nb-chunk", 1024); + int32_t nbChunk = m_config.getNumberValue("nb-chunk", 1024); // intanciate specific API ... m_interface.instanciate(typeInterface); m_interface.setName(_name); // TODO : Check return ... - std::string type = m_config->getStringValue("type", "int16"); + std::string type = m_config.getStringValue("type", "int16"); if (streamName == "") { streamName = "default"; } diff --git a/audio/river/io/NodeFile.h b/audio/river/io/NodeFile.h index bd5eb78..beca6a5 100644 --- a/audio/river/io/NodeFile.h +++ b/audio/river/io/NodeFile.h @@ -24,9 +24,9 @@ namespace audio { /** * @brief Constructor */ - NodeFile(const std::string& _name, const std::shared_ptr& _config); + NodeFile(const std::string& _name, const ejson::Object& _config); public: - static std::shared_ptr create(const std::string& _name, const std::shared_ptr& _config); + static std::shared_ptr create(const std::string& _name, const ejson::Object& _config); /** * @brief Destructor */ diff --git a/audio/river/io/NodeMuxer.cpp b/audio/river/io/NodeMuxer.cpp index b9b798f..7612c08 100644 --- a/audio/river/io/NodeMuxer.cpp +++ b/audio/river/io/NodeMuxer.cpp @@ -13,7 +13,7 @@ #undef __class__ #define __class__ "io::NodeMuxer" -std::shared_ptr audio::river::io::NodeMuxer::create(const std::string& _name, const std::shared_ptr& _config) { +std::shared_ptr audio::river::io::NodeMuxer::create(const std::string& _name, const ejson::Object& _config) { return std::shared_ptr(new audio::river::io::NodeMuxer(_name, _config)); } @@ -23,16 +23,16 @@ std::shared_ptr audio::river::io::NodeMuxer::createInpu const std::string& _objectName, const std::string& _name) { // check if the output exist - const std::shared_ptr tmppp = m_config->getObject(_objectName); - if (tmppp == nullptr) { - RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config->getKeys()); + const ejson::Object tmppp = m_config[_objectName].toObject(); + if (tmppp.exist() == false) { + RIVER_ERROR("can not open a non existance virtual interface: '" << _objectName << "' not present in : " << m_config.getKeys()); return std::shared_ptr(); } - std::string streamName = tmppp->getStringValue("map-on", "error"); + std::string streamName = tmppp.getStringValue("map-on", "error"); // check if it is an Output: - std::string type = tmppp->getStringValue("io", "error"); + std::string type = tmppp.getStringValue("io", "error"); if ( type != "input" && type != "feedback") { RIVER_ERROR("can not open in output a virtual interface: '" << streamName << "' configured has : " << type); @@ -52,7 +52,7 @@ std::shared_ptr audio::river::io::NodeMuxer::createInpu } -audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std::shared_ptr& _config) : +audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const ejson::Object& _config) : Node(_name, _config) { audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat(); audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat(); @@ -88,14 +88,14 @@ audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std::shar RIVER_ERROR("Can not opne virtual device ... map-on-input-1 in " << _name); return; } - std::shared_ptr listChannelMap = m_config->getArray("input-1-remap"); - if ( listChannelMap == nullptr - || listChannelMap->size() == 0) { + const ejson::Array listChannelMap = m_config["input-1-remap"].toArray(); + if ( listChannelMap.exist() == false + || listChannelMap.size() == 0) { m_mapInput1 = m_interfaceInput1->getInterfaceFormat().getMap(); } else { m_mapInput1.clear(); - for (size_t iii=0; iiisize(); ++iii) { - std::string value = listChannelMap->getStringValue(iii); + for (const auto it : listChannelMap) { + std::string value = it.toString().get(); m_mapInput1.push_back(audio::getChannelFromString(value)); } if (m_mapInput1.size() != m_interfaceInput1->getInterfaceFormat().getMap().size()) { @@ -114,14 +114,14 @@ audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std::shar RIVER_ERROR("Can not opne virtual device ... map-on-input-2 in " << _name); return; } - listChannelMap = m_config->getArray("input-2-remap"); - if ( listChannelMap == nullptr - || listChannelMap->size() == 0) { + const ejson::Array listChannelMap2 = m_config["input-2-remap"].toArray(); + if ( listChannelMap2.exist() == false + || listChannelMap2.size() == 0) { m_mapInput2 = m_interfaceInput2->getInterfaceFormat().getMap(); } else { m_mapInput2.clear(); - for (size_t iii=0; iiisize(); ++iii) { - std::string value = listChannelMap->getStringValue(iii); + for (const auto it : listChannelMap2) { + std::string value = it.toString().get(); m_mapInput2.push_back(audio::getChannelFromString(value)); } if (m_mapInput2.size() != m_interfaceInput2->getInterfaceFormat().getMap().size()) { diff --git a/audio/river/io/NodeMuxer.h b/audio/river/io/NodeMuxer.h index 8fb1a67..9499661 100644 --- a/audio/river/io/NodeMuxer.h +++ b/audio/river/io/NodeMuxer.h @@ -18,9 +18,9 @@ namespace audio { /** * @brief Constructor */ - NodeMuxer(const std::string& _name, const std::shared_ptr& _config); + NodeMuxer(const std::string& _name, const ejson::Object& _config); public: - static std::shared_ptr create(const std::string& _name, const std::shared_ptr& _config); + static std::shared_ptr create(const std::string& _name, const ejson::Object& _config); /** * @brief Destructor */ diff --git a/audio/river/io/NodeOrchestra.cpp b/audio/river/io/NodeOrchestra.cpp index 9eba0db..469ead2 100644 --- a/audio/river/io/NodeOrchestra.cpp +++ b/audio/river/io/NodeOrchestra.cpp @@ -37,11 +37,11 @@ int32_t audio::river::io::NodeOrchestra::playbackCallback(void* _outputBuffer, -std::shared_ptr audio::river::io::NodeOrchestra::create(const std::string& _name, const std::shared_ptr& _config) { +std::shared_ptr audio::river::io::NodeOrchestra::create(const std::string& _name, const ejson::Object& _config) { return std::shared_ptr(new audio::river::io::NodeOrchestra(_name, _config)); } -audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const std::shared_ptr& _config) : +audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const ejson::Object& _config) : Node(_name, _config) { audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat(); audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat(); @@ -54,23 +54,23 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s */ std::string typeInterface = audio::orchestra::type_undefined; std::string streamName = "default"; - const std::shared_ptr tmpObject = m_config->getObject("map-on"); - if (tmpObject == nullptr) { + const ejson::Object tmpObject = m_config["map-on"].toObject(); + if (tmpObject.exist() == false) { RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'"); } else { - typeInterface = tmpObject->getStringValue("interface", audio::orchestra::type_undefined); + typeInterface = tmpObject.getStringValue("interface", audio::orchestra::type_undefined); if (typeInterface == "auto") { typeInterface = audio::orchestra::type_undefined; } - streamName = tmpObject->getStringValue("name", "default"); + streamName = tmpObject.getStringValue("name", "default"); } - int32_t nbChunk = m_config->getNumberValue("nb-chunk", 1024); + int32_t nbChunk = m_config.getNumberValue("nb-chunk", 1024); // intanciate specific API ... m_interface.instanciate(typeInterface); m_interface.setName(_name); // TODO : Check return ... - std::string type = m_config->getStringValue("type", "int16"); + std::string type = m_config.getStringValue("type", "int16"); if (streamName == "") { streamName = "default"; } @@ -189,7 +189,7 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const s RIVER_CRITICAL("Can not open hardware device with more channel (" << params.nChannels << ") that is autorized by hardware (" << m_info.channels.size() << ")."); } audio::orchestra::StreamOptions option; - etk::from_string(option.mode, tmpObject->getStringValue("timestamp-mode", "soft")); + etk::from_string(option.mode, tmpObject.getStringValue("timestamp-mode", "soft")); RIVER_DEBUG("interfaceFormat=" << interfaceFormat); RIVER_DEBUG("hardwareFormat=" << hardwareFormat); diff --git a/audio/river/io/NodeOrchestra.h b/audio/river/io/NodeOrchestra.h index 535a582..6cbf5d8 100644 --- a/audio/river/io/NodeOrchestra.h +++ b/audio/river/io/NodeOrchestra.h @@ -24,9 +24,9 @@ namespace audio { /** * @brief Constructor */ - NodeOrchestra(const std::string& _name, const std::shared_ptr& _config); + NodeOrchestra(const std::string& _name, const ejson::Object& _config); public: - static std::shared_ptr create(const std::string& _name, const std::shared_ptr& _config); + static std::shared_ptr create(const std::string& _name, const ejson::Object& _config); /** * @brief Destructor */ diff --git a/audio/river/io/NodePortAudio.cpp b/audio/river/io/NodePortAudio.cpp index c6658ac..e808f93 100644 --- a/audio/river/io/NodePortAudio.cpp +++ b/audio/river/io/NodePortAudio.cpp @@ -56,11 +56,11 @@ int32_t audio::river::io::NodePortAudio::duplexCallback(const void* _inputBuffer } -std::shared_ptr audio::river::io::NodePortAudio::create(const std::string& _name, const std::shared_ptr& _config) { +std::shared_ptr audio::river::io::NodePortAudio::create(const std::string& _name, const ejson::Object& _config) { return std::shared_ptr(new audio::river::io::NodePortAudio(_name, _config)); } -audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const std::shared_ptr& _config) : +audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const ejson::Object& _config) : Node(_name, _config) { audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat(); audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat(); @@ -72,14 +72,14 @@ audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const s nb-chunk:1024 # number of chunk to open device (create the latency anf the frequency to call user) */ std::string streamName = "default"; - const std::shared_ptr tmpObject = m_config->getObject("map-on"); - if (tmpObject == nullptr) { + const ejson::Object tmpObject = m_config["map-on"].toObject(); + if (tmpObject.exist() == false) { RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'"); } else { - std::string value = tmpObject->getStringValue("interface", "default"); - streamName = tmpObject->getStringValue("name", "default"); + std::string value = tmpObject.getStringValue("interface", "default"); + streamName = tmpObject.getStringValue("name", "default"); } - int32_t nbChunk = m_config->getNumberValue("nb-chunk", 1024); + int32_t nbChunk = m_config.getNumberValue("nb-chunk", 1024); PaError err = 0; if (m_isInput == true) { diff --git a/audio/river/io/NodePortAudio.h b/audio/river/io/NodePortAudio.h index 10fa47a..dd3c52a 100644 --- a/audio/river/io/NodePortAudio.h +++ b/audio/river/io/NodePortAudio.h @@ -15,15 +15,15 @@ namespace audio { namespace river { namespace io { class Manager; - //! @not-in-doc + //! @not_in_doc class NodePortAudio : public Node { protected: /** * @brief Constructor */ - NodePortAudio(const std::string& _name, const std::shared_ptr& _config); + NodePortAudio(const std::string& _name, const ejson::Object& _config); public: - static std::shared_ptr create(const std::string& _name, const std::shared_ptr& _config); + static std::shared_ptr create(const std::string& _name, const ejson::Object& _config); /** * @brief Destructor */ diff --git a/sample/write/main.cpp b/sample/write/main.cpp index 8a8ca0f..4216c79 100644 --- a/sample/write/main.cpp +++ b/sample/write/main.cpp @@ -16,36 +16,41 @@ static const std::string configurationRiver = " speaker:{\n" " io:'output',\n" " map-on:{\n" - " interface:'auto',\n" - " name:'default',\n" + " interface:'alsa',\n" + " name:'hw:2,0',\n" " },\n" " frequency:0,\n" + //" channel-map:['front-left', 'front-right', 'rear-left', 'rear-right'],\n" " channel-map:['front-left', 'front-right'],\n" - " type:'auto',\n" + " type:'int32',\n" " nb-chunk:1024,\n" " volume-name:'MASTER'\n" " }\n" "}\n"; +static const int32_t nbChannelMax=8; + void onDataNeeded(void* _data, const audio::Time& _time, size_t _nbChunk, enum audio::format _format, uint32_t _frequency, const std::vector& _map) { - static double phase = 0; + static double phase[8] = {0,0,0,0,0,0,0,0}; + if (_format != audio::format_int16) { std::cout << "[ERROR] call wrong type ... (need int16_t)" << std::endl; } + //std::cout << "Map " << _map << std::endl; int16_t* data = static_cast(_data); - double baseCycle = 2.0*M_PI/(double)48000 * (double)550; + double baseCycle = 2.0*M_PI/double(48000) * double(440); for (int32_t iii=0; iii<_nbChunk; iii++) { for (int32_t jjj=0; jjj<_map.size(); jjj++) { - data[_map.size()*iii+jjj] = cos(phase) * 30000; - } - phase += baseCycle; - if (phase >= 2*M_PI) { - phase -= 2*M_PI; + data[_map.size()*iii+jjj] = cos(phase[jjj]) * 30000; + phase[jjj] += baseCycle*jjj; + if (phase[jjj] >= 2*M_PI) { + phase[jjj] -= 2*M_PI; + } } } }