[DEV] flow now link themself
This commit is contained in:
parent
3b161aac2a
commit
d8860e377e
@ -10,6 +10,9 @@
|
|||||||
#include <eaudiofx/Thread.h>
|
#include <eaudiofx/Thread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "Thread"
|
||||||
|
|
||||||
static const char* threadGetCharState(enum eaudiofx::status state) {
|
static const char* threadGetCharState(enum eaudiofx::status state) {
|
||||||
const char* ret = (const char*)"";
|
const char* ret = (const char*)"";
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "GeneratorSignal"
|
||||||
|
|
||||||
void eaudiofx::GeneratorSignal::init() {
|
void eaudiofx::GeneratorSignal::init() {
|
||||||
eaudiofx::Block::init();
|
eaudiofx::Block::init();
|
||||||
}
|
}
|
||||||
@ -19,17 +22,7 @@ void eaudiofx::GeneratorSignal::init() {
|
|||||||
eaudiofx::GeneratorSignal::GeneratorSignal() :
|
eaudiofx::GeneratorSignal::GeneratorSignal() :
|
||||||
m_phase(0),
|
m_phase(0),
|
||||||
m_output(*this, "out", "Output sinus generated", "{ type:'audio', freq:48000, format:'int16', channels:2}") {
|
m_output(*this, "out", "Output sinus generated", "{ type:'audio', freq:48000, format:'int16', channels:2}") {
|
||||||
/*
|
addObjectType("eaudiofx::GeneratorSignal");
|
||||||
// set output :
|
|
||||||
m_io.insert(
|
|
||||||
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
|
||||||
"out",
|
|
||||||
eaudiofx::Block::IOProperty(
|
|
||||||
eaudiofx::Block::ioOutput,
|
|
||||||
"{ type:'audio', compression:'raw', frequency:48000, channel:2, format:'float' }",
|
|
||||||
new eaudiofx::BufferAudio(*this)
|
|
||||||
) ) );
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
#include <eaudiofx/core/BufferAudio.h>
|
#include <eaudiofx/core/BufferAudio.h>
|
||||||
#include <airtaudio/Interface.h>
|
#include <airtaudio/Interface.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "ReceiverRtAudio"
|
||||||
|
|
||||||
int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
|
int eaudiofx::ReceiverRtAudio::rtAudioCallBack(void *_outputBuffer,
|
||||||
void *_inputBuffer,
|
void *_inputBuffer,
|
||||||
unsigned int _nBufferFrames,
|
unsigned int _nBufferFrames,
|
||||||
@ -66,17 +69,7 @@ void eaudiofx::ReceiverRtAudio::init() {
|
|||||||
eaudiofx::ReceiverRtAudio::ReceiverRtAudio() :
|
eaudiofx::ReceiverRtAudio::ReceiverRtAudio() :
|
||||||
m_processStarted(false),
|
m_processStarted(false),
|
||||||
m_input(*this, "in", "Input audio flow", "{ type:'audio', freq:[8000, 16000, 32000, 48000, 64000, 96000, 128000, 192000], format:['int8','int16','int32','float']}") {
|
m_input(*this, "in", "Input audio flow", "{ type:'audio', freq:[8000, 16000, 32000, 48000, 64000, 96000, 128000, 192000], format:['int8','int16','int32','float']}") {
|
||||||
/*
|
addObjectType("eaudiofx::ReceiverRtAudio");
|
||||||
// set output :
|
|
||||||
m_io.insert(
|
|
||||||
std::pair<std::string, eaudiofx::Block::IOProperty>(
|
|
||||||
"in",
|
|
||||||
eaudiofx::Block::IOProperty(
|
|
||||||
eaudiofx::Block::ioInput,
|
|
||||||
"{ type:'audio', compression:'raw', frequency:48000, channel:2, format:'float' }",
|
|
||||||
NULL
|
|
||||||
) ) );
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,10 +11,12 @@
|
|||||||
#include <eaudiofx/core/Buffer.h>
|
#include <eaudiofx/core/Buffer.h>
|
||||||
#include <eaudiofx/core/BlockMeta.h>
|
#include <eaudiofx/core/BlockMeta.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "Block"
|
||||||
|
|
||||||
|
|
||||||
eaudiofx::Block::Block() {
|
eaudiofx::Block::Block() {
|
||||||
|
addObjectType("eaudiofx::Block");
|
||||||
}
|
}
|
||||||
|
|
||||||
eaudiofx::Block::~Block() {
|
eaudiofx::Block::~Block() {
|
||||||
@ -22,3 +24,21 @@ eaudiofx::Block::~Block() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<eaudiofx::Block> eaudiofx::Block::getBlockNamed(const std::string& _name) {
|
||||||
|
std::shared_ptr<eaudiofx::Block> out;
|
||||||
|
EAUDIOFX_INFO(" get block : " << _name);
|
||||||
|
std::shared_ptr<ewol::Object> parrent = m_parent.lock();
|
||||||
|
if (parrent != nullptr) {
|
||||||
|
std::shared_ptr<eaudiofx::Block> parrentBlock = std::dynamic_pointer_cast<eaudiofx::Block>(parrent);
|
||||||
|
if (parrentBlock != nullptr) {
|
||||||
|
return parrentBlock->getBlockNamed(_name);
|
||||||
|
} else {
|
||||||
|
EAUDIOFX_INFO(" Parent is not a Block ...");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
EAUDIOFX_INFO(" No parent ...");
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ namespace eaudiofx {
|
|||||||
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
|
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
}
|
}
|
||||||
|
virtual std::shared_ptr<eaudiofx::Block> getBlockNamed(const std::string& _name);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,10 +9,12 @@
|
|||||||
#include <eaudiofx/debug.h>
|
#include <eaudiofx/debug.h>
|
||||||
#include <eaudiofx/core/BlockMeta.h>
|
#include <eaudiofx/core/BlockMeta.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "BlockMeta"
|
||||||
|
|
||||||
|
|
||||||
eaudiofx::BlockMeta::BlockMeta() {
|
eaudiofx::BlockMeta::BlockMeta() {
|
||||||
|
addObjectType("eaudiofx::BlockMeta");
|
||||||
}
|
}
|
||||||
|
|
||||||
eaudiofx::BlockMeta::~BlockMeta() {
|
eaudiofx::BlockMeta::~BlockMeta() {
|
||||||
@ -60,6 +62,7 @@ int32_t eaudiofx::BlockMeta::addBlock(const std::shared_ptr<eaudiofx::Block>& _b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_list.push_back(_block);
|
m_list.push_back(_block);
|
||||||
|
_block->setParent(shared_from_this());
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,3 +170,40 @@ int32_t eaudiofx::BlockMeta::algoStop() {
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<eaudiofx::Block> eaudiofx::BlockMeta::getBlockNamed(const std::string& _name) {
|
||||||
|
std::shared_ptr<eaudiofx::Block> out;
|
||||||
|
EAUDIOFX_DEBUG("[" << m_name << "] try get Block : " << _name);
|
||||||
|
// Special case for proxy flow ...
|
||||||
|
if ( _name == ""
|
||||||
|
|| _name == m_name.get()) {
|
||||||
|
EAUDIOFX_DEBUG(" ==> find Him");
|
||||||
|
return std::static_pointer_cast<eaudiofx::Block>(shared_from_this());
|
||||||
|
}
|
||||||
|
// find in sub elements.
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if (it == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
EAUDIOFX_DEBUG(" check : " << it->getName());
|
||||||
|
if (it->getName() == _name) {
|
||||||
|
out = it;
|
||||||
|
EAUDIOFX_DEBUG(" ==> find this one");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
void eaudiofx::BlockMeta::flowLinkInput() {
|
||||||
|
EAUDIOFX_INFO("[" << getId() << "] Meta block Link: '" << getName() << "'");
|
||||||
|
// find in sub elements.
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if (it == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it->flowLinkInput();
|
||||||
|
}
|
||||||
|
// Call upper class
|
||||||
|
eaudiofx::Block::flowLinkInput();
|
||||||
|
}
|
||||||
|
@ -82,6 +82,8 @@ namespace eaudiofx {
|
|||||||
virtual int32_t algoStart();
|
virtual int32_t algoStart();
|
||||||
virtual int32_t algoStop();
|
virtual int32_t algoStop();
|
||||||
|
|
||||||
|
virtual std::shared_ptr<eaudiofx::Block> getBlockNamed(const std::string& _name);
|
||||||
|
virtual void flowLinkInput();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include <eaudiofx/core/Buffer.h>
|
#include <eaudiofx/core/Buffer.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "Buffer"
|
||||||
|
|
||||||
|
|
||||||
eaudiofx::Buffer::Buffer(eaudiofx::Block& _parent) :
|
eaudiofx::Buffer::Buffer(eaudiofx::Block& _parent) :
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class Block;
|
class Block;
|
||||||
class Buffer {
|
class Buffer : public std::enable_shared_from_this<Buffer> {
|
||||||
public:
|
public:
|
||||||
Buffer(eaudiofx::Block& _parent);
|
Buffer(eaudiofx::Block& _parent);
|
||||||
virtual ~Buffer() {};
|
virtual ~Buffer() {};
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
#include <eaudiofx/core/BufferAudio.h>
|
#include <eaudiofx/core/BufferAudio.h>
|
||||||
#include <eaudiofx/debug.h>
|
#include <eaudiofx/debug.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "BufferAudio"
|
||||||
|
|
||||||
|
|
||||||
eaudiofx::BufferAudio::BufferAudio(eaudiofx::Block& _parent, const std::string& _description) :
|
eaudiofx::BufferAudio::BufferAudio(eaudiofx::Block& _parent, const std::string& _description) :
|
||||||
eaudiofx::Buffer(_parent),
|
eaudiofx::Buffer(_parent),
|
||||||
m_frequency(48000),
|
m_frequency(48000),
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
#include <eaudiofx/core/BufferAudioFreq.h>
|
#include <eaudiofx/core/BufferAudioFreq.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "BufferAudioFreq"
|
||||||
|
|
||||||
|
|
||||||
eaudiofx::BufferAudioFreq::BufferAudioFreq(eaudiofx::Block& _parent) :
|
eaudiofx::BufferAudioFreq::BufferAudioFreq(eaudiofx::Block& _parent) :
|
||||||
eaudiofx::BufferAudio(_parent) {
|
eaudiofx::BufferAudio(_parent) {
|
||||||
|
@ -11,6 +11,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "Processing"
|
||||||
|
eaudiofx::Processing::Processing() {
|
||||||
|
addObjectType("eaudiofx::Processing");
|
||||||
|
};
|
||||||
|
|
||||||
int32_t eaudiofx::Processing::process() {
|
int32_t eaudiofx::Processing::process() {
|
||||||
EAUDIOFX_INFO("Start process : '" << getName() << "'");
|
EAUDIOFX_INFO("Start process : '" << getName() << "'");
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
@ -34,6 +40,16 @@ int32_t eaudiofx::Processing::waitEndOfProcess() {
|
|||||||
|
|
||||||
bool eaudiofx::Processing::stateStart() {
|
bool eaudiofx::Processing::stateStart() {
|
||||||
EAUDIOFX_INFO("Start Processing : '" << getName() << "'");
|
EAUDIOFX_INFO("Start Processing : '" << getName() << "'");
|
||||||
|
// TODO : Add return code ... and test all of theses events ...
|
||||||
|
// Init request flow update:
|
||||||
|
flowLinkInput();
|
||||||
|
// check if the IOs are compatible
|
||||||
|
flowCheckAllCompatibility();
|
||||||
|
// Allocate all Outputs
|
||||||
|
flowAllocateOutput();
|
||||||
|
// Get pointer on all Inputs
|
||||||
|
flowGetInput();
|
||||||
|
// init algorithm
|
||||||
int32_t ret = algoInit();
|
int32_t ret = algoInit();
|
||||||
if (ret != eaudiofx::ERR_NONE) {
|
if (ret != eaudiofx::ERR_NONE) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class Processing : public eaudiofx::BlockMeta, eaudiofx::Thread {
|
class Processing : public eaudiofx::BlockMeta, eaudiofx::Thread {
|
||||||
protected:
|
protected:
|
||||||
Processing() {};
|
Processing();
|
||||||
void init() {
|
void init() {
|
||||||
eaudiofx::BlockMeta::init();
|
eaudiofx::BlockMeta::init();
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
#include <eaudiofx/debug.h>
|
#include <eaudiofx/debug.h>
|
||||||
#include <eaudiofx/flow/Interface.h>
|
#include <eaudiofx/flow/Interface.h>
|
||||||
#include <eaudiofx/flow/Base.h>
|
#include <eaudiofx/flow/Base.h>
|
||||||
|
#include <eaudiofx/core/Block.h>
|
||||||
|
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "flow::Base"
|
||||||
|
|
||||||
eaudiofx::flow::Base::Base(eaudiofx::flow::Interface& _flowInterfaceLink,
|
eaudiofx::flow::Base::Base(eaudiofx::flow::Interface& _flowInterfaceLink,
|
||||||
bool _input,
|
bool _input,
|
||||||
@ -20,14 +24,60 @@ eaudiofx::flow::Base::Base(eaudiofx::flow::Interface& _flowInterfaceLink,
|
|||||||
m_name(_name),
|
m_name(_name),
|
||||||
m_description(_description),
|
m_description(_description),
|
||||||
m_input(_input) {
|
m_input(_input) {
|
||||||
|
m_ref = std::make_shared<BaseReference>(this);
|
||||||
// add a reference on the current signal ...
|
// add a reference on the current signal ...
|
||||||
m_flowInterfaceLink.flowAdd(this);
|
m_flowInterfaceLink.flowAdd(this);
|
||||||
m_formatAvaillable.parse(_formatAvaillable);
|
m_formatAvaillable.parse(_formatAvaillable);
|
||||||
EAUDIOFX_INFO(" create flow : " << _name << " mode:'" << (m_input==true?"input":"output") << "' prop:");
|
EAUDIOFX_INFO("Create flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' prop:");
|
||||||
m_formatAvaillable.display();
|
m_formatAvaillable.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eaudiofx::flow::Base::~Base() {
|
||||||
|
m_ref->removeBase();
|
||||||
|
EAUDIOFX_INFO("Remove flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "'");
|
||||||
|
};
|
||||||
|
|
||||||
std::ostream& eaudiofx::flow::operator <<(std::ostream& _os, const eaudiofx::flow::Base& _obj) {
|
std::ostream& eaudiofx::flow::operator <<(std::ostream& _os, const eaudiofx::flow::Base& _obj) {
|
||||||
_os << _obj.getName();
|
_os << _obj.getName();
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void eaudiofx::flow::Base::link() {
|
||||||
|
EAUDIOFX_INFO(" link flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' (no code)");
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkCompatibility() {
|
||||||
|
EAUDIOFX_INFO(" chack flow : '" << m_name << "' (no code)");
|
||||||
|
}
|
||||||
|
|
||||||
|
void getInputBuffer() {
|
||||||
|
EAUDIOFX_INFO(" get Buffers : '" << m_name << "' (no code)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// due to the fact it acces at the block interface, we need to write it here ...
|
||||||
|
std::shared_ptr<eaudiofx::flow::BaseReference> eaudiofx::flow::Base::getFlowReference(const std::string& _blockName,
|
||||||
|
const std::string& _flowLinkName) {
|
||||||
|
std::shared_ptr<eaudiofx::flow::BaseReference> out;
|
||||||
|
if (_flowLinkName == "") {
|
||||||
|
EAUDIOFX_INFO(" Get flow : " << _blockName << ":" << _flowLinkName << " nothing to do ==> no connection ...");
|
||||||
|
}
|
||||||
|
std::shared_ptr<eaudiofx::Block> blockRemote = m_flowInterfaceLink.getBlockNamed(_blockName);
|
||||||
|
if (blockRemote == nullptr) {
|
||||||
|
EAUDIOFX_ERROR(" Get flow : '" << m_name << "' mode:'input' to " << _blockName << ":" << _flowLinkName << " Error no remote block");
|
||||||
|
} else {
|
||||||
|
out = blockRemote->getFlowReference(_flowLinkName);
|
||||||
|
if (out == nullptr) {
|
||||||
|
EAUDIOFX_ERROR(" Get flow : '" << m_name << "' mode:'input' to " << _blockName << ":" << _flowLinkName << " Error no Flow found");
|
||||||
|
} else {
|
||||||
|
EAUDIOFX_INFO(" Get flow : " << _blockName << ":" << _flowLinkName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::shared_ptr<eaudiofx::Block> eaudiofx::flow::Base::getBlockNamed(const std::string& _name) {
|
||||||
|
EAUDIOFX_ERROR("NEED to call Parrent ...");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
namespace flow {
|
namespace flow {
|
||||||
|
class BaseReference;
|
||||||
class Base {
|
class Base {
|
||||||
protected:
|
protected:
|
||||||
eaudiofx::flow::Interface& m_flowInterfaceLink;
|
eaudiofx::flow::Interface& m_flowInterfaceLink;
|
||||||
@ -41,7 +42,7 @@ namespace eaudiofx {
|
|||||||
/**
|
/**
|
||||||
* @brief Destructor.
|
* @brief Destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~Base() { };
|
virtual ~Base();
|
||||||
|
|
||||||
const std::string& getName() const {
|
const std::string& getName() const {
|
||||||
return m_name;
|
return m_name;
|
||||||
@ -67,8 +68,43 @@ namespace eaudiofx {
|
|||||||
const std::string& _flowLinkName) {
|
const std::string& _flowLinkName) {
|
||||||
EAUDIOFX_ERROR("[" << m_name << "] Can not create a link on an Output (only manage with input ...)");
|
EAUDIOFX_ERROR("[" << m_name << "] Can not create a link on an Output (only manage with input ...)");
|
||||||
}
|
}
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<BaseReference> m_ref; //!< To simplify implementation code we use a temporary variable to shared the current reference...
|
||||||
|
public:
|
||||||
|
std::shared_ptr<BaseReference> getReference() {
|
||||||
|
return m_ref;
|
||||||
|
}
|
||||||
|
virtual void addReference(const std::shared_ptr<BaseReference>& _reference) {
|
||||||
|
EAUDIOFX_ERROR("[" << m_name << "] Can not add reference ...");
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<BaseReference> getFlowReference(const std::string& _blockName,
|
||||||
|
const std::string& _flowLinkName);
|
||||||
|
public:
|
||||||
|
virtual void link();
|
||||||
|
virtual void checkCompatibility();
|
||||||
|
virtual void getInputBuffer();
|
||||||
|
//virtual std::shared_ptr<eaudiofx::Block> getBlockNamed(const std::string& _name);
|
||||||
};
|
};
|
||||||
std::ostream& operator <<(std::ostream& _os, const eaudiofx::flow::Base& _obj);
|
std::ostream& operator <<(std::ostream& _os, const eaudiofx::flow::Base& _obj);
|
||||||
|
// we use a reference to simplify code of every blocks...
|
||||||
|
//! @not-in-doc
|
||||||
|
class BaseReference : public std::enable_shared_from_this<BaseReference> {
|
||||||
|
protected:
|
||||||
|
Base* m_basePointer;
|
||||||
|
public:
|
||||||
|
BaseReference(Base* _base = nullptr) :
|
||||||
|
m_basePointer(_base) {
|
||||||
|
// nothing to do ...
|
||||||
|
}
|
||||||
|
~BaseReference() {}
|
||||||
|
void removeBase() {
|
||||||
|
m_basePointer = nullptr;
|
||||||
|
}
|
||||||
|
inline Base* getBase() const {
|
||||||
|
return m_basePointer;
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,6 +62,7 @@ namespace eaudiofx {
|
|||||||
private:
|
private:
|
||||||
std::string m_blockName; //!< Temporary value of flow link (when not linked & distant block can be created after) : Block name
|
std::string m_blockName; //!< Temporary value of flow link (when not linked & distant block can be created after) : Block name
|
||||||
std::string m_flowName; //!< Temporary value of flow link (when not linked & distant block can be created after) : Flow name
|
std::string m_flowName; //!< Temporary value of flow link (when not linked & distant block can be created after) : Flow name
|
||||||
|
std::weak_ptr<BaseReference> m_remoteFlow; //!< reference on the remote flow.
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Create a parameter with a specific type.
|
* @brief Create a parameter with a specific type.
|
||||||
@ -87,10 +88,24 @@ namespace eaudiofx {
|
|||||||
m_flowName = _flowLinkName;
|
m_flowName = _flowLinkName;
|
||||||
EAUDIOFX_INFO("[" << Base::m_name << "] Link with : '" << m_blockName << "':'" << m_flowName << "'");
|
EAUDIOFX_INFO("[" << Base::m_name << "] Link with : '" << m_blockName << "':'" << m_flowName << "'");
|
||||||
}
|
}
|
||||||
|
virtual void link() {
|
||||||
|
EAUDIOFX_INFO(" link flow : '" << Base::m_name << "' mode:'input' to " << m_blockName << ":" << m_flowName);
|
||||||
|
std::shared_ptr<BaseReference> remoteFlow = Base::getFlowReference(m_blockName, m_flowName);
|
||||||
|
m_remoteFlow = remoteFlow;
|
||||||
|
if (remoteFlow == nullptr) {
|
||||||
|
EAUDIOFX_ERROR(" link flow : '" << Base::m_name << "' mode:'input' to " << m_blockName << ":" << m_flowName << " Error no Flow found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// set our own cross reference to the remote ...
|
||||||
|
remoteFlow->getBase()->addReference(Base::getReference());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "flow::Output"
|
#define __class__ "flow::Output"
|
||||||
template<typename T> class Output : public Flow<T> {
|
template<typename T> class Output : public Flow<T> {
|
||||||
|
protected:
|
||||||
|
std::vector<std::weak_ptr<BaseReference>> m_remoteFlow; //!< List of reference on the remote flow (multiple childs).
|
||||||
|
ejson::Document m_formatMix; //!< current format that is now availlable on the flow (can be on error) represent the intersection of all flow connected
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Create a parameter with a specific type.
|
* @brief Create a parameter with a specific type.
|
||||||
@ -110,6 +125,9 @@ namespace eaudiofx {
|
|||||||
* @brief Destructor.
|
* @brief Destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~Output() { };
|
virtual ~Output() { };
|
||||||
|
virtual void addReference(const std::shared_ptr<BaseReference>& _reference) {
|
||||||
|
m_remoteFlow.push_back(_reference);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
#undef __class__
|
#undef __class__
|
||||||
|
@ -72,3 +72,49 @@ void eaudiofx::flow::Interface::flowSetLinkWith(const std::string& _flowName,
|
|||||||
}
|
}
|
||||||
EAUDIOFX_ERROR("Can not find Flow : '" << _flowName << "'");
|
EAUDIOFX_ERROR("Can not find Flow : '" << _flowName << "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void eaudiofx::flow::Interface::flowLinkInput() {
|
||||||
|
EAUDIOFX_INFO(" Block update the flows links");
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if(it != nullptr) {
|
||||||
|
it->link();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void eaudiofx::flow::Interface::flowCheckAllCompatibility() {
|
||||||
|
EAUDIOFX_INFO(" Block Check the flows Capabilities");
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if(it != nullptr) {
|
||||||
|
it->checkCompatibility();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void eaudiofx::flow::Interface::flowAllocateOutput() {
|
||||||
|
EAUDIOFX_WARNING(" Block need to allocate all his output");
|
||||||
|
}
|
||||||
|
|
||||||
|
void eaudiofx::flow::Interface::flowGetInput() {
|
||||||
|
EAUDIOFX_WARNING(" Block Get input data pointers");
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if(it != nullptr) {
|
||||||
|
it->getInputBuffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<eaudiofx::flow::BaseReference> eaudiofx::flow::Interface::getFlowReference(const std::string& _flowName) {
|
||||||
|
std::shared_ptr<eaudiofx::flow::BaseReference> out;
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if( it != nullptr
|
||||||
|
&& it->getName() == _flowName) {
|
||||||
|
out = it->getReference();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,8 +14,10 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
|
class Block;
|
||||||
namespace flow {
|
namespace flow {
|
||||||
class Base;
|
class Base;
|
||||||
|
class BaseReference;
|
||||||
class Interface {
|
class Interface {
|
||||||
friend class eaudiofx::flow::Base; // to register parameter in the list.
|
friend class eaudiofx::flow::Base; // to register parameter in the list.
|
||||||
private:
|
private:
|
||||||
@ -62,14 +64,23 @@ namespace eaudiofx {
|
|||||||
const std::string& _flowLinkName);
|
const std::string& _flowLinkName);
|
||||||
public:
|
public:
|
||||||
// get pointer on the specidic input and output from all the IOs
|
// get pointer on the specidic input and output from all the IOs
|
||||||
virtual void flowLinkAllInputOutput() {};
|
virtual void flowLinkInput();
|
||||||
// check if the IOs are compatible
|
// check if the IOs are compatible
|
||||||
virtual void flowCheckAllCompatibility() {};
|
virtual void flowCheckAllCompatibility() {};
|
||||||
// Allocate all Outputs
|
// Allocate all Outputs
|
||||||
virtual void flowAllocateOutput() {};
|
virtual void flowAllocateOutput() {};
|
||||||
// Get pointer on all Inputs
|
// Get pointer on all Inputs
|
||||||
virtual void flowgetInput() {};
|
virtual void flowGetInput() {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get The block named ...
|
||||||
|
* @param[in] _name Name of the block requested
|
||||||
|
* @return The block requested if it exist.
|
||||||
|
*/
|
||||||
|
virtual std::shared_ptr<eaudiofx::Block> getBlockNamed(const std::string& _name) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
std::shared_ptr<eaudiofx::flow::BaseReference> getFlowReference(const std::string& _name);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <etk/tool.h>
|
#include <etk/tool.h>
|
||||||
#include <eaudiofx/eaudiofx.h>
|
#include <eaudiofx/eaudiofx.h>
|
||||||
#include <ewol/widget/Button.h>
|
#include <ewol/widget/Button.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <eaudiofx/base/GeneratorSignal.h>
|
#include <eaudiofx/base/GeneratorSignal.h>
|
||||||
#include <eaudiofx/base/ReceiverRtAudio.h>
|
#include <eaudiofx/base/ReceiverRtAudio.h>
|
||||||
@ -38,9 +39,14 @@ void appl::Windows::init() {
|
|||||||
composition += " Play 1\n";
|
composition += " Play 1\n";
|
||||||
composition += " </label>\n";
|
composition += " </label>\n";
|
||||||
composition += " </button>\n";
|
composition += " </button>\n";
|
||||||
composition += " <button name='bt-play2'>\n";
|
composition += " <button name='bt-stop1'>\n";
|
||||||
composition += " <label>\n";
|
composition += " <label>\n";
|
||||||
composition += " Play 2\n";
|
composition += " Stop 1\n";
|
||||||
|
composition += " </label>\n";
|
||||||
|
composition += " </button>\n";
|
||||||
|
composition += " <button name='bt-play-stop'>\n";
|
||||||
|
composition += " <label>\n";
|
||||||
|
composition += " Play / Stop\n";
|
||||||
composition += " </label>\n";
|
composition += " </label>\n";
|
||||||
composition += " </button>\n";
|
composition += " </button>\n";
|
||||||
composition += " </sizer>\n";
|
composition += " </sizer>\n";
|
||||||
@ -54,11 +60,16 @@ void appl::Windows::init() {
|
|||||||
}
|
}
|
||||||
setSubWidget(m_composer);
|
setSubWidget(m_composer);
|
||||||
subBind(ewol::widget::Button, "bt-play1", signalPressed, shared_from_this(), &appl::Windows::onCallbackPlay);
|
subBind(ewol::widget::Button, "bt-play1", signalPressed, shared_from_this(), &appl::Windows::onCallbackPlay);
|
||||||
subBind(ewol::widget::Button, "bt-play2", signalPressed, shared_from_this(), &appl::Windows::onCallbackStop);
|
subBind(ewol::widget::Button, "bt-stop1", signalPressed, shared_from_this(), &appl::Windows::onCallbackStop);
|
||||||
|
subBind(ewol::widget::Button, "bt-play-stop", signalPressed, shared_from_this(), &appl::Windows::onCallbackPlayStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<eaudiofx::Processing> process = NULL;
|
std::shared_ptr<eaudiofx::Processing> process = NULL;
|
||||||
|
void appl::Windows::onCallbackPlayStop() {
|
||||||
|
onCallbackPlay();
|
||||||
|
usleep(500000);
|
||||||
|
onCallbackStop();
|
||||||
|
}
|
||||||
void appl::Windows::onCallbackPlay() {
|
void appl::Windows::onCallbackPlay() {
|
||||||
#if 0
|
#if 0
|
||||||
APPL_INFO("Play Requested ...");
|
APPL_INFO("Play Requested ...");
|
||||||
@ -106,13 +117,14 @@ void appl::Windows::onCallbackPlay() {
|
|||||||
APPL_ERROR("can not create processing ...");
|
APPL_ERROR("can not create processing ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
process->setName("main Process");
|
||||||
APPL_INFO("Create Generator Sinus");
|
APPL_INFO("Create Generator Sinus");
|
||||||
std::shared_ptr<eaudiofx::GeneratorSignal> generator = eaudiofx::GeneratorSignal::create();
|
std::shared_ptr<eaudiofx::GeneratorSignal> generator = eaudiofx::GeneratorSignal::create();
|
||||||
if (generator == NULL) {
|
if (generator == NULL) {
|
||||||
APPL_ERROR("can not create Generator ...");
|
APPL_ERROR("can not create Generator ...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
generator->setName("myGeneratorSinus");
|
generator->setName("myGenerator");
|
||||||
process->addBlock(generator);
|
process->addBlock(generator);
|
||||||
|
|
||||||
APPL_INFO("Create Receiver ...");
|
APPL_INFO("Create Receiver ...");
|
||||||
|
@ -24,6 +24,7 @@ namespace appl {
|
|||||||
public: // callback functions
|
public: // callback functions
|
||||||
void onCallbackPlay();
|
void onCallbackPlay();
|
||||||
void onCallbackStop();
|
void onCallbackStop();
|
||||||
|
void onCallbackPlayStop();
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user