[DEV] correct Channel muxer

This commit is contained in:
Edouard DUPIN 2015-03-05 21:28:39 +01:00
parent 6a3e364cd3
commit 720c8e7764
12 changed files with 205 additions and 137 deletions

View File

@ -377,6 +377,17 @@ static void link(etk::FSNode& _node, const std::string& _first, const std::strin
}
}
std::string river::Interface::getDotNodeName() const {
if (m_mode == river::modeInterface_input) {
return "API_" + etk::to_string(m_uid) + "_input";
} else if (m_mode == river::modeInterface_feedback) {
return "API_" + etk::to_string(m_uid) + "_feedback";
} else if (m_mode == river::modeInterface_output) {
return "API_" + etk::to_string(m_uid) + "_output";
}
return "error";
}
void river::Interface::generateDot(etk::FSNode& _node, const std::string& _nameIO, bool _isLink) {
_node << " subgraph clusterInterface_" << m_uid << " {\n";
_node << " color=orange;\n";
@ -385,8 +396,12 @@ void river::Interface::generateDot(etk::FSNode& _node, const std::string& _nameI
_node << " subgraph clusterInterface_" << m_uid << "_process {\n";
_node << " label=\"Drain::Process\";\n";
_node << " node [shape=ellipse];\n";
_node << " INTERFACE_ALGO_" << m_uid << "_in [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\n in\" ];\n";
_node << " INTERFACE_ALGO_" << m_uid << "_out [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\n out\" ];\n";
_node << " INTERFACE_ALGO_" << m_uid << "_in [ label=\"format=" << etk::to_string(m_process.getInputConfig().getFormat())
<< "\\n freq=" << m_process.getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getInputConfig().getMap()) << "\\n in\" ];\n";
_node << " INTERFACE_ALGO_" << m_uid << "_out [ label=\"format=" << etk::to_string(m_process.getOutputConfig().getFormat())
<< "\\n freq=" << m_process.getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getOutputConfig().getMap()) << "\\n out\" ];\n";
_node << " }\n";
if ( m_mode == river::modeInterface_input
|| m_mode == river::modeInterface_feedback) {
@ -398,15 +413,15 @@ void river::Interface::generateDot(etk::FSNode& _node, const std::string& _nameI
}
_node << " node [shape=Mdiamond];\n";
if (m_mode == river::modeInterface_input) {
_node << " API_" << m_uid << "_input [ label=\"API\nINPUT\" ];\n";
link(_node, "INTERFACE_ALGO_" + etk::to_string(m_uid) + "_out", "->", "API_" + etk::to_string(m_uid) + "_input");
_node << " " << getDotNodeName() << " [ label=\"API\\nINPUT\" ];\n";
link(_node, "INTERFACE_ALGO_" + etk::to_string(m_uid) + "_out", "->", getDotNodeName());
} else if (m_mode == river::modeInterface_feedback) {
_node << " API_" << m_uid << "_feedback [ label=\"API\nFEEDBACK\" ];\n";
link(_node, "INTERFACE_ALGO_" + etk::to_string(m_uid) + "_out", "->", "API_" + etk::to_string(m_uid) + "_feedback");
_node << " " << getDotNodeName() << " [ label=\"API\\nFEEDBACK\" ];\n";
link(_node, "INTERFACE_ALGO_" + etk::to_string(m_uid) + "_out", "->", getDotNodeName());
} else if (m_mode == river::modeInterface_output) {
_node << " API_" << m_uid << "_output [ label=\"API\nOUTPUT\" ];\n";
link(_node, "INTERFACE_ALGO_" + etk::to_string(m_uid) + "_in", "<-", "API_" + etk::to_string(m_uid) + "_output");
_node << " " << getDotNodeName() << " [ label=\"API\\nOUTPUT\" ];\n";
link(_node, "INTERFACE_ALGO_" + etk::to_string(m_uid) + "_in", "<-", getDotNodeName());
}
_node << "}\n";
_node << " }\n \n";
}

View File

@ -209,6 +209,7 @@ namespace river {
float m_volume; //!< Local channel Volume
public:
virtual void generateDot(etk::FSNode& _node, const std::string& _nameIO, bool _isLink=true);
virtual std::string getDotNodeName() const;
};
};

View File

@ -133,11 +133,13 @@ void river::io::Group::stop() {
}
}
void river::io::Group::generateDot(etk::FSNode& _node) {
void river::io::Group::generateDot(etk::FSNode& _node, bool _hardwareNode) {
for (size_t iii=0; iii<m_list.size(); ++iii) {
if (m_list[iii] != nullptr) {
if (m_list[iii]->isHarwareNode() == _hardwareNode) {
m_list[iii]->generateDot(_node);
}
}
}
}

View File

@ -27,7 +27,7 @@ namespace river {
std11::shared_ptr<river::io::Node> getNode(const std::string& _name);
void start();
void stop();
void generateDot(etk::FSNode& _node);
void generateDot(etk::FSNode& _node, bool _hardwareNode);
};
}
}

