[DEV] update new etk Uri API

This commit is contained in:
Edouard DUPIN 2018-10-23 22:19:32 +02:00
parent 965df2ee2f
commit 1773297dab
26 changed files with 146 additions and 168 deletions

View File

@ -12,9 +12,7 @@
#include <audio/drain/EndPointRead.hpp>
#include <audio/drain/Volume.hpp>
audio::river::Interface::Interface(void) :
m_node(),
m_name("") {
audio::river::Interface::Interface(void) {
static uint32_t uid = 0;
m_uid = uid++;
@ -460,19 +458,19 @@ void audio::river::Interface::systemVolumeChange() {
algo->volumeChange();
}
static void link(etk::FSNode& _node, const etk::String& _first, const etk::String& _op, const etk::String& _second, bool _isLink=true) {
static void link(ememory::SharedPtr<etk::io::Interface>& _io, const etk::String& _first, const etk::String& _op, const etk::String& _second, bool _isLink=true) {
if (_op == "->") {
if (_isLink) {
_node << " " << _first << " -> " << _second << ";\n";
*_io << " " << _first << " -> " << _second << ";\n";
} else {
_node << " " << _first << " -> " << _second << " [style=dashed];\n";
*_io << " " << _first << " -> " << _second << " [style=dashed];\n";
}
} else if (_op == "<-") {
_node << " " << _first << " -> " <<_second<< " [color=transparent];\n";
*_io << " " << _first << " -> " <<_second<< " [color=transparent];\n";
if (_isLink) {
_node << " " << _second << " -> " << _first << " [constraint=false];\n";
*_io << " " << _second << " -> " << _first << " [constraint=false];\n";
} else {
_node << " " << _second << " -> " << _first << " [constraint=false, style=dashed];\n";
*_io << " " << _second << " -> " << _first << " [constraint=false, style=dashed];\n";
}
}
}
@ -488,37 +486,37 @@ etk::String audio::river::Interface::getDotNodeName() const {
return "error";
}
void audio::river::Interface::generateDot(etk::FSNode& _node, const etk::String& _nameIO, bool _isLink) {
_node << " subgraph clusterInterface_" << m_uid << " {\n";
_node << " color=orange;\n";
_node << " label=\"[" << m_uid << "] Interface : " << m_name << "\";\n";
void audio::river::Interface::generateDot(ememory::SharedPtr<etk::io::Interface>& _io, const etk::String& _nameIO, bool _isLink) {
*_io << " subgraph clusterInterface_" << m_uid << " {\n";
*_io << " color=orange;\n";
*_io << " label=\"[" << m_uid << "] Interface : " << m_name << "\";\n";
etk::String nameIn;
etk::String nameOut;
if ( m_mode == audio::river::modeInterface_input
|| m_mode == audio::river::modeInterface_feedback) {
m_process.generateDot(_node, 3, 10000+m_uid, nameIn, nameOut, false);
m_process.generateDot(_io, 3, 10000+m_uid, nameIn, nameOut, false);
} else {
m_process.generateDot(_node, 3, 10000+m_uid, nameOut, nameIn, true);
m_process.generateDot(_io, 3, 10000+m_uid, nameOut, nameIn, true);
}
if ( m_mode == audio::river::modeInterface_input
|| m_mode == audio::river::modeInterface_feedback) {
link(_node, _nameIO, "->", nameIn, _isLink);
link(_io, _nameIO, "->", nameIn, _isLink);
} else {
link(_node, _nameIO, "<-", nameOut, _isLink);
link(_io, _nameIO, "<-", nameOut, _isLink);
}
_node << " node [shape=Mdiamond];\n";
*_io << " node [shape=Mdiamond];\n";
if (m_mode == audio::river::modeInterface_input) {
_node << " " << getDotNodeName() << " [ label=\"API\\nINPUT\" ];\n";
link(_node, nameOut, "->", getDotNodeName());
*_io << " " << getDotNodeName() << " [ label=\"API\\nINPUT\" ];\n";
link(_io, nameOut, "->", getDotNodeName());
} else if (m_mode == audio::river::modeInterface_feedback) {
_node << " " << getDotNodeName() << " [ label=\"API\\nFEEDBACK\" ];\n";
link(_node, nameOut, "->", getDotNodeName());
*_io << " " << getDotNodeName() << " [ label=\"API\\nFEEDBACK\" ];\n";
link(_io, nameOut, "->", getDotNodeName());
} else if (m_mode == audio::river::modeInterface_output) {
_node << " " << getDotNodeName() << " [ label=\"API\\nOUTPUT\" ];\n";
link(_node, nameIn, "<-", getDotNodeName());
*_io << " " << getDotNodeName() << " [ label=\"API\\nOUTPUT\" ];\n";
link(_io, nameIn, "<-", getDotNodeName());
}
_node << " }\n \n";
*_io << " }\n \n";
}

View File

@ -18,7 +18,6 @@
#include <audio/drain/EndPointCallback.hpp>
#include <audio/drain/EndPointWrite.hpp>
#include <ejson/ejson.hpp>
#include <etk/os/FSNode.hpp>
#include <audio/Time.hpp>
namespace audio {
@ -298,11 +297,11 @@ namespace audio {
public:
/**
* @brief Create the dot in the FileNode stream.
* @param[in,out] _node File node to write data.
* @param[in,out] _io File interafce to write data.
* @param[in] _nameIO Name to link the interface node
* @param[in] _isLink True if the node is connected on the current interface.
*/
virtual void generateDot(etk::FSNode& _node, const etk::String& _nameIO, bool _isLink=true);
virtual void generateDot(ememory::SharedPtr<etk::io::Interface>& _io, const etk::String& _nameIO, bool _isLink=true);
/**
* @brief Get the current 'dot' name of the interface
* @return The anme requested.

View File

@ -130,11 +130,11 @@ void audio::river::io::Group::stop() {
}
}
void audio::river::io::Group::generateDot(etk::FSNode& _node, bool _hardwareNode) {
void audio::river::io::Group::generateDot(ememory::SharedPtr<etk::io::Interface>& _io, bool _hardwareNode) {
for (size_t iii=0; iii<m_list.size(); ++iii) {
if (m_list[iii] != null) {
if (m_list[iii]->isHarwareNode() == _hardwareNode) {
m_list[iii]->generateDot(_node);
m_list[iii]->generateDot(_io);
}
}
}

View File

@ -9,7 +9,7 @@
#include <etk/String.hpp>
#include <etk/Vector.hpp>
#include <ejson/ejson.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/io/Interface.hpp>
namespace audio {
namespace river {
@ -65,7 +65,7 @@ namespace audio {
* @param[in] _hardwareNode true if user want only display the hardware
* node and not the software node. false The oposite.
*/
void generateDot(etk::FSNode& _node, bool _hardwareNode);
void generateDot(ememory::SharedPtr<etk::io::Interface>& _node, bool _hardwareNode);
};
}
}

View File

@ -12,9 +12,10 @@
#include <audio/river/io/NodeMuxer.hpp>
#include <audio/river/io/NodeOrchestra.hpp>
#include <audio/river/io/NodePortAudio.hpp>
#include <etk/os/FSNode.hpp>
#include <ememory/memory.hpp>
#include <etk/types.hpp>
#include <etk/path/fileSystem.hpp>
#include <etk/uri/uri.hpp>
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
extern "C" {
@ -56,7 +57,7 @@ static etk::String basicAutoConfig =
"}\n";
static etk::String pathToTheRiverConfigInHome("HOME:.local/share/audio-river/config.json");
static etk::Uri pathToTheRiverConfigInHome(etk::path::getHomePath() / ".local" / "share" / "audio-river" / "config.json");
audio::river::io::Manager::Manager() {
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
@ -67,18 +68,18 @@ audio::river::io::Manager::Manager() {
#endif
}
void audio::river::io::Manager::init(const etk::String& _filename) {
void audio::river::io::Manager::init(const etk::Uri& _uri) {
RIVER_ERROR("kjqsdhfkjqshdfkjqhsdskjdfhfkqjshqhskdjfhqsdfqsdqsdfqsdqsdfqsdfqsdfqsdfqsdfqsd");
ethread::RecursiveLock lock(m_mutex);
if (_filename == "") {
if (_uri.isEmpty() == true) {
if (m_config.load(pathToTheRiverConfigInHome) == false) {
RIVER_INFO("Load default config");
m_config.parse(basicAutoConfig);
} else {
RIVER_INFO("Load default user configuration: " << pathToTheRiverConfigInHome);
}
} else if (m_config.load(_filename) == false) {
RIVER_ERROR("you must set a basic configuration file for harware configuration: '" << _filename << "'");
} else if (m_config.load(_uri) == false) {
RIVER_ERROR("you must set a basic configuration file for harware configuration: " << _uri);
}
}
@ -349,16 +350,16 @@ bool audio::river::io::Manager::getMute(const etk::String& _volumeName) {
return volume->getMute();
}
void audio::river::io::Manager::generateDot(const etk::String& _filename) {
void audio::river::io::Manager::generateDot(const etk::Uri& _uri) {
ethread::RecursiveLock lock(m_mutex);
etk::FSNode node(_filename);
RIVER_INFO("Generate the DOT files: " << node);
if (node.fileOpenWrite() == false) {
RIVER_ERROR("Can not Write the dot file (fail to open) : " << node);
ememory::SharedPtr<etk::io::Interface> ioFile = etk::uri::get(_uri);
RIVER_INFO("Generate the DOT files: " << _uri);
if (ioFile->open(etk::io::OpenMode::Write) == false) {
RIVER_ERROR("Can not Write the dot file (fail to open) : " << _uri);
return;
}
node << "digraph G {" << "\n";
node << " rankdir=\"LR\";\n";
*ioFile << "digraph G {" << "\n";
*ioFile << " rankdir=\"LR\";\n";
// First Step : Create all HW interface:
{
// standalone
@ -366,7 +367,7 @@ void audio::river::io::Manager::generateDot(const etk::String& _filename) {
ememory::SharedPtr<audio::river::io::Node> val = m_list[iii].lock();
if (val != null) {
if (val->isHarwareNode() == true) {
val->generateDot(node);
val->generateDot(ioFile);
}
}
}
@ -374,7 +375,7 @@ void audio::river::io::Manager::generateDot(const etk::String& _filename) {
it != m_listGroup.end();
++it) {
if (it->second != null) {
it->second->generateDot(node, true);
it->second->generateDot(ioFile, true);
}
}
}
@ -385,7 +386,7 @@ void audio::river::io::Manager::generateDot(const etk::String& _filename) {
ememory::SharedPtr<audio::river::io::Node> val = m_list[iii].lock();
if (val != null) {
if (val->isHarwareNode() == false) {
val->generateDot(node);
val->generateDot(ioFile);
}
}
}
@ -393,14 +394,14 @@ void audio::river::io::Manager::generateDot(const etk::String& _filename) {
it != m_listGroup.end();
++it) {
if (it->second != null) {
it->second->generateDot(node, false);
it->second->generateDot(ioFile, false);
}
}
}
node << "}" << "\n";
node.fileClose();
RIVER_INFO("Generate the DOT files: " << node << " (DONE)");
*ioFile << "}" << "\n";
ioFile->close();
RIVER_INFO("Generate the DOT files: " << _uri << " (DONE)");
}
ememory::SharedPtr<audio::river::io::Group> audio::river::io::Manager::getGroup(const etk::String& _name) {

View File

@ -42,9 +42,9 @@ namespace audio {
~Manager();
/**
* @brief Called by audio::river::init() to set the hardware configuration file.
* @param[in] _filename Name of the file to initialize.
* @param[in] _uri Uri file to initialize.
*/
void init(const etk::String& _filename);
void init(const etk::Uri& _uri);
/**
* @brief Called by audio::river::initString() to set the hardware configuration string.
* @param[in] _data json configuration string.
@ -132,9 +132,9 @@ namespace audio {
bool getMute(const etk::String& _volumeName);
/**
* @brief Generate the dot file corresponding at the actif nodes.
* @param[in] _filename Name of the file to write data.
* @param[in] _uri Uri of the file to write data.
*/
void generateDot(const etk::String& _filename);
void generateDot(const etk::Uri& _uri);
private:
etk::Map<etk::String, ememory::SharedPtr<audio::river::io::Group> > m_listGroup; //!< List of all groups
/**

View File

@ -391,63 +391,63 @@ void audio::river::io::Node::newOutput(void* _outputBuffer,
return;
}
static void link(etk::FSNode& _node, const etk::String& _first, const etk::String& _op, const etk::String& _second) {
static void link(ememory::SharedPtr<etk::io::Interface>& _io, const etk::String& _first, const etk::String& _op, const etk::String& _second) {
if (_op == "->") {
_node << " " << _first << " -> " << _second << ";\n";
*_io << " " << _first << " -> " << _second << ";\n";
} else if (_op == "<-") {
_node << " " << _first << " -> " <<_second<< " [color=transparent];\n";
_node << " " << _second << " -> " << _first << " [constraint=false];\n";
*_io << " " << _first << " -> " <<_second<< " [color=transparent];\n";
*_io << " " << _second << " -> " << _first << " [constraint=false];\n";
}
}
void audio::river::io::Node::generateDot(etk::FSNode& _node) {
_node << " subgraph clusterNode_" << m_uid << " {\n";
_node << " color=blue;\n";
_node << " label=\"[" << m_uid << "] IO::Node : " << m_name << "\";\n";
void audio::river::io::Node::generateDot(ememory::SharedPtr<etk::io::Interface>& _io) {
*_io << " subgraph clusterNode_" << m_uid << " {\n";
*_io << " color=blue;\n";
*_io << " label=\"[" << m_uid << "] IO::Node : " << m_name << "\";\n";
if (m_isInput == true) {
_node << " node [shape=rarrow];\n";
_node << " NODE_" << m_uid << "_HW_interface [ label=\"HW interface\\n interface=ALSA\\n stream=" << m_name << "\\n type=input\" ];\n";
*_io << " node [shape=rarrow];\n";
*_io << " NODE_" << m_uid << "_HW_interface [ label=\"HW interface\\n interface=ALSA\\n stream=" << m_name << "\\n type=input\" ];\n";
etk::String nameIn;
etk::String nameOut;
m_process.generateDotProcess(_node, 3, m_uid, nameIn, nameOut, false);
_node << " node [shape=square];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::toString(m_process.getOutputConfig().getFormat()) << "\" ];\n";
m_process.generateDotProcess(_io, 3, m_uid, nameIn, nameOut, false);
*_io << " node [shape=square];\n";
*_io << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::toString(m_process.getOutputConfig().getFormat()) << "\" ];\n";
// Link all nodes :
_node << " NODE_" << m_uid << "_HW_interface -> " << nameIn << " [arrowhead=\"open\"];\n";
_node << " " << nameOut << " -> NODE_" << m_uid << "_demuxer [arrowhead=\"open\"];\n";
*_io << " NODE_" << m_uid << "_HW_interface -> " << nameIn << " [arrowhead=\"open\"];\n";
*_io << " " << nameOut << " -> NODE_" << m_uid << "_demuxer [arrowhead=\"open\"];\n";
} else {
size_t nbOutput = getNumberOfInterfaceAvaillable(audio::river::modeInterface_output);
size_t nbfeedback = getNumberOfInterfaceAvaillable(audio::river::modeInterface_feedback);
_node << " node [shape=larrow];\n";
_node << " NODE_" << m_uid << "_HW_interface [ label=\"HW interface\\n interface=ALSA\\n stream=" << m_name << "\\n type=output\" ];\n";
*_io << " node [shape=larrow];\n";
*_io << " NODE_" << m_uid << "_HW_interface [ label=\"HW interface\\n interface=ALSA\\n stream=" << m_name << "\\n type=output\" ];\n";
etk::String nameIn;
etk::String nameOut;
if (nbOutput>0) {
m_process.generateDotProcess(_node, 3, m_uid, nameIn, nameOut, true);
m_process.generateDotProcess(_io, 3, m_uid, nameIn, nameOut, true);
}
_node << " node [shape=square];\n";
*_io << " node [shape=square];\n";
if (nbOutput>0) {
_node << " NODE_" << m_uid << "_muxer [ label=\"MUXER\\n format=" << etk::toString(m_process.getInputConfig().getFormat()) << "\" ];\n";
*_io << " NODE_" << m_uid << "_muxer [ label=\"MUXER\\n format=" << etk::toString(m_process.getInputConfig().getFormat()) << "\" ];\n";
}
if (nbfeedback>0) {
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::toString(m_process.getOutputConfig().getFormat()) << "\" ];\n";
*_io << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::toString(m_process.getOutputConfig().getFormat()) << "\" ];\n";
}
// Link all nodes :
if (nbOutput>0) {
link(_node, "NODE_" + etk::toString(m_uid) + "_HW_interface", "<-", nameOut);
link(_node, nameIn, "<-", "NODE_" + etk::toString(m_uid) + "_muxer");
link(_io, "NODE_" + etk::toString(m_uid) + "_HW_interface", "<-", nameOut);
link(_io, nameIn, "<-", "NODE_" + etk::toString(m_uid) + "_muxer");
}
if (nbfeedback>0) {
_node << " NODE_" << m_uid << "_HW_interface -> NODE_" << m_uid << "_demuxer [arrowhead=\"open\"];\n";
*_io << " NODE_" << m_uid << "_HW_interface -> NODE_" << m_uid << "_demuxer [arrowhead=\"open\"];\n";
}
if ( nbOutput>0
&& nbfeedback>0) {
_node << " { rank=same; NODE_" << m_uid << "_demuxer; NODE_" << m_uid << "_muxer }\n";
*_io << " { rank=same; NODE_" << m_uid << "_demuxer; NODE_" << m_uid << "_muxer }\n";
}
}
_node << " }\n \n";
*_io << " }\n \n";
for (size_t iii=0; iii< m_listAvaillable.size(); ++iii) {
if (m_listAvaillable[iii].expired() == true) {
@ -465,11 +465,11 @@ void audio::river::io::Node::generateDot(etk::FSNode& _node) {
}
if (element != null) {
if (element->getMode() == modeInterface_input) {
element->generateDot(_node, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
element->generateDot(_io, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
} else if (element->getMode() == modeInterface_output) {
element->generateDot(_node, "NODE_" + etk::toString(m_uid) + "_muxer", isLink);
element->generateDot(_io, "NODE_" + etk::toString(m_uid) + "_muxer", isLink);
} else if (element->getMode() == modeInterface_feedback) {
element->generateDot(_node, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
element->generateDot(_io, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
} else {
}

View File

@ -15,7 +15,7 @@
#include <audio/river/Interface.hpp>
#include <audio/drain/IOFormatInterface.hpp>
#include <audio/drain/Volume.hpp>
#include <etk/os/FSNode.hpp>
#include <etk/io/Interface.hpp>
namespace audio {
namespace river {
@ -209,9 +209,9 @@ namespace audio {
public:
/**
* @brief Generate the node dot file section
* @param[in] _node File node to generate the data.
* @param[in] _io File interface to dump data.
*/
virtual void generateDot(etk::FSNode& _node);
virtual void generateDot(ememory::SharedPtr<etk::io::Interface>& _io);
};
}
}

View File

@ -316,27 +316,27 @@ void audio::river::io::NodeAEC::processAEC(void* _dataMic, void* _dataFB, uint32
}
void audio::river::io::NodeAEC::generateDot(etk::FSNode& _node) {
_node << " subgraph clusterNode_" << m_uid << " {\n";
_node << " color=blue;\n";
_node << " label=\"[" << m_uid << "] IO::Node : " << m_name << "\";\n";
_node << " NODE_" << m_uid << "_HW_AEC [ label=\"AEC\\n channelMap=" << etk::toString(getInterfaceFormat().getMap()) << "\" ];\n";
void audio::river::io::NodeAEC::generateDot(ememory::SharedPtr<etk::io::Interface>& _io) {
*_io << " subgraph clusterNode_" << m_uid << " {\n";
*_io << " color=blue;\n";
*_io << " label=\"[" << m_uid << "] IO::Node : " << m_name << "\";\n";
*_io << " NODE_" << m_uid << "_HW_AEC [ label=\"AEC\\n channelMap=" << etk::toString(getInterfaceFormat().getMap()) << "\" ];\n";
etk::String nameIn;
etk::String nameOut;
m_process.generateDot(_node, 3, m_uid, nameIn, nameOut, false);
_node << " node [shape=square];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::toString(m_process.getOutputConfig().getFormat()) << "\" ];\n";
m_process.generateDot(_io, 3, m_uid, nameIn, nameOut, false);
*_io << " node [shape=square];\n";
*_io << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::toString(m_process.getOutputConfig().getFormat()) << "\" ];\n";
// Link all nodes :
_node << " NODE_" << m_uid << "_HW_AEC -> " << nameIn << ";\n";
_node << " " << nameOut << " -> NODE_" << m_uid << "_demuxer;\n";
_node << " }\n";
*_io << " NODE_" << m_uid << "_HW_AEC -> " << nameIn << ";\n";
*_io << " " << nameOut << " -> NODE_" << m_uid << "_demuxer;\n";
*_io << " }\n";
if (m_interfaceMicrophone != null) {
_node << " " << m_interfaceMicrophone->getDotNodeName() << " -> NODE_" << m_uid << "_HW_AEC;\n";
*_io << " " << m_interfaceMicrophone->getDotNodeName() << " -> NODE_" << m_uid << "_HW_AEC;\n";
}
if (m_interfaceFeedBack != null) {
_node << " " << m_interfaceFeedBack->getDotNodeName() << " -> NODE_" << m_uid << "_HW_AEC;\n";
*_io << " " << m_interfaceFeedBack->getDotNodeName() << " -> NODE_" << m_uid << "_HW_AEC;\n";
}
_node << " \n";
*_io << " \n";
for (size_t iii=0; iii< m_listAvaillable.size(); ++iii) {
if (m_listAvaillable[iii].expired() == true) {
@ -354,11 +354,11 @@ void audio::river::io::NodeAEC::generateDot(etk::FSNode& _node) {
}
if (element != null) {
if (element->getMode() == modeInterface_input) {
element->generateDot(_node, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
element->generateDot(_io, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
} else if (element->getMode() == modeInterface_output) {
element->generateDot(_node, "NODE_" + etk::toString(m_uid) + "_muxer", isLink);
element->generateDot(_io, "NODE_" + etk::toString(m_uid) + "_muxer", isLink);
} else if (element->getMode() == modeInterface_feedback) {
element->generateDot(_node, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
element->generateDot(_io, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
} else {
}

View File

@ -87,7 +87,7 @@ namespace audio {
*/
void processAEC(void* _dataMic, void* _dataFB, uint32_t _nbChunk, const audio::Time& _time);
public:
virtual void generateDot(etk::FSNode& _node);
virtual void generateDot(ememory::SharedPtr<etk::io::Interface>& _io);
private:
int32_t m_nbChunk;
int32_t m_gainValue;

View File

@ -34,12 +34,12 @@ int32_t audio::river::io::NodeFile::playbackCallback(void* _outputBuffer,
ememory::SharedPtr<audio::river::io::NodeFile> audio::river::io::NodeFile::create(const etk::String& _name, const ejson::Object& _config) {
return ememory::SharedPtr<audio::river::io::NodeFile>(ETK_NEW(audio::river::io::NodeFile, _name, _config));
ememory::SharedPtr<audio::river::io::NodeFile> audio::river::io::NodeFile::create(const etk::Path& _path, const ejson::Object& _config) {
return ememory::SharedPtr<audio::river::io::NodeFile>(ETK_NEW(audio::river::io::NodeFile, _path, _config));
}
audio::river::io::NodeFile::NodeFile(const etk::String& _name, const ejson::Object& _config) :
Node(_name, _config) {
audio::river::io::NodeFile::NodeFile(const etk::Path& _path, const ejson::Object& _config) :
Node(_path.getString(), _config) {
audio::drain::IOFormatInterface interfaceFormat = getInterfaceFormat();
audio::drain::IOFormatInterface hardwareFormat = getHarwareFormat();
/**

View File

@ -24,9 +24,9 @@ namespace audio {
/**
* @brief Constructor
*/
NodeFile(const etk::String& _name, const ejson::Object& _config);
NodeFile(const etk::Path& _path, const ejson::Object& _config);
public:
static ememory::SharedPtr<NodeFile> create(const etk::String& _name, const ejson::Object& _config);
static ememory::SharedPtr<NodeFile> create(const etk::Path& _path, const ejson::Object& _config);
/**
* @brief Destructor
*/
@ -36,7 +36,7 @@ namespace audio {
};
protected:
audio::Time m_time; //!< time of the flow
etk::FSNode m_file; //!< File interface
ememory::SharedPtr<etk::io::Interface>& m_file; //!< File interface
bool m_restartAtEnd; //!< The read is done in loop
uint32_t m_sampleRate; //!< Sample Rate of the Raw file
audio::format m_format; //!< Format of the file

View File

@ -433,30 +433,30 @@ void audio::river::io::NodeMuxer::processMuxer(void* _dataIn1, void* _dataIn2, u
}
void audio::river::io::NodeMuxer::generateDot(etk::FSNode& _node) {
_node << " subgraph clusterNode_" << m_uid << " {\n";
_node << " color=blue;\n";
_node << " label=\"[" << m_uid << "] IO::Node : " << m_name << "\";\n";
void audio::river::io::NodeMuxer::generateDot(ememory::SharedPtr<etk::io::Interface>& _io) {
*_io << " subgraph clusterNode_" << m_uid << " {\n";
*_io << " color=blue;\n";
*_io << " label=\"[" << m_uid << "] IO::Node : " << m_name << "\";\n";
_node << " node [shape=box];\n";
*_io << " node [shape=box];\n";
// TODO : Create a structure ...
_node << " NODE_" << m_uid << "_HW_MUXER [ label=\"Muxer\\n channelMap=" << etk::toString(getInterfaceFormat().getMap()) << "\" ];\n";
*_io << " NODE_" << m_uid << "_HW_MUXER [ label=\"Muxer\\n channelMap=" << etk::toString(getInterfaceFormat().getMap()) << "\" ];\n";
etk::String nameIn;
etk::String nameOut;
m_process.generateDot(_node, 3, m_uid, nameIn, nameOut, false);
_node << " node [shape=square];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::toString(m_process.getOutputConfig().getFormat()) << "\" ];\n";
m_process.generateDot(_io, 3, m_uid, nameIn, nameOut, false);
*_io << " node [shape=square];\n";
*_io << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::toString(m_process.getOutputConfig().getFormat()) << "\" ];\n";
// Link all nodes :
_node << " NODE_" << m_uid << "_HW_MUXER -> " << nameIn << ";\n";
_node << " " << nameOut << " -> NODE_" << m_uid << "_demuxer;\n";
_node << " }\n";
*_io << " NODE_" << m_uid << "_HW_MUXER -> " << nameIn << ";\n";
*_io << " " << nameOut << " -> NODE_" << m_uid << "_demuxer;\n";
*_io << " }\n";
if (m_interfaceInput2 != null) {
_node << " " << m_interfaceInput2->getDotNodeName() << " -> NODE_" << m_uid << "_HW_MUXER;\n";
*_io << " " << m_interfaceInput2->getDotNodeName() << " -> NODE_" << m_uid << "_HW_MUXER;\n";
}
if (m_interfaceInput1 != null) {
_node << " " << m_interfaceInput1->getDotNodeName() << " -> NODE_" << m_uid << "_HW_MUXER;\n";
*_io << " " << m_interfaceInput1->getDotNodeName() << " -> NODE_" << m_uid << "_HW_MUXER;\n";
}
_node << " \n";
*_io << " \n";
for (size_t iii=0; iii< m_listAvaillable.size(); ++iii) {
if (m_listAvaillable[iii].expired() == true) {
continue;
@ -473,15 +473,15 @@ void audio::river::io::NodeMuxer::generateDot(etk::FSNode& _node) {
}
if (element != null) {
if (element->getMode() == modeInterface_input) {
element->generateDot(_node, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
element->generateDot(_io, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
} else if (element->getMode() == modeInterface_output) {
element->generateDot(_node, "NODE_" + etk::toString(m_uid) + "_muxer", isLink);
element->generateDot(_io, "NODE_" + etk::toString(m_uid) + "_muxer", isLink);
} else if (element->getMode() == modeInterface_feedback) {
element->generateDot(_node, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
element->generateDot(_io, "NODE_" + etk::toString(m_uid) + "_demuxer", isLink);
} else {
}
}
}
_node << "\n";
*_io << "\n";
}

View File

@ -56,7 +56,7 @@ namespace audio {
void processMuxer(void* _dataMic, void* _dataFB, uint32_t _nbChunk, const audio::Time& _time);
etk::Vector<uint8_t> m_data;
public:
virtual void generateDot(etk::FSNode& _node);
virtual void generateDot(ememory::SharedPtr<etk::io::Interface>& _io);
private:
void reorder(void* _output, uint32_t _nbChunk, void* _input, const etk::Vector<audio::channel>& _mapInput);
};

View File

@ -31,7 +31,7 @@ With a file:
```{.cpp}
// initialize river interface
river::init("DATA:configFileName.json");
river::init("DATA:///configFileName.json");
```
With a json string:

View File

@ -10,11 +10,11 @@
#include <audio/river/Manager.hpp>
#include <audio/river/Interface.hpp>
//! [audio_river_sample_include]
#include <etk/os/FSNode.hpp>
#include <etk/etk.hpp>
#include <ethread/Thread.hpp>
#include <ethread/tools.hpp>
#include <test-debug/debug.hpp>
#include <etk/uri/uri.hpp>
@ -44,14 +44,14 @@ void onDataReceived(const void* _data,
enum audio::format _format,
uint32_t _frequency,
const etk::Vector<audio::channel>& _map,
etk::FSNode* _outputNode) {
ememory::SharedPtr<etk::io::Interface> _fileIO) {
if ( _format != audio::format_int16
&& _format != audio::format_float) {
TEST_ERROR("Call wrong type ... (need int16_t.float)");
return;
}
//! [audio_river_sample_callback_implement]
if (_outputNode->fileIsOpen() == false) {
if (_fileIO->isOpen() == false) {
if (_format != audio::format_int16) {
// get the curent power of the signal.
const int16_t* data = static_cast<const int16_t*>(_data);
@ -74,7 +74,7 @@ void onDataReceived(const void* _data,
} else {
// just write data
TEST_VERBOSE("Get data ... chunks=" << _nbChunk << " time=" << _time);
_outputNode->fileWrite(_data, _map.size()*audio::getFormatBytes(_format), _nbChunk);
_fileIO->write(_data, _map.size()*audio::getFormatBytes(_format), _nbChunk);
}
}
@ -86,7 +86,7 @@ int main(int _argc, const char **_argv) {
// local parameter:
etk::String configFile;
etk::String ioName="microphone";
etk::String outputFileName = "";
etk::Path outputFileName = "";
for (int32_t iii=0; iii<_argc ; ++iii) {
etk::String data = _argv[iii];
if ( data == "-h"
@ -130,11 +130,10 @@ int main(int _argc, const char **_argv) {
return -1;
}
//! [audio_river_sample_create_read_interface]
etk::FSNode outputNode;
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(outputFileName);
// open output file if needed:
if (outputFileName != "") {
outputNode.setName(outputFileName);
outputNode.fileOpenWrite();
if (outputFileName.isEmpty() == false) {
fileIO->open(etk::io::OpenMode::Write);
}
//! [audio_river_sample_set_callback]
// set callback mode ...
@ -144,7 +143,7 @@ int main(int _argc, const char **_argv) {
enum audio::format _format,
uint32_t _frequency,
const etk::Vector<audio::channel>& _map) {
onDataReceived(_data, _time, _nbChunk, _format, _frequency, _map, &outputNode);
onDataReceived(_data, _time, _nbChunk, _format, _frequency, _map, fileIO);
});
//! [audio_river_sample_set_callback]
//! [audio_river_sample_read_start_stop]
@ -162,7 +161,7 @@ int main(int _argc, const char **_argv) {
//! [audio_river_sample_read_reset]
// close the output file
if (outputFileName != "") {
outputNode.fileClose();
fileIO->close();
}
return 0;
}

View File

@ -32,7 +32,6 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
extern "C" {
#include <math.h>
}

View File

@ -10,8 +10,6 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
#include "main.hpp"
extern "C" {
#include <math.h>
}

View File

@ -10,14 +10,12 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
extern "C" {
#include <math.h>
}
#include <ethread/Thread.hpp>
#include <ethread/tools.hpp>
#include "main.hpp"
namespace river_test_echo_delay {
class TestClass {
@ -202,7 +200,7 @@ namespace river_test_echo_delay {
if (_format != audio::format_int16) {
TEST_ERROR("call wrong type ... (need int16_t)");
}
TEST_SAVE_FILE_MACRO(int16_t, "REC_FeedBack.raw", _data, _nbChunk*_map.size());
//TEST_SAVE_FILE_MACRO(int16_t, "REC_FeedBack.raw", _data, _nbChunk*_map.size());
if (m_estimateVolumeInput == true) {
// nothing to do ...
} else {
@ -257,7 +255,7 @@ namespace river_test_echo_delay {
if (_format != audio::format_int16) {
TEST_ERROR("call wrong type ... (need int16_t)");
}
TEST_SAVE_FILE_MACRO(int16_t, "REC_Microphone.raw", _data, _nbChunk*_map.size());
//TEST_SAVE_FILE_MACRO(int16_t, "REC_Microphone.raw", _data, _nbChunk*_map.size());
const int16_t* data = static_cast<const int16_t*>(_data);
if (m_estimateVolumeInput == true) {
m_stateMic ++;

View File

@ -10,14 +10,12 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
extern "C" {
#include <math.h>
}
#include <ethread/Thread.hpp>
#include <ethread/tools.hpp>
#include "main.hpp"
namespace river_test_format {
static const etk::String configurationRiver =

View File

@ -9,14 +9,12 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
extern "C" {
#include <math.h>
}
#include <ethread/Thread.hpp>
#include <ethread/tools.hpp>
#include "main.hpp"
namespace river_test_muxer {
class TestClass {
@ -100,7 +98,7 @@ namespace river_test_muxer {
if (_format != audio::format_int16) {
TEST_ERROR("call wrong type ... (need int16_t)");
}
TEST_SAVE_FILE_MACRO(int16_t, "REC_MicrophoneMuxed.raw", _data, _nbChunk*_map.size());
//TEST_SAVE_FILE_MACRO(int16_t, "REC_MicrophoneMuxed.raw", _data, _nbChunk*_map.size());
TEST_ERROR("Receive data ... " << _nbChunk << " map=" << _map);
}
void run() {

View File

@ -10,14 +10,12 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
extern "C" {
#include <math.h>
}
#include <ethread/Thread.hpp>
#include <ethread/tools.hpp>
#include "main.hpp"
namespace river_test_playback_callback {

View File

@ -10,14 +10,12 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
extern "C" {
#include <math.h>
}
#include <ethread/Thread.hpp>
#include <ethread/tools.hpp>
#include "main.hpp"
namespace river_test_playback_write {
static const etk::String configurationRiver =

View File

@ -9,14 +9,12 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
extern "C" {
#include <math.h>
}
#include <ethread/Thread.hpp>
#include <ethread/tools.hpp>
#include "main.hpp"
namespace river_test_record_callback {
static const etk::String configurationRiver =
@ -70,7 +68,7 @@ namespace river_test_record_callback {
if (_format != audio::format_int16) {
TEST_ERROR("call wrong type ... (need int16_t)");
}
TEST_SAVE_FILE_MACRO(int16_t, "REC_INPUT.raw", _data, _nbChunk * _map.size());
//TEST_SAVE_FILE_MACRO(int16_t, "REC_INPUT.raw", _data, _nbChunk * _map.size());
const int16_t* data = static_cast<const int16_t*>(_data);
int64_t value = 0;
for (size_t iii=0; iii<_nbChunk*_map.size(); ++iii) {

View File

@ -10,13 +10,11 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
extern "C" {
#include <math.h>
}
#include <ethread/Thread.hpp>
#include "main.hpp"
namespace river_test_record_read {

View File

@ -10,14 +10,12 @@
#include <audio/river/Interface.hpp>
#include <etest/etest.hpp>
#include <etk/etk.hpp>
#include <etk/os/FSNode.hpp>
extern "C" {
#include <math.h>
}
#include <ethread/Thread.hpp>
#include <ethread/tools.hpp>
#include "main.hpp"
namespace river_test_volume {
static const etk::String configurationRiver =