[DEV] update new ETK
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
|
||||
#include <audio/river/io/Group.hpp>
|
||||
#include <audio/river/debug.hpp>
|
||||
#include "Node.hpp"
|
||||
#include "NodeAEC.hpp"
|
||||
#include "NodeOrchestra.hpp"
|
||||
#include "NodePortAudio.hpp"
|
||||
#include "Node.hpp"
|
||||
#include <audio/river/io/Node.hpp>
|
||||
#include <audio/river/io/NodeAEC.hpp>
|
||||
#include <audio/river/io/NodeOrchestra.hpp>
|
||||
#include <audio/river/io/NodePortAudio.hpp>
|
||||
#include <audio/river/io/Node.hpp>
|
||||
|
||||
void audio::river::io::Group::createFrom(const ejson::Document& _obj, const etk::String& _name) {
|
||||
RIVER_INFO("Create Group[" << _name << "] (START) ___________________________");
|
||||
|
@@ -15,10 +15,11 @@
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <utility>
|
||||
|
||||
#ifdef AUDIO_RIVER_BUILD_PORTAUDIO
|
||||
#include <portaudio/portaudio.h>
|
||||
extern "C" {
|
||||
#include <portaudio/portaudio.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
static etk::String basicAutoConfig =
|
||||
@@ -68,7 +69,7 @@ audio::river::io::Manager::Manager() {
|
||||
|
||||
void audio::river::io::Manager::init(const etk::String& _filename) {
|
||||
RIVER_ERROR("kjqsdhfkjqshdfkjqhsdskjdfhfkqjshqhskdjfhqsdfqsdqsdfqsdqsdfqsdfqsdfqsdfqsdfqsd");
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (_filename == "") {
|
||||
if (m_config.load(pathToTheRiverConfigInHome) == false) {
|
||||
RIVER_INFO("Load default config");
|
||||
@@ -82,12 +83,12 @@ void audio::river::io::Manager::init(const etk::String& _filename) {
|
||||
}
|
||||
|
||||
void audio::river::io::Manager::initString(const etk::String& _data) {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
m_config.parse(_data);
|
||||
}
|
||||
|
||||
void audio::river::io::Manager::unInit() {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
// TODO : ...
|
||||
}
|
||||
|
||||
@@ -110,7 +111,7 @@ ememory::SharedPtr<audio::river::io::Manager> audio::river::io::Manager::getInst
|
||||
|
||||
|
||||
etk::Vector<etk::String> audio::river::io::Manager::getListStreamInput() {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
etk::Vector<etk::String> output;
|
||||
etk::Vector<etk::String> keys = m_config.getKeys();
|
||||
for (auto &it : keys) {
|
||||
@@ -127,7 +128,7 @@ etk::Vector<etk::String> audio::river::io::Manager::getListStreamInput() {
|
||||
}
|
||||
|
||||
etk::Vector<etk::String> audio::river::io::Manager::getListStreamOutput() {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
etk::Vector<etk::String> output;
|
||||
etk::Vector<etk::String> keys = m_config.getKeys();
|
||||
for (auto &it : keys) {
|
||||
@@ -144,7 +145,7 @@ etk::Vector<etk::String> audio::river::io::Manager::getListStreamOutput() {
|
||||
}
|
||||
|
||||
etk::Vector<etk::String> audio::river::io::Manager::getListStreamVirtual() {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
etk::Vector<etk::String> output;
|
||||
etk::Vector<etk::String> keys = m_config.getKeys();
|
||||
for (auto &it : keys) {
|
||||
@@ -164,7 +165,7 @@ etk::Vector<etk::String> audio::river::io::Manager::getListStreamVirtual() {
|
||||
}
|
||||
|
||||
etk::Vector<etk::String> audio::river::io::Manager::getListStream() {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
etk::Vector<etk::String> output;
|
||||
etk::Vector<etk::String> keys = m_config.getKeys();
|
||||
for (auto &it : keys) {
|
||||
@@ -180,7 +181,7 @@ etk::Vector<etk::String> audio::river::io::Manager::getListStream() {
|
||||
}
|
||||
|
||||
ememory::SharedPtr<audio::river::io::Node> audio::river::io::Manager::getNode(const etk::String& _name) {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
RIVER_WARNING("Get node : " << _name);
|
||||
// search in the standalone list :
|
||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||
@@ -193,7 +194,7 @@ ememory::SharedPtr<audio::river::io::Node> audio::river::io::Manager::getNode(co
|
||||
}
|
||||
// search in the group list:
|
||||
{
|
||||
for (etk::Map<etk::String, ememory::SharedPtr<audio::river::io::Group> >::iterator it(m_listGroup.begin());
|
||||
for (etk::Map<etk::String, ememory::SharedPtr<audio::river::io::Group> >::Iterator it(m_listGroup.begin());
|
||||
it != m_listGroup.end();
|
||||
++it) {
|
||||
if (it->second != nullptr) {
|
||||
@@ -267,7 +268,7 @@ ememory::SharedPtr<audio::river::io::Node> audio::river::io::Manager::getNode(co
|
||||
}
|
||||
|
||||
ememory::SharedPtr<audio::drain::VolumeElement> audio::river::io::Manager::getVolumeGroup(const etk::String& _name) {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (_name == "") {
|
||||
RIVER_ERROR("Try to create an audio group with no name ...");
|
||||
return ememory::SharedPtr<audio::drain::VolumeElement>();
|
||||
@@ -287,7 +288,7 @@ ememory::SharedPtr<audio::drain::VolumeElement> audio::river::io::Manager::getVo
|
||||
}
|
||||
|
||||
bool audio::river::io::Manager::setVolume(const etk::String& _volumeName, float _valuedB) {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ememory::SharedPtr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||
if (volume == nullptr) {
|
||||
RIVER_ERROR("Can not set volume ... : '" << _volumeName << "'");
|
||||
@@ -309,7 +310,7 @@ bool audio::river::io::Manager::setVolume(const etk::String& _volumeName, float
|
||||
}
|
||||
|
||||
float audio::river::io::Manager::getVolume(const etk::String& _volumeName) {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ememory::SharedPtr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||
if (volume == nullptr) {
|
||||
RIVER_ERROR("Can not get volume ... : '" << _volumeName << "'");
|
||||
@@ -323,7 +324,7 @@ etk::Pair<float,float> audio::river::io::Manager::getVolumeRange(const etk::Stri
|
||||
}
|
||||
|
||||
void audio::river::io::Manager::setMute(const etk::String& _volumeName, bool _mute) {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ememory::SharedPtr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||
if (volume == nullptr) {
|
||||
RIVER_ERROR("Can not set volume ... : '" << _volumeName << "'");
|
||||
@@ -339,7 +340,7 @@ void audio::river::io::Manager::setMute(const etk::String& _volumeName, bool _mu
|
||||
}
|
||||
|
||||
bool audio::river::io::Manager::getMute(const etk::String& _volumeName) {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ememory::SharedPtr<audio::drain::VolumeElement> volume = getVolumeGroup(_volumeName);
|
||||
if (volume == nullptr) {
|
||||
RIVER_ERROR("Can not get volume ... : '" << _volumeName << "'");
|
||||
@@ -349,7 +350,7 @@ bool audio::river::io::Manager::getMute(const etk::String& _volumeName) {
|
||||
}
|
||||
|
||||
void audio::river::io::Manager::generateDot(const etk::String& _filename) {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
etk::FSNode node(_filename);
|
||||
RIVER_INFO("Generate the DOT files: " << node);
|
||||
if (node.fileOpenWrite() == false) {
|
||||
@@ -369,7 +370,7 @@ void audio::river::io::Manager::generateDot(const etk::String& _filename) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (etk::Map<etk::String, ememory::SharedPtr<audio::river::io::Group> >::iterator it(m_listGroup.begin());
|
||||
for (etk::Map<etk::String, ememory::SharedPtr<audio::river::io::Group> >::Iterator it(m_listGroup.begin());
|
||||
it != m_listGroup.end();
|
||||
++it) {
|
||||
if (it->second != nullptr) {
|
||||
@@ -388,7 +389,7 @@ void audio::river::io::Manager::generateDot(const etk::String& _filename) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (etk::Map<etk::String, ememory::SharedPtr<audio::river::io::Group> >::iterator it(m_listGroup.begin());
|
||||
for (etk::Map<etk::String, ememory::SharedPtr<audio::river::io::Group> >::Iterator it(m_listGroup.begin());
|
||||
it != m_listGroup.end();
|
||||
++it) {
|
||||
if (it->second != nullptr) {
|
||||
@@ -403,16 +404,15 @@ void audio::river::io::Manager::generateDot(const etk::String& _filename) {
|
||||
}
|
||||
|
||||
ememory::SharedPtr<audio::river::io::Group> audio::river::io::Manager::getGroup(const etk::String& _name) {
|
||||
Ethread::RecursiveLock lock(m_mutex);
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ememory::SharedPtr<audio::river::io::Group> out;
|
||||
etk::Map<etk::String, ememory::SharedPtr<audio::river::io::Group> >::iterator it = m_listGroup.find(_name);
|
||||
etk::Map<etk::String, ememory::SharedPtr<audio::river::io::Group> >::Iterator it = m_listGroup.find(_name);
|
||||
if (it == m_listGroup.end()) {
|
||||
RIVER_INFO("Create a new group: " << _name << " (START)");
|
||||
out = ememory::makeShared<audio::river::io::Group>();
|
||||
if (out != nullptr) {
|
||||
out->createFrom(m_config, _name);
|
||||
etk::Pair<etk::String, ememory::SharedPtr<audio::river::io::Group> > plop(etk::String(_name), out);
|
||||
m_listGroup.insert(plop);
|
||||
m_listGroup.add(_name, out);
|
||||
RIVER_INFO("Create a new group: " << _name << " ( END )");
|
||||
} else {
|
||||
RIVER_ERROR("Can not create new group: " << _name << " ( END )");
|
||||
|
@@ -8,10 +8,7 @@
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/Map.hpp>
|
||||
#include <list>
|
||||
#include <cstdint>
|
||||
#include <ethread/Mutex.hpp>
|
||||
#include <chrono>
|
||||
#include <etk/Function.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <audio/format.hpp>
|
||||
@@ -19,6 +16,7 @@
|
||||
#include <ejson/ejson.hpp>
|
||||
#include <audio/drain/Volume.hpp>
|
||||
#include <audio/river/io/Group.hpp>
|
||||
#include <ethread/MutexRecursive.hpp>
|
||||
|
||||
namespace audio {
|
||||
namespace river {
|
||||
@@ -30,7 +28,7 @@ namespace audio {
|
||||
*/
|
||||
class Manager : public ememory::EnableSharedFromThis<Manager> {
|
||||
private:
|
||||
mutable std::recursive_mutex m_mutex; //!< prevent multiple access
|
||||
mutable ethread::MutexRecursive m_mutex; //!< prevent multiple access
|
||||
private:
|
||||
/**
|
||||
* @brief Constructor
|
||||
|
@@ -122,7 +122,7 @@ size_t audio::river::io::Node::getNumberOfInterface(enum audio::river::modeInter
|
||||
size_t audio::river::io::Node::getNumberOfInterfaceAvaillable(enum audio::river::modeInterface _interfaceType) {
|
||||
size_t out = 0;
|
||||
for (size_t iii=0; iii<m_listAvaillable.size(); ++iii) {
|
||||
ememory::SharedPtr<audio::river::Interface> element = m_listAvaillable[iii].lock();
|
||||
auto element = m_listAvaillable[iii].lock();
|
||||
if (element == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ size_t audio::river::io::Node::getNumberOfInterfaceAvaillable(enum audio::river:
|
||||
}
|
||||
|
||||
void audio::river::io::Node::registerAsRemote(const ememory::SharedPtr<audio::river::Interface>& _interface) {
|
||||
etk::Vector<ememory::WeakPtr<audio::river::Interface> >::iterator it = m_listAvaillable.begin();
|
||||
auto it = m_listAvaillable.begin();
|
||||
while (it != m_listAvaillable.end()) {
|
||||
if (it->expired() == true) {
|
||||
it = m_listAvaillable.erase(it);
|
||||
@@ -181,7 +181,7 @@ void audio::river::io::Node::interfaceRemove(const ememory::SharedPtr<audio::riv
|
||||
|
||||
void audio::river::io::Node::volumeChange() {
|
||||
for (size_t iii=0; iii< m_listAvaillable.size(); ++iii) {
|
||||
ememory::SharedPtr<audio::river::Interface> node = m_listAvaillable[iii].lock();
|
||||
auto node = m_listAvaillable[iii].lock();
|
||||
if (node != nullptr) {
|
||||
node->systemVolumeChange();
|
||||
}
|
||||
|
@@ -7,9 +7,6 @@
|
||||
|
||||
#include <etk/String.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <list>
|
||||
#include <cstdint>
|
||||
#include <chrono>
|
||||
#include <etk/Function.hpp>
|
||||
#include <ememory/memory.hpp>
|
||||
#include <audio/format.hpp>
|
||||
|
@@ -103,28 +103,27 @@ audio::river::io::NodeAEC::NodeAEC(const etk::String& _name, const ejson::Object
|
||||
}
|
||||
|
||||
// set callback mode ...
|
||||
m_interfaceFeedBack->setInputCallback(std::bind(&audio::river::io::NodeAEC::onDataReceivedFeedBack,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6));
|
||||
m_interfaceFeedBack->setInputCallback([=](const void* _data,
|
||||
const audio::Time& _time,
|
||||
size_t _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _frequency,
|
||||
const etk::Vector<audio::channel>& _map) {
|
||||
onDataReceivedFeedBack(_data, _time, _nbChunk, _format, _frequency, _map);
|
||||
});
|
||||
// set callback mode ...
|
||||
m_interfaceMicrophone->setInputCallback(std::bind(&audio::river::io::NodeAEC::onDataReceivedMicrophone,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6));
|
||||
|
||||
m_bufferMicrophone.setCapacity(std::chrono::milliseconds(1000),
|
||||
m_interfaceMicrophone->setInputCallback([=](const void* _data,
|
||||
const audio::Time& _time,
|
||||
size_t _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _frequency,
|
||||
const etk::Vector<audio::channel>& _map) {
|
||||
onDataReceivedMicrophone(_data, _time, _nbChunk, _format, _frequency, _map);
|
||||
});
|
||||
m_bufferMicrophone.setCapacity(echrono::milliseconds(1000),
|
||||
audio::getFormatBytes(hardwareFormat.getFormat())*hardwareFormat.getMap().size(),
|
||||
hardwareFormat.getFrequency());
|
||||
m_bufferFeedBack.setCapacity(std::chrono::milliseconds(1000),
|
||||
m_bufferFeedBack.setCapacity(echrono::milliseconds(1000),
|
||||
audio::getFormatBytes(hardwareFormat.getFormat()), // only one channel ...
|
||||
hardwareFormat.getFrequency());
|
||||
|
||||
@@ -212,7 +211,7 @@ void audio::river::io::NodeAEC::process() {
|
||||
delta = MicTime - fbTime;
|
||||
}
|
||||
|
||||
RIVER_INFO("check delta " << delta.count() << " > " << m_sampleTime.count());
|
||||
RIVER_INFO("check delta " << delta << " > " << m_sampleTime);
|
||||
if (delta > m_sampleTime) {
|
||||
// Synchronize if possible
|
||||
if (MicTime < fbTime) {
|
||||
@@ -238,7 +237,7 @@ void audio::river::io::NodeAEC::process() {
|
||||
fbTime = m_bufferFeedBack.getReadTimeStamp();
|
||||
|
||||
if (MicTime-fbTime > m_sampleTime) {
|
||||
RIVER_ERROR("Can not synchronize flow ... : " << MicTime << " != " << fbTime << " delta = " << (MicTime-fbTime).count()/1000 << " µs");
|
||||
RIVER_ERROR("Can not synchronize flow ... : " << MicTime << " != " << fbTime << " delta = " << (MicTime-fbTime));
|
||||
return;
|
||||
}
|
||||
etk::Vector<uint8_t> dataMic;
|
||||
@@ -248,7 +247,7 @@ void audio::river::io::NodeAEC::process() {
|
||||
while (true) {
|
||||
MicTime = m_bufferMicrophone.getReadTimeStamp();
|
||||
fbTime = m_bufferFeedBack.getReadTimeStamp();
|
||||
RIVER_INFO(" process 256 samples ... micTime=" << MicTime << " fbTime=" << fbTime << " delta = " << (MicTime-fbTime).count());
|
||||
RIVER_INFO(" process 256 samples ... micTime=" << MicTime << " fbTime=" << fbTime << " delta = " << (MicTime-fbTime));
|
||||
m_bufferMicrophone.read(&dataMic[0], m_nbChunk);
|
||||
m_bufferFeedBack.read(&dataFB[0], m_nbChunk);
|
||||
RIVER_SAVE_FILE_MACRO(int16_t, "REC_Microphone_sync.raw", &dataMic[0], m_nbChunk*getHarwareFormat().getMap().size());
|
||||
|
@@ -197,28 +197,40 @@ audio::river::io::NodeFile::NodeFile(const etk::String& _name, const ejson::Obje
|
||||
if (m_isInput == true) {
|
||||
m_process.setInputConfig(hardwareFormat);
|
||||
m_process.setOutputConfig(interfaceFormat);
|
||||
err = m_interface.openStream(nullptr, ¶ms,
|
||||
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||
std::bind(&audio::river::io::NodeFile::recordCallback,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6),
|
||||
option
|
||||
);
|
||||
err = m_interface.openStream(nullptr,
|
||||
¶ms,
|
||||
hardwareFormat.getFormat(),
|
||||
hardwareFormat.getFrequency(),
|
||||
&m_rtaudioFrameSize,
|
||||
[=](const void* _data,
|
||||
const audio::Time& _time,
|
||||
size_t _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _frequency,
|
||||
const etk::Vector<audio::channel>& _map
|
||||
) {
|
||||
recordCallback(_data, _time, _nbChunk, _map);
|
||||
},
|
||||
option
|
||||
);
|
||||
} else {
|
||||
m_process.setInputConfig(interfaceFormat);
|
||||
m_process.setOutputConfig(hardwareFormat);
|
||||
err = m_interface.openStream(¶ms, nullptr,
|
||||
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||
std::bind(&audio::river::io::NodeFile::playbackCallback,
|
||||
this,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6),
|
||||
option
|
||||
err = m_interface.openStream(¶ms,
|
||||
nullptr,
|
||||
hardwareFormat.getFormat(),
|
||||
hardwareFormat.getFrequency(),
|
||||
&m_rtaudioFrameSize,
|
||||
[=](const void* _data,
|
||||
const audio::Time& _time,
|
||||
size_t _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _frequency,
|
||||
const etk::Vector<audio::channel>& _map
|
||||
) {
|
||||
playbackCallback(_data, _time, _nbChunk, _map);
|
||||
},
|
||||
option
|
||||
);
|
||||
}
|
||||
if (err != audio::orchestra::error_none) {
|
||||
|
@@ -42,7 +42,7 @@ namespace audio {
|
||||
audio::format m_format; //!< Format of the file
|
||||
etk::Vector<audio::channel> m_map; //!< Map of the file
|
||||
ememory::SharedPtr<ethread::Thread> m_thread; //!< playing thread of the flow
|
||||
std::atomic<bool> m_alive; //!< thread is active
|
||||
bool m_alive; //!< thread is active
|
||||
protected:
|
||||
virtual void start();
|
||||
virtual void stop();
|
||||
|
@@ -128,28 +128,28 @@ audio::river::io::NodeMuxer::NodeMuxer(const etk::String& _name, const ejson::Ob
|
||||
}
|
||||
|
||||
// set callback mode ...
|
||||
m_interfaceInput1->setInputCallback(std::bind(&audio::river::io::NodeMuxer::onDataReceivedInput1,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6));
|
||||
m_interfaceInput1->setInputCallback([=](const void* _data,
|
||||
const audio::Time& _time,
|
||||
size_t _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _frequency,
|
||||
const etk::Vector<audio::channel>& _map) {
|
||||
onDataReceivedInput1(_data, _time, _nbChunk, _format, _frequency, _map);
|
||||
});
|
||||
// set callback mode ...
|
||||
m_interfaceInput2->setInputCallback(std::bind(&audio::river::io::NodeMuxer::onDataReceivedInput2,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6));
|
||||
m_interfaceInput2->setInputCallback([=](const void* _data,
|
||||
const audio::Time& _time,
|
||||
size_t _nbChunk,
|
||||
enum audio::format _format,
|
||||
uint32_t _frequency,
|
||||
const etk::Vector<audio::channel>& _map) {
|
||||
onDataReceivedInput2(_data, _time, _nbChunk, _format, _frequency, _map);
|
||||
});
|
||||
|
||||
m_bufferInput1.setCapacity(std::chrono::milliseconds(1000),
|
||||
m_bufferInput1.setCapacity(echrono::milliseconds(1000),
|
||||
audio::getFormatBytes(hardwareFormat.getFormat())*m_mapInput1.size(),
|
||||
hardwareFormat.getFrequency());
|
||||
m_bufferInput2.setCapacity(std::chrono::milliseconds(1000),
|
||||
m_bufferInput2.setCapacity(echrono::milliseconds(1000),
|
||||
audio::getFormatBytes(hardwareFormat.getFormat())*m_mapInput2.size(),
|
||||
hardwareFormat.getFrequency());
|
||||
|
||||
@@ -243,7 +243,7 @@ void audio::river::io::NodeMuxer::process() {
|
||||
} else {
|
||||
delta = in1Time - in2Time;
|
||||
}
|
||||
RIVER_VERBOSE("check delta " << delta.count() << " > " << m_sampleTime.count());
|
||||
RIVER_VERBOSE("check delta " << delta << " > " << m_sampleTime);
|
||||
if (delta > m_sampleTime) {
|
||||
// Synchronize if possible
|
||||
if (in1Time < in2Time) {
|
||||
@@ -271,7 +271,7 @@ void audio::river::io::NodeMuxer::process() {
|
||||
in2Time = m_bufferInput2.getReadTimeStamp();
|
||||
|
||||
if (in1Time-in2Time > m_sampleTime) {
|
||||
RIVER_ERROR("Can not synchronize flow ... : " << in1Time << " != " << in2Time << " delta = " << (in1Time-in2Time).count()/1000 << " µs");
|
||||
RIVER_ERROR("Can not synchronize flow ... : " << in1Time << " != " << in2Time << " delta = " << (in1Time-in2Time));
|
||||
return;
|
||||
}
|
||||
etk::Vector<uint8_t> dataIn1;
|
||||
@@ -282,7 +282,7 @@ void audio::river::io::NodeMuxer::process() {
|
||||
while (true) {
|
||||
in1Time = m_bufferInput1.getReadTimeStamp();
|
||||
in2Time = m_bufferInput2.getReadTimeStamp();
|
||||
//RIVER_INFO(" process 256 samples ... in1Time=" << in1Time << " in2Time=" << in2Time << " delta = " << (in1Time-in2Time).count());
|
||||
//RIVER_INFO(" process 256 samples ... in1Time=" << in1Time << " in2Time=" << in2Time << " delta = " << (in1Time-in2Time));
|
||||
m_bufferInput1.read(&dataIn1[0], 256);
|
||||
m_bufferInput2.read(&dataIn2[0], 256);
|
||||
//RIVER_SAVE_FILE_MACRO(int16_t, "REC_muxer_output_1.raw", &dataIn1[0], 256 * m_mapInput1.size());
|
||||
|
@@ -198,29 +198,39 @@ audio::river::io::NodeOrchestra::NodeOrchestra(const etk::String& _name, const e
|
||||
if (m_isInput == true) {
|
||||
m_process.setInputConfig(hardwareFormat);
|
||||
m_process.setOutputConfig(interfaceFormat);
|
||||
err = m_interface.openStream(nullptr, ¶ms,
|
||||
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||
std::bind(&audio::river::io::NodeOrchestra::recordCallback,
|
||||
this,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6),
|
||||
option
|
||||
);
|
||||
err = m_interface.openStream(nullptr,
|
||||
¶ms,
|
||||
hardwareFormat.getFormat(),
|
||||
hardwareFormat.getFrequency(),
|
||||
&m_rtaudioFrameSize,
|
||||
[=] (const void* _inputBuffer,
|
||||
const audio::Time& _timeInput,
|
||||
void* _outputBuffer,
|
||||
const audio::Time& _timeOutput,
|
||||
uint32_t _nbChunk,
|
||||
const etk::Vector<audio::orchestra::status>& _status) {
|
||||
return recordCallback(_inputBuffer, _timeInput, _nbChunk, _status);
|
||||
},
|
||||
option
|
||||
);
|
||||
} else {
|
||||
m_process.setInputConfig(interfaceFormat);
|
||||
m_process.setOutputConfig(hardwareFormat);
|
||||
err = m_interface.openStream(¶ms, nullptr,
|
||||
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
|
||||
std::bind(&audio::river::io::NodeOrchestra::playbackCallback,
|
||||
this,
|
||||
std::placeholders::_3,
|
||||
std::placeholders::_4,
|
||||
std::placeholders::_5,
|
||||
std::placeholders::_6),
|
||||
option
|
||||
);
|
||||
err = m_interface.openStream(¶ms,
|
||||
nullptr,
|
||||
hardwareFormat.getFormat(),
|
||||
hardwareFormat.getFrequency(),
|
||||
&m_rtaudioFrameSize,
|
||||
[=] (const void* _inputBuffer,
|
||||
const audio::Time& _timeInput,
|
||||
void* _outputBuffer,
|
||||
const audio::Time& _timeOutput,
|
||||
uint32_t _nbChunk,
|
||||
const etk::Vector<audio::orchestra::status>& _status) {
|
||||
return playbackCallback(_outputBuffer, _timeOutput, _nbChunk, _status);
|
||||
},
|
||||
option
|
||||
);
|
||||
}
|
||||
if (err != audio::orchestra::error_none) {
|
||||
RIVER_ERROR("Create stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") << " can not create stream " << err);
|
||||
|
Reference in New Issue
Block a user