[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_config = _config;
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;
m_name = _node->getName() + "__" + (_node->isInput()==true?"input":"output") + "__" + type + "__" + etk::to_string(uid++);
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,
const std::vector<audio::channel>& _map,
audio::format _format,
const std::string& _streamName,
const std::string& _options) {
const std::vector<audio::channel>& _map,
audio::format _format,
const std::string& _streamName,
const std::string& _options) {
// get global hardware interface:
std::shared_ptr<audio::river::io::Manager> manager = audio::river::io::Manager::getInstance();
if (manager == nullptr) {
@ -164,7 +164,7 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createOutput(flo
// create user iterface:
std::shared_ptr<audio::river::Interface> interface;
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);
// store it in a list (needed to apply some parameters).
m_listOpenInterface.push_back(interface);
@ -195,7 +195,7 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createInput(floa
// create user iterface:
std::shared_ptr<audio::river::Interface> interface;
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);
// store it in a list (needed to apply some parameters).
m_listOpenInterface.push_back(interface);
@ -227,7 +227,7 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createFeedback(f
// create user iterface:
std::shared_ptr<audio::river::Interface> interface;
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);
// store it in a list (needed to apply some parameters).
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) {
continue;
}
std::string groupName = tmpObject.getStringValue("group", "");
std::string groupName = tmpObject["group"].toString().get();
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["io"].toString().get("error");
#ifdef AUDIO_RIVER_BUILD_ORCHESTRA
if ( ioType == "input"
|| ioType == "output") {

View File

@ -111,7 +111,7 @@ std::vector<std::string> audio::river::io::Manager::getListStreamInput() {
for (auto &it : keys) {
const ejson::Object tmppp = m_config[it].toObject();
if (tmppp.exist() == true) {
std::string type = tmppp.getStringValue("io", "error");
std::string type = tmppp["io"].toString().get("error");
if ( type == "input"
|| type == "PAinput") {
output.push_back(it);
@ -128,7 +128,7 @@ std::vector<std::string> audio::river::io::Manager::getListStreamOutput() {
for (auto &it : keys) {
const ejson::Object tmppp = m_config[it].toObject();
if (tmppp.exist() == true) {
std::string type = tmppp.getStringValue("io", "error");
std::string type = tmppp["io"].toString().get("error");
if ( type == "output"
|| type == "PAoutput") {
output.push_back(it);
@ -145,7 +145,7 @@ std::vector<std::string> audio::river::io::Manager::getListStreamVirtual() {
for (auto &it : keys) {
const ejson::Object tmppp = m_config[it].toObject();
if (tmppp.exist() == true) {
std::string type = tmppp.getStringValue("io", "error");
std::string type = tmppp["io"].toString().get("error");
if ( type != "input"
&& type != "PAinput"
&& type != "output"
@ -165,7 +165,7 @@ std::vector<std::string> audio::river::io::Manager::getListStream() {
for (auto &it : keys) {
const ejson::Object tmppp = m_config[it].toObject();
if (tmppp.exist() == true) {
std::string type = tmppp.getStringValue("io", "error");
std::string type = tmppp["io"].toString().get("error");
if (type != "error") {
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();
if (tmpObject.exist() == true) {
//Check if it is in a group:
std::string groupName = tmpObject.getStringValue("group", "");
std::string groupName = tmpObject["group"].toString().get();
// get type : io
std::string ioType = tmpObject.getStringValue("io", "error");
std::string ioType = tmpObject["io"].toString().get("error");
if ( groupName != ""
&& ( ioType == "input"
|| 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)
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);
if ( interfaceType == "input"
|| interfaceType == "PAinput"
@ -45,12 +45,12 @@ audio::river::io::Node::Node(const std::string& _name, const ejson::Object& _con
m_isInput = false;
}
int32_t frequency = m_config.getNumberValue("frequency", 1);
int32_t frequency = m_config["frequency"].toNumber().get(1);
// 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);
// Get volume stage :
std::string volumeName = m_config.getStringValue("volume-name", "");
std::string volumeName = m_config["volume-name"].toString().get();
if (volumeName != "") {
RIVER_INFO("add node volume stage : '" << volumeName << "'");
// 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;
if (m_isInput == true) {
muxerDemuxerConfig = m_config.getStringValue("mux-demux-type", "int16");
muxerDemuxerConfig = m_config["mux-demux-type"].toString().get("int16");
} 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);
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());
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:
std::string type = tmppp.getStringValue("io", "error");
std::string type = tmppp["io"].toString().get("error");
if ( type != "input"
&& type != "feedback") {
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());
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:
std::string type = tmppp.getStringValue("io", "error");
std::string type = tmppp["io"].toString().get("error");
if ( type != "input"
&& type != "feedback") {
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) {
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
} else {
typeInterface = tmpObject.getStringValue("interface", audio::orchestra::type_undefined);
typeInterface = tmpObject["interface"].toString().get(audio::orchestra::type_undefined);
if (typeInterface == "auto") {
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 ...
m_interface.instanciate(typeInterface);
m_interface.setName(_name);
// TODO : Check return ...
std::string type = m_config.getStringValue("type", "int16");
std::string type = m_config["type"].toString().get("int16");
if (streamName == "") {
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() << ").");
}
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("hardwareFormat=" << hardwareFormat);