/** @file * @author Edouard DUPIN * @copyright 2015, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ #include "Manager.hpp" #include "Interface.hpp" #include "io/Manager.hpp" #include "io/Node.hpp" #include "debug.hpp" #include static ethread::Mutex g_mutex; static etk::Vector > g_listOfAllManager; ememory::SharedPtr audio::river::Manager::create(const etk::String& _applicationUniqueId) { ethread::UniqueLock lock(g_mutex); for (size_t iii=0; iii tmp = g_listOfAllManager[iii].lock(); if (tmp == null) { continue; } if (tmp->m_applicationUniqueId == _applicationUniqueId) { return tmp; } } // create a new one: ememory::SharedPtr out = ememory::SharedPtr(ETK_NEW(audio::river::Manager, _applicationUniqueId)); // add it at the list: for (size_t iii=0; iii audio::river::Manager::getListStreamInput() { etk::Vector output; ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); } else { output = manager->getListStreamInput(); } return output; } etk::Vector audio::river::Manager::getListStreamOutput() { etk::Vector output; ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); } else { output = manager->getListStreamOutput(); } return output; } etk::Vector audio::river::Manager::getListStreamVirtual() { etk::Vector output; ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); } else { output = manager->getListStreamVirtual(); } return output; } etk::Vector audio::river::Manager::getListStream() { etk::Vector output; ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); } else { output = manager->getListStream(); } return output; } bool audio::river::Manager::setVolume(const etk::String& _volumeName, float _valuedB) { ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); return false; } return manager->setVolume(_volumeName, _valuedB); } float audio::river::Manager::getVolume(const etk::String& _volumeName) const { ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); return false; } return manager->getVolume(_volumeName); } etk::Pair audio::river::Manager::getVolumeRange(const etk::String& _volumeName) const { ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); return etk::makePair(0.0f,0.0f); } return manager->getVolumeRange(_volumeName); } void audio::river::Manager::setMute(const etk::String& _volumeName, bool _mute) { ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); return; } manager->setMute(_volumeName, _mute); } bool audio::river::Manager::getMute(const etk::String& _volumeName) const { ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); return false; } return manager->getMute(_volumeName); } ememory::SharedPtr audio::river::Manager::createOutput(float _freq, const etk::Vector& _map, audio::format _format, const etk::String& _streamName, const etk::String& _options) { // get global hardware interface: ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); return ememory::SharedPtr(); } // get the output or input channel : ememory::SharedPtr node = manager->getNode(_streamName); if (node == null) { RIVER_ERROR("Can not get the Requested stream '" << _streamName << "' ==> not listed in : " << manager->getListStream()); return ememory::SharedPtr(); } if (node->isOutput() != true) { RIVER_ERROR("Can not Connect output on other thing than output ... for stream '" << _streamName << "'");; return ememory::SharedPtr(); } // create user iterface: ememory::SharedPtr interface; ejson::Object tmpOption = ejson::Object(_options); 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.pushBack(interface); return interface; } ememory::SharedPtr audio::river::Manager::createInput(float _freq, const etk::Vector& _map, audio::format _format, const etk::String& _streamName, const etk::String& _options) { // get global hardware interface: ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); return ememory::SharedPtr(); } // get the output or input channel : ememory::SharedPtr node = manager->getNode(_streamName); if (node == null) { RIVER_ERROR("Can not get the Requested stream '" << _streamName << "' ==> not listed in : " << manager->getListStream()); return ememory::SharedPtr(); } if (node->isInput() != true) { RIVER_ERROR("Can not Connect input on other thing than input ... for stream '" << _streamName << "'");; return ememory::SharedPtr(); } // create user iterface: ememory::SharedPtr interface; ejson::Object tmpOption = ejson::Object(_options); 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.pushBack(interface); return interface; } ememory::SharedPtr audio::river::Manager::createFeedback(float _freq, const etk::Vector& _map, audio::format _format, const etk::String& _streamName, const etk::String& _options) { // get global hardware interface: ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Unable to load harware IO manager ... "); return ememory::SharedPtr(); } // get the output or input channel : ememory::SharedPtr node = manager->getNode(_streamName); if (node == null) { RIVER_ERROR("Can not get the Requested stream '" << _streamName << "' ==> not listed in : " << manager->getListStream()); return ememory::SharedPtr(); } if (node->isOutput() != true) { RIVER_ERROR("Can not Connect feedback on other thing than output ... for stream '" << _streamName << "'");; return ememory::SharedPtr(); } // create user iterface: ememory::SharedPtr interface; ejson::Object tmpOption = ejson::Object(_options); 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.pushBack(interface); return interface; } void audio::river::Manager::generateDotAll(const etk::String& _filename) { // get global hardware interface: ememory::SharedPtr manager = audio::river::io::Manager::getInstance(); if (manager == null) { RIVER_ERROR("Can not get the harware manager"); return; } manager->generateDot(_filename); }