View File

@ -234,20 +234,45 @@ void river::io::Manager::generateDot(const std::string& _filename) {
}
node << "digraph G {" << "\n";
node << " rankdir=\"LR\";\n";
// First Step : Create all HW interface:
{
// standalone
for (size_t iii=0; iii<m_list.size(); ++iii) {
std11::shared_ptr<river::io::Node> val = m_list[iii].lock();
if (val != nullptr) {
if (val->isHarwareNode() == true) {
val->generateDot(node);
}
}
}
for (std::map<std::string, std11::shared_ptr<river::io::Group> >::iterator it(m_listGroup.begin());
it != m_listGroup.end();
++it) {
if (it->second != nullptr) {
it->second->generateDot(node);
it->second->generateDot(node, true);
}
}
}
// All other ...
{
// standalone
for (size_t iii=0; iii<m_list.size(); ++iii) {
std11::shared_ptr<river::io::Node> val = m_list[iii].lock();
if (val != nullptr) {
if (val->isHarwareNode() == false) {
val->generateDot(node);
}
}
}
for (std::map<std::string, std11::shared_ptr<river::io::Group> >::iterator it(m_listGroup.begin());
it != m_listGroup.end();
++it) {
if (it->second != nullptr) {
it->second->generateDot(node, false);
}
}
}
node << "}" << "\n";
node.fileClose();
RIVER_INFO("Generate the DOT files: " << node << " (DONE)");

View File

@ -268,16 +268,20 @@ void river::io::Node::generateDot(etk::FSNode& _node) {
_node << " 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=MICROPHONE\n type=input\" ];\n";
_node << " NODE_" << m_uid << "_HW_interface [ label=\"HW interface\\n interface=ALSA\\n stream=" << m_name << "\\n type=input\" ];\n";
_node << " subgraph clusterNode_" << m_uid << "_process {\n";
_node << " label=\"Drain::Process\";\n";
_node << " node [shape=ellipse];\n";
_node << " node_ALGO_" << m_uid << "_in [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\" ];\n";
_node << " node_ALGO_" << m_uid << "_out [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\" ];\n";
_node << " node_ALGO_" << m_uid << "_in [ label=\"format=" << etk::to_string(m_process.getInputConfig().getFormat())
<< "\\n freq=" << m_process.getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getInputConfig().getMap()) << "\" ];\n";
_node << " node_ALGO_" << m_uid << "_out [ label=\"format=" << etk::to_string(m_process.getOutputConfig().getFormat())
<< "\\n freq=" << m_process.getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getOutputConfig().getMap()) << "\" ];\n";
_node << " }\n";
_node << " node [shape=square];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\n format=xxx\" ];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::to_string(m_process.getOutputConfig().getFormat()) << "\" ];\n";
// Link all nodes :
_node << " NODE_" << m_uid << "_HW_interface -> node_ALGO_" << m_uid << "_in [arrowhead=\"open\"];\n";
_node << " node_ALGO_" << m_uid << "_in -> node_ALGO_" << m_uid << "_out [arrowhead=\"open\"];\n";
@ -286,21 +290,25 @@ void river::io::Node::generateDot(etk::FSNode& _node) {
size_t nbOutput = getNumberOfInterfaceAvaillable(river::modeInterface_output);
size_t nbfeedback = getNumberOfInterfaceAvaillable(river::modeInterface_feedback);
_node << " node [shape=larrow];\n";
_node << " NODE_" << m_uid << "_HW_interface [ label=\"HW interface\n interface=ALSA\n stream=SPEAKER\n type=output\" ];\n";
_node << " NODE_" << m_uid << "_HW_interface [ label=\"HW interface\\n interface=ALSA\\n stream=" << m_name << "\\n type=output\" ];\n";
if (nbOutput>0) {
_node << " subgraph clusterNode_" << m_uid << "_process {\n";
_node << " label=\"Drain::Process\";\n";
_node << " node [shape=ellipse];\n";
_node << " node_ALGO_" << m_uid << "_out [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\" ];\n";
_node << " node_ALGO_" << m_uid << "_in [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\" ];\n";
_node << " node_ALGO_" << m_uid << "_out [ label=\"format=" << etk::to_string(m_process.getOutputConfig().getFormat())
<< "\\n freq=" << m_process.getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getOutputConfig().getMap()) << "\" ];\n";
_node << " node_ALGO_" << m_uid << "_in [ label=\"format=" << etk::to_string(m_process.getInputConfig().getFormat())
<< "\\n freq=" << m_process.getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getInputConfig().getMap()) << "\" ];\n";
_node << " }\n";
}
_node << " node [shape=square];\n";
if (nbOutput>0) {
_node << " NODE_" << m_uid << "_muxer [ label=\"MUXER\n format=xxx\" ];\n";
_node << " NODE_" << m_uid << "_muxer [ label=\"MUXER\\n format=" << etk::to_string(m_process.getInputConfig().getFormat()) << "\" ];\n";
}
if (nbfeedback>0) {
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\n format=xxx\" ];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::to_string(m_process.getOutputConfig().getFormat()) << "\" ];\n";
}
// Link all nodes :
if (nbOutput>0) {
@ -317,7 +325,7 @@ void river::io::Node::generateDot(etk::FSNode& _node) {
}
}
_node << "}\n";
_node << " }\n \n";
for (size_t iii=0; iii< m_listAvaillable.size(); ++iii) {
if (m_listAvaillable[iii].expired() == true) {

View File

@ -41,7 +41,9 @@ namespace river {
* @brief Destructor
*/
virtual ~Node();
virtual bool isHarwareNode() {
return false;
};
protected:
mutable std11::mutex m_mutex;
std11::shared_ptr<const ejson::Object> m_config;

View File

@ -355,22 +355,26 @@ void river::io::NodeAEC::generateDot(etk::FSNode& _node) {
_node << " subgraph clusterNode_" << m_uid << "_process {\n";
_node << " label=\"Drain::Process\";\n";
_node << " node [shape=ellipse];\n";
_node << " node_ALGO_" << m_uid << "_in [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\" ];\n";
_node << " node_ALGO_" << m_uid << "_out [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\" ];\n";
_node << " node_ALGO_" << m_uid << "_in [ label=\"format=" << etk::to_string(m_process.getInputConfig().getFormat())
<< "\\n freq=" << m_process.getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getInputConfig().getMap()) << "\" ];\n";
_node << " node_ALGO_" << m_uid << "_out [ label=\"format=" << etk::to_string(m_process.getOutputConfig().getFormat())
<< "\\n freq=" << m_process.getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getOutputConfig().getMap()) << "\" ];\n";
_node << " }\n";
_node << " node [shape=square];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\n format=xxx\" ];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::to_string(m_process.getOutputConfig().getFormat()) << "\" ];\n";
// Link all nodes :
_node << " NODE_" << m_uid << "_HW_AEC -> node_ALGO_" << m_uid << "_in;\n";
_node << " node_ALGO_" << m_uid << "_in -> node_ALGO_" << m_uid << "_out;\n";
_node << " node_ALGO_" << m_uid << "_out -> NODE_" << m_uid << "_demuxer;\n";
_node << " }\n";
if (m_interfaceMicrophone != nullptr) {
_node << " API_" << m_interfaceMicrophone->m_uid << "_input -> NODE_" << m_uid << "_HW_AEC;\n";
_node << " " << m_interfaceMicrophone->getDotNodeName() << " -> NODE_" << m_uid << "_HW_AEC;\n";
}
if (m_interfaceFeedBack != nullptr) {
_node << " API_" << m_interfaceFeedBack->m_uid << "_feedback -> NODE_" << m_uid << "_HW_AEC;\n";
_node << " " << m_interfaceFeedBack->getDotNodeName() << " -> NODE_" << m_uid << "_HW_AEC;\n";
}
for (size_t iii=0; iii<m_list.size(); ++iii) {

View File

@ -28,6 +28,9 @@ namespace river {
* @brief Destructor
*/
virtual ~NodeAirTAudio();
virtual bool isHarwareNode() {
return true;
};
protected:
airtaudio::Interface m_adac; //!< Real audio interface
airtaudio::DeviceInfo m_info;

View File

@ -128,7 +128,7 @@ river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std11::shared_pt
}
// set callback mode ...
m_interfaceInput1->setInputCallback(std11::bind(&river::io::NodeMuxer::onDataReceivedFeedBack,
m_interfaceInput1->setInputCallback(std11::bind(&river::io::NodeMuxer::onDataReceivedInput1,
this,
std11::placeholders::_1,
std11::placeholders::_2,
@ -137,7 +137,7 @@ river::io::NodeMuxer::NodeMuxer(const std::string& _name, const std11::shared_pt
std11::placeholders::_5,
std11::placeholders::_6));
// set callback mode ...
m_interfaceInput2->setInputCallback(std11::bind(&river::io::NodeMuxer::onDataReceivedMicrophone,
m_interfaceInput2->setInputCallback(std11::bind(&river::io::NodeMuxer::onDataReceivedInput2,
this,
std11::placeholders::_1,
std11::placeholders::_2,
@ -187,7 +187,7 @@ void river::io::NodeMuxer::stop() {
}
void river::io::NodeMuxer::onDataReceivedMicrophone(const void* _data,
void river::io::NodeMuxer::onDataReceivedInput1(const void* _data,
const std11::chrono::system_clock::time_point& _time,
size_t _nbChunk,
enum audio::format _format,
@ -205,7 +205,7 @@ void river::io::NodeMuxer::onDataReceivedMicrophone(const void* _data,
process();
}
void river::io::NodeMuxer::onDataReceivedFeedBack(const void* _data,
void river::io::NodeMuxer::onDataReceivedInput2(const void* _data,
const std11::chrono::system_clock::time_point& _time,
size_t _nbChunk,
enum audio::format _format,
@ -436,28 +436,32 @@ void river::io::NodeMuxer::generateDot(etk::FSNode& _node) {
_node << " node [shape=box];\n";
// TODO : Create a structure ...
_node << " NODE_" << m_uid << "_HW_AEC [ label=\"AEC\" ];\n";
_node << " NODE_" << m_uid << "_HW_MUXER [ label=\"Muxer\\n channelMap=" << etk::to_string(getInterfaceFormat().getMap()) << "\" ];\n";
_node << " subgraph clusterNode_" << m_uid << "_process {\n";
_node << " label=\"Drain::Process\";\n";
_node << " node [shape=ellipse];\n";
_node << " node_ALGO_" << m_uid << "_in [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\" ];\n";
_node << " node_ALGO_" << m_uid << "_out [ label=\"format=xxx\n freq=yyy\n channelMap={left,right}\" ];\n";
_node << " node_ALGO_" << m_uid << "_in [ label=\"format=" << etk::to_string(m_process.getInputConfig().getFormat())
<< "\\n freq=" << m_process.getInputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getInputConfig().getMap()) << "\" ];\n";
_node << " node_ALGO_" << m_uid << "_out [ label=\"format=" << etk::to_string(m_process.getOutputConfig().getFormat())
<< "\\n freq=" << m_process.getOutputConfig().getFrequency()
<< "\\n channelMap=" << etk::to_string(m_process.getOutputConfig().getMap()) << "\" ];\n";
_node << " }\n";
_node << " node [shape=square];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\n format=xxx\" ];\n";
_node << " NODE_" << m_uid << "_demuxer [ label=\"DEMUXER\\n format=" << etk::to_string(m_process.getOutputConfig().getFormat()) << "\" ];\n";
// Link all nodes :
_node << " NODE_" << m_uid << "_HW_AEC -> node_ALGO_" << m_uid << "_in;\n";
_node << " NODE_" << m_uid << "_HW_MUXER -> node_ALGO_" << m_uid << "_in;\n";
_node << " node_ALGO_" << m_uid << "_in -> node_ALGO_" << m_uid << "_out;\n";
_node << " node_ALGO_" << m_uid << "_out -> NODE_" << m_uid << "_demuxer;\n";
_node << " }\n";
if (m_interfaceInput2 != nullptr) {
_node << " API_" << m_interfaceInput2->m_uid << "_input -> NODE_" << m_uid << "_HW_AEC;\n";
_node << " " << m_interfaceInput2->getDotNodeName() << " -> NODE_" << m_uid << "_HW_MUXER;\n";
}
if (m_interfaceInput1 != nullptr) {
_node << " API_" << m_interfaceInput1->m_uid << "_feedback -> NODE_" << m_uid << "_HW_AEC;\n";
_node << " " << m_interfaceInput1->getDotNodeName() << " -> NODE_" << m_uid << "_HW_MUXER;\n";
}
_node << " \n";
for (size_t iii=0; iii<m_list.size(); ++iii) {
if (m_list[iii] != nullptr) {
if (m_list[iii]->getMode() == modeInterface_input) {
@ -471,4 +475,5 @@ void river::io::NodeMuxer::generateDot(etk::FSNode& _node) {
}
}
}
_node << "\n";
}

View File

@ -36,13 +36,13 @@ namespace river {
audio::format _format,
const std::string& _streamName,
const std::string& _name);
void onDataReceivedMicrophone(const void* _data,
void onDataReceivedInput1(const void* _data,
const std11::chrono::system_clock::time_point& _time,
size_t _nbChunk,
enum audio::format _format,
uint32_t _frequency,
const std::vector<audio::channel>& _map);
void onDataReceivedFeedBack(const void* _data,
void onDataReceivedInput2(const void* _data,
const std11::chrono::system_clock::time_point& _time,
size_t _nbChunk,
enum audio::format _format,

View File

@ -28,6 +28,9 @@ namespace river {
* @brief Destructor
*/
virtual ~NodePortAudio();
virtual bool isHarwareNode() {
return true;
};
protected:
PaStream* m_stream;
public: