[DEV] update new ejson interface

This commit is contained in:
Edouard DUPIN 2016-04-20 21:19:11 +02:00
parent c9bb77e8d6
commit aa5df52e14
18 changed files with 129 additions and 126 deletions

View File

@ -28,12 +28,12 @@ bool audio::river::Interface::init(float _freq,
const std::vector<audio::channel>& _map,
audio::format _format,
const std::shared_ptr<audio::river::io::Node>& _node,
const std::shared_ptr<const ejson::Object>& _config) {
const ejson::Object& _config) {
std::vector<audio::channel> 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> audio::river::Interface::create(float _
const std::vector<audio::channel>& _map,
audio::format _format,
const std::shared_ptr<audio::river::io::Node>& _node,
const std::shared_ptr<const ejson::Object>& _config) {
const ejson::Object& _config) {
std::shared_ptr<audio::river::Interface> out = std::shared_ptr<audio::river::Interface>(new audio::river::Interface());
out->init(_freq, _map, _format, _node, _config);
return out;

View File

@ -66,7 +66,7 @@ namespace audio {
const std::vector<audio::channel>& _map,
audio::format _format,
const std::shared_ptr<audio::river::io::Node>& _node,
const std::shared_ptr<const ejson::Object>& _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<audio::channel>& _map,
audio::format _format,
const std::shared_ptr<audio::river::io::Node>& _node,
const std::shared_ptr<const ejson::Object>& _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<const ejson::Object> 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:

View File

@ -13,8 +13,6 @@
#include "debug.h"
#include <ejson/ejson.h>
#undef __class__
#define __class__ "Manager"
static std::mutex g_mutex;
static std::vector<std::weak_ptr<audio::river::Manager> > g_listOfAllManager;
@ -165,8 +163,8 @@ std::shared_ptr<audio::river::Interface> audio::river::Manager::createOutput(flo
}
// create user iterface:
std::shared_ptr<audio::river::Interface> interface;
std::shared_ptr<ejson::Object> 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::Interface> audio::river::Manager::createInput(floa
}
// create user iterface:
std::shared_ptr<audio::river::Interface> interface;
std::shared_ptr<ejson::Object> 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::Interface> audio::river::Manager::createFeedback(f
}
// create user iterface:
std::shared_ptr<audio::river::Interface> interface;
std::shared_ptr<ejson::Object> 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);

View File

@ -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<const ejson::Object> 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") {

View File

@ -108,13 +108,13 @@ std::vector<std::string> audio::river::io::Manager::getListStreamInput() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
std::vector<std::string> output;
std::vector<std::string> keys = m_config.getKeys();
for (size_t iii=0; iii<keys.size(); ++iii) {
const std::shared_ptr<const ejson::Object> 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<std::string> audio::river::io::Manager::getListStreamOutput() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
std::vector<std::string> output;
std::vector<std::string> keys = m_config.getKeys();
for (size_t iii=0; iii<keys.size(); ++iii) {
const std::shared_ptr<const ejson::Object> 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<std::string> audio::river::io::Manager::getListStreamVirtual() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
std::vector<std::string> output;
std::vector<std::string> keys = m_config.getKeys();
for (size_t iii=0; iii<keys.size(); ++iii) {
const std::shared_ptr<const ejson::Object> 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<std::string> audio::river::io::Manager::getListStream() {
std::unique_lock<std::recursive_mutex> lock(m_mutex);
std::vector<std::string> output;
std::vector<std::string> keys = m_config.getKeys();
for (size_t iii=0; iii<keys.size(); ++iii) {
const std::shared_ptr<const ejson::Object> 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::Node> 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<const ejson::Object> 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"

View File

@ -11,7 +11,7 @@
#define __class__ "io::Node"
audio::river::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejson::Object>& _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_ptr<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.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_ptr<con
m_isInput = false;
}
int32_t frequency = m_config->getNumberValue("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<con
}
// Get map type :
std::vector<audio::channel> map;
const std::shared_ptr<const ejson::Array> 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; iii<listChannelMap->size(); ++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_ptr<con
std::string muxerDemuxerConfig;
if (m_isInput == true) {
muxerDemuxerConfig = m_config->getStringValue("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) {

View File

@ -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<const ejson::Object>& _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<const ejson::Object> m_config; //!< configuration description.
const ejson::Object m_config; //!< configuration description.
protected:
audio::drain::Process m_process; //!< Low level algorithms
public:

View File

@ -13,7 +13,7 @@
#undef __class__
#define __class__ "io::NodeAEC"
std::shared_ptr<audio::river::io::NodeAEC> audio::river::io::NodeAEC::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
std::shared_ptr<audio::river::io::NodeAEC> audio::river::io::NodeAEC::create(const std::string& _name, const ejson::Object& _config) {
return std::shared_ptr<audio::river::io::NodeAEC>(new audio::river::io::NodeAEC(_name, _config));
}
@ -23,16 +23,16 @@ std::shared_ptr<audio::river::Interface> audio::river::io::NodeAEC::createInput(
const std::string& _objectName,
const std::string& _name) {
// check if the output exist
const std::shared_ptr<const ejson::Object> 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<audio::river::Interface>();
}
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::Interface> audio::river::io::NodeAEC::createInput(
}
audio::river::io::NodeAEC::NodeAEC(const std::string& _name, const std::shared_ptr<const ejson::Object>& _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),

View File

@ -18,14 +18,14 @@ namespace audio {
/**
* @brief Constructor
*/
NodeAEC(const std::string& _name, const std::shared_ptr<const ejson::Object>& _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<NodeAEC> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
static std::shared_ptr<NodeAEC> create(const std::string& _name, const ejson::Object& _config);
/**
* @brief Destructor
*/

View File

@ -37,11 +37,11 @@ int32_t audio::river::io::NodeFile::playbackCallback(void* _outputBuffer,
std::shared_ptr<audio::river::io::NodeFile> audio::river::io::NodeFile::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
std::shared_ptr<audio::river::io::NodeFile> audio::river::io::NodeFile::create(const std::string& _name, const ejson::Object& _config) {
return std::shared_ptr<audio::river::io::NodeFile>(new audio::river::io::NodeFile(_name, _config));
}
audio::river::io::NodeFile::NodeFile(const std::string& _name, const std::shared_ptr<const ejson::Object>& _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<const ejson::Object> 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";
}

View File

@ -24,9 +24,9 @@ namespace audio {
/**
* @brief Constructor
*/
NodeFile(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
NodeFile(const std::string& _name, const ejson::Object& _config);
public:
static std::shared_ptr<NodeFile> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
static std::shared_ptr<NodeFile> create(const std::string& _name, const ejson::Object& _config);
/**
* @brief Destructor
*/

View File

@ -13,7 +13,7 @@
#undef __class__
#define __class__ "io::NodeMuxer"
std::shared_ptr<audio::river::io::NodeMuxer> audio::river::io::NodeMuxer::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
std::shared_ptr<audio::river::io::NodeMuxer> audio::river::io::NodeMuxer::create(const std::string& _name, const ejson::Object& _config) {
return std::shared_ptr<audio::river::io::NodeMuxer>(new audio::river::io::NodeMuxer(_name, _config));
}
@ -23,16 +23,16 @@ std::shared_ptr<audio::river::Interface> audio::river::io::NodeMuxer::createInpu
const std::string& _objectName,
const std::string& _name) {
// check if the output exist
const std::shared_ptr<const ejson::Object> 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<audio::river::Interface>();
}
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::Interface> audio::river::io::NodeMuxer::createInpu
}
audio::river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std::shared_ptr<const ejson::Object>& _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<const ejson::Array> 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; iii<listChannelMap->size(); ++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; iii<listChannelMap->size(); ++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()) {

View File

@ -18,9 +18,9 @@ namespace audio {
/**
* @brief Constructor
*/
NodeMuxer(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
NodeMuxer(const std::string& _name, const ejson::Object& _config);
public:
static std::shared_ptr<NodeMuxer> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
static std::shared_ptr<NodeMuxer> create(const std::string& _name, const ejson::Object& _config);
/**
* @brief Destructor
*/

View File

@ -37,11 +37,11 @@ int32_t audio::river::io::NodeOrchestra::playbackCallback(void* _outputBuffer,
std::shared_ptr<audio::river::io::NodeOrchestra> audio::river::io::NodeOrchestra::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
std::shared_ptr<audio::river::io::NodeOrchestra> audio::river::io::NodeOrchestra::create(const std::string& _name, const ejson::Object& _config) {
return std::shared_ptr<audio::river::io::NodeOrchestra>(new audio::river::io::NodeOrchestra(_name, _config));
}
audio::river::io::NodeOrchestra::NodeOrchestra(const std::string& _name, const std::shared_ptr<const ejson::Object>& _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<const ejson::Object> 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);

View File

@ -24,9 +24,9 @@ namespace audio {
/**
* @brief Constructor
*/
NodeOrchestra(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
NodeOrchestra(const std::string& _name, const ejson::Object& _config);
public:
static std::shared_ptr<NodeOrchestra> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
static std::shared_ptr<NodeOrchestra> create(const std::string& _name, const ejson::Object& _config);
/**
* @brief Destructor
*/

View File

@ -56,11 +56,11 @@ int32_t audio::river::io::NodePortAudio::duplexCallback(const void* _inputBuffer
}
std::shared_ptr<audio::river::io::NodePortAudio> audio::river::io::NodePortAudio::create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config) {
std::shared_ptr<audio::river::io::NodePortAudio> audio::river::io::NodePortAudio::create(const std::string& _name, const ejson::Object& _config) {
return std::shared_ptr<audio::river::io::NodePortAudio>(new audio::river::io::NodePortAudio(_name, _config));
}
audio::river::io::NodePortAudio::NodePortAudio(const std::string& _name, const std::shared_ptr<const ejson::Object>& _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<const ejson::Object> 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) {

View File

@ -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<const ejson::Object>& _config);
NodePortAudio(const std::string& _name, const ejson::Object& _config);
public:
static std::shared_ptr<NodePortAudio> create(const std::string& _name, const std::shared_ptr<const ejson::Object>& _config);
static std::shared_ptr<NodePortAudio> create(const std::string& _name, const ejson::Object& _config);
/**
* @brief Destructor
*/

View File

@ -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<audio::channel>& _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<int16_t*>(_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;
}
}
}
}