[DEV] update to ne new ejson API (remove helper)

This commit is contained in:
Edouard DUPIN 2016-04-28 23:46:12 +02:00
parent aa5df52e14
commit 07a56e29ae
8 changed files with 32 additions and 32 deletions

View File

@ -33,7 +33,7 @@ bool audio::river::Interface::init(float _freq,
m_node = _node; m_node = _node;
m_config = _config; m_config = _config;
m_mode = audio::river::modeInterface_unknow; m_mode = audio::river::modeInterface_unknow;
std::string type = m_config.getStringValue("io", "error"); std::string type = m_config["io"].toString().get("error");
static int32_t uid=0; static int32_t uid=0;
m_name = _node->getName() + "__" + (_node->isInput()==true?"input":"output") + "__" + type + "__" + etk::to_string(uid++); m_name = _node->getName() + "__" + (_node->isInput()==true?"input":"output") + "__" + type + "__" + etk::to_string(uid++);
if (type == "output") { if (type == "output") {

View File

@ -141,10 +141,10 @@ bool audio::river::Manager::getMute(const std::string& _volumeName) const {
} }
std::shared_ptr<audio::river::Interface> audio::river::Manager::createOutput(float _freq, std::shared_ptr<audio::river::Interface> audio::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& _options) { const std::string& _options) {
// get global hardware interface: // get global hardware interface:
std::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance(); std::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
if (manager == nullptr) { if (manager == nullptr) {
@ -164,7 +164,7 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createOutput(flo
// create user iterface: // create user iterface:
std::shared_ptr<audio::river::Interface> interface; std::shared_ptr<audio::river::Interface> interface;
ejson::Object tmpOption = ejson::Object(_options); ejson::Object tmpOption = ejson::Object(_options);
tmpOption.addString("io", "output"); tmpOption.add("io", ejson::String("output"));
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption); interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
// 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);
@ -195,7 +195,7 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createInput(floa
// create user iterface: // create user iterface:
std::shared_ptr<audio::river::Interface> interface; std::shared_ptr<audio::river::Interface> interface;
ejson::Object tmpOption = ejson::Object(_options); ejson::Object tmpOption = ejson::Object(_options);
tmpOption.addString("io", "input"); tmpOption.add("io", ejson::String("input"));
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption); interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
// 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);
@ -227,7 +227,7 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createFeedback(f
// create user iterface: // create user iterface:
std::shared_ptr<audio::river::Interface> interface; std::shared_ptr<audio::river::Interface> interface;
ejson::Object tmpOption = ejson::Object(_options); ejson::Object tmpOption = ejson::Object(_options);
tmpOption.addString("io", "feedback"); tmpOption.add("io", ejson::String("feedback"));
interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption); interface = audio::river::Interface::create(_freq, _map, _format, node, tmpOption);
// 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);

View File

@ -22,11 +22,11 @@ void audio::river::io::Group::createFrom(const ejson::Document& _obj, const std:
if (tmpObject.exist() == false) { if (tmpObject.exist() == false) {
continue; continue;
} }
std::string groupName = tmpObject.getStringValue("group", ""); std::string groupName = tmpObject["group"].toString().get();
if (groupName == _name) { if (groupName == _name) {
RIVER_INFO("Add element in Group[" << _name << "]: " << _obj.getKey(iii)); RIVER_INFO("Add element in Group[" << _name << "]: " << _obj.getKey(iii));
// get type : io // get type : io
std::string ioType = tmpObject.getStringValue("io", "error"); std::string ioType = tmpObject["io"].toString().get("error");
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA #ifdef AUDIO_RIVER_BUILD_ORCHESTRA
if ( ioType == "input" if ( ioType == "input"
|| ioType == "output") { || ioType == "output") {

View File

@ -111,7 +111,7 @@ std::vector<std::string> audio::river::io::Manager::getListStreamInput() {
for (auto &it : keys) { for (auto &it : keys) {
const ejson::Object tmppp = m_config[it].toObject(); const ejson::Object tmppp = m_config[it].toObject();
if (tmppp.exist() == true) { if (tmppp.exist() == true) {
std::string type = tmppp.getStringValue("io", "error"); std::string type = tmppp["io"].toString().get("error");
if ( type == "input" if ( type == "input"
|| type == "PAinput") { || type == "PAinput") {
output.push_back(it); output.push_back(it);
@ -128,7 +128,7 @@ std::vector<std::string> audio::river::io::Manager::getListStreamOutput() {
for (auto &it : keys) { for (auto &it : keys) {
const ejson::Object tmppp = m_config[it].toObject(); const ejson::Object tmppp = m_config[it].toObject();
if (tmppp.exist() == true) { if (tmppp.exist() == true) {
std::string type = tmppp.getStringValue("io", "error"); std::string type = tmppp["io"].toString().get("error");
if ( type == "output" if ( type == "output"
|| type == "PAoutput") { || type == "PAoutput") {
output.push_back(it); output.push_back(it);
@ -145,7 +145,7 @@ std::vector<std::string> audio::river::io::Manager::getListStreamVirtual() {
for (auto &it : keys) { for (auto &it : keys) {
const ejson::Object tmppp = m_config[it].toObject(); const ejson::Object tmppp = m_config[it].toObject();
if (tmppp.exist() == true) { if (tmppp.exist() == true) {
std::string type = tmppp.getStringValue("io", "error"); std::string type = tmppp["io"].toString().get("error");
if ( type != "input" if ( type != "input"
&& type != "PAinput" && type != "PAinput"
&& type != "output" && type != "output"
@ -165,7 +165,7 @@ std::vector<std::string> audio::river::io::Manager::getListStream() {
for (auto &it : keys) { for (auto &it : keys) {
const ejson::Object tmppp = m_config[it].toObject(); const ejson::Object tmppp = m_config[it].toObject();
if (tmppp.exist() == true) { if (tmppp.exist() == true) {
std::string type = tmppp.getStringValue("io", "error"); std::string type = tmppp["io"].toString().get("error");
if (type != "error") { if (type != "error") {
output.push_back(it); output.push_back(it);
} }
@ -205,9 +205,9 @@ std::shared_ptr<audio::river::io::Node> audio::river::io::Manager::getNode(const
const ejson::Object tmpObject = m_config[_name].toObject(); const ejson::Object tmpObject = m_config[_name].toObject();
if (tmpObject.exist() == true) { if (tmpObject.exist() == true) {
//Check if it is in a group: //Check if it is in a group:
std::string groupName = tmpObject.getStringValue("group", ""); std::string groupName = tmpObject["group"].toString().get();
// get type : io // get type : io
std::string ioType = tmpObject.getStringValue("io", "error"); std::string ioType = tmpObject["io"].toString().get("error");
if ( groupName != "" if ( groupName != ""
&& ( ioType == "input" && ( ioType == "input"
|| ioType == "output" || ioType == "output"

View File

@ -34,7 +34,7 @@ audio::river::io::Node::Node(const std::string& _name, const ejson::Object& _con
# muxer/demuxer format type (int8-on-int16, int16-on-int32, int24-on-int32, int32-on-int64, float) # muxer/demuxer format type (int8-on-int16, int16-on-int32, int24-on-int32, int32-on-int64, float)
mux-demux-type:"int16_on_int32", mux-demux-type:"int16_on_int32",
*/ */
std::string interfaceType = m_config.getStringValue("io"); std::string interfaceType = m_config["io"].toString().get();
RIVER_INFO("interfaceType=" << interfaceType); RIVER_INFO("interfaceType=" << interfaceType);
if ( interfaceType == "input" if ( interfaceType == "input"
|| interfaceType == "PAinput" || interfaceType == "PAinput"
@ -45,12 +45,12 @@ audio::river::io::Node::Node(const std::string& _name, const ejson::Object& _con
m_isInput = false; m_isInput = false;
} }
int32_t frequency = m_config.getNumberValue("frequency", 1); int32_t frequency = m_config["frequency"].toNumber().get(1);
// Get audio format type: // Get audio format type:
std::string type = m_config.getStringValue("type", "int16"); std::string type = m_config["type"].toString().get("int16");
enum audio::format formatType = audio::getFormatFromString(type); enum audio::format formatType = audio::getFormatFromString(type);
// Get volume stage : // Get volume stage :
std::string volumeName = m_config.getStringValue("volume-name", ""); std::string volumeName = m_config["volume-name"].toString().get();
if (volumeName != "") { if (volumeName != "") {
RIVER_INFO("add node volume stage : '" << volumeName << "'"); RIVER_INFO("add node volume stage : '" << volumeName << "'");
// use global manager for volume ... // use global manager for volume ...
@ -75,9 +75,9 @@ audio::river::io::Node::Node(const std::string& _name, const ejson::Object& _con
std::string muxerDemuxerConfig; std::string muxerDemuxerConfig;
if (m_isInput == true) { if (m_isInput == true) {
muxerDemuxerConfig = m_config.getStringValue("mux-demux-type", "int16"); muxerDemuxerConfig = m_config["mux-demux-type"].toString().get("int16");
} else { } else {
muxerDemuxerConfig = m_config.getStringValue("mux-demux-type", "int16-on-int32"); muxerDemuxerConfig = m_config["mux-demux-type"].toString().get("int16-on-int32");
} }
enum audio::format muxerFormatType = audio::getFormatFromString(muxerDemuxerConfig); enum audio::format muxerFormatType = audio::getFormatFromString(muxerDemuxerConfig);
if (m_isInput == true) { if (m_isInput == true) {

View File

@ -28,11 +28,11 @@ std::shared_ptr<audio::river::Interface> audio::river::io::NodeAEC::createInput(
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 std::shared_ptr<audio::river::Interface>(); return std::shared_ptr<audio::river::Interface>();
} }
std::string streamName = tmppp.getStringValue("map-on", "error"); std::string streamName = tmppp["map-on"].toString().get("error");
m_nbChunk = m_config.getNumberValue("nb-chunk", 1024); m_nbChunk = m_config["nb-chunk"].toNumber().get(1024);
// check if it is an Output: // check if it is an Output:
std::string type = tmppp.getStringValue("io", "error"); std::string type = tmppp["io"].toString().get("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);

View File

@ -28,11 +28,11 @@ std::shared_ptr<audio::river::Interface> audio::river::io::NodeMuxer::createInpu
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 std::shared_ptr<audio::river::Interface>(); return std::shared_ptr<audio::river::Interface>();
} }
std::string streamName = tmppp.getStringValue("map-on", "error"); std::string streamName = tmppp["map-on"].toString().get("error");
// check if it is an Output: // check if it is an Output:
std::string type = tmppp.getStringValue("io", "error"); std::string type = tmppp["io"].toString().get("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);

View File

@ -58,19 +58,19 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const e
if (tmpObject.exist() == false) { if (tmpObject.exist() == false) {
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'"); RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
} else { } else {
typeInterface = tmpObject.getStringValue("interface", audio::orchestra::type_undefined); typeInterface = tmpObject["interface"].toString().get(audio::orchestra::type_undefined);
if (typeInterface == "auto") { if (typeInterface == "auto") {
typeInterface = audio::orchestra::type_undefined; typeInterface = audio::orchestra::type_undefined;
} }
streamName = tmpObject.getStringValue("name", "default"); streamName = tmpObject["name"].toString().get("default");
} }
int32_t nbChunk = m_config.getNumberValue("nb-chunk", 1024); int32_t nbChunk = m_config["nb-chunk"].toNumber().get(1024);
// intanciate specific API ... // intanciate specific API ...
m_interface.instanciate(typeInterface); m_interface.instanciate(typeInterface);
m_interface.setName(_name); m_interface.setName(_name);
// TODO : Check return ... // TODO : Check return ...
std::string type = m_config.getStringValue("type", "int16"); std::string type = m_config["type"].toString().get("int16");
if (streamName == "") { if (streamName == "") {
streamName = "default"; streamName = "default";
} }
@ -189,7 +189,7 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const e
RIVER_CRITICAL("Can not open hardware device with more channel (" << params.nChannels << ") that is autorized by hardware (" << m_info.channels.size() << ")."); 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; audio::orchestra::StreamOptions option;
etk::from_string(option.mode, tmpObject.getStringValue("timestamp-mode", "soft")); etk::from_string(option.mode, tmpObject["timestamp-mode"].toString().get("soft"));
RIVER_DEBUG("interfaceFormat=" << interfaceFormat); RIVER_DEBUG("interfaceFormat=" << interfaceFormat);
RIVER_DEBUG("hardwareFormat=" << hardwareFormat); RIVER_DEBUG("hardwareFormat=" << hardwareFormat);