[DEV] add flow template interaface
This commit is contained in:
parent
020a599f17
commit
3b161aac2a
@ -17,7 +17,8 @@ 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}") {
|
||||||
/*
|
/*
|
||||||
// set output :
|
// set output :
|
||||||
m_io.insert(
|
m_io.insert(
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define __EAUDIOFX_GENERATOR_SIGNAL_H__
|
#define __EAUDIOFX_GENERATOR_SIGNAL_H__
|
||||||
|
|
||||||
#include <eaudiofx/core/Block.h>
|
#include <eaudiofx/core/Block.h>
|
||||||
|
#include <eaudiofx/core/BufferAudio.h>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class GeneratorSignal : public eaudiofx::Block {
|
class GeneratorSignal : public eaudiofx::Block {
|
||||||
@ -23,6 +24,8 @@ namespace eaudiofx {
|
|||||||
virtual ~GeneratorSignal() {};
|
virtual ~GeneratorSignal() {};
|
||||||
public:
|
public:
|
||||||
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot);
|
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot);
|
||||||
|
protected:
|
||||||
|
eaudiofx::flow::Output<eaudiofx::BufferAudio> m_output;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ 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']}") {
|
||||||
/*
|
/*
|
||||||
// set output :
|
// set output :
|
||||||
m_io.insert(
|
m_io.insert(
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <eaudiofx/core/Block.h>
|
#include <eaudiofx/core/Block.h>
|
||||||
#include <airtaudio/Interface.h>
|
#include <airtaudio/Interface.h>
|
||||||
|
#include <eaudiofx/core/BufferAudio.h>
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class ReceiverRtAudio : public eaudiofx::Block {
|
class ReceiverRtAudio : public eaudiofx::Block {
|
||||||
@ -46,6 +47,8 @@ namespace eaudiofx {
|
|||||||
std::vector<int8_t> m_buffer;
|
std::vector<int8_t> m_buffer;
|
||||||
public:
|
public:
|
||||||
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot);
|
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot);
|
||||||
|
protected:
|
||||||
|
eaudiofx::flow::Input<eaudiofx::BufferAudio> m_input;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,17 +9,21 @@
|
|||||||
#ifndef __EAUDIOFX_BLOCK_H__
|
#ifndef __EAUDIOFX_BLOCK_H__
|
||||||
#define __EAUDIOFX_BLOCK_H__
|
#define __EAUDIOFX_BLOCK_H__
|
||||||
|
|
||||||
#include <eaudiofx/core/audio.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <ewol/object/Object.h>
|
#include <ewol/object/Object.h>
|
||||||
|
#include <eaudiofx/core/audio.h>
|
||||||
|
#include <eaudiofx/flow/Interface.h>
|
||||||
|
#include <eaudiofx/flow/Flow.h>
|
||||||
|
|
||||||
|
|
||||||
namespace eaudiofx {
|
namespace eaudiofx {
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BlockMeta;
|
class BlockMeta;
|
||||||
|
|
||||||
class Block : public ewol::Object {
|
class Block : public ewol::Object,
|
||||||
|
public eaudiofx::flow::Interface {
|
||||||
protected:
|
protected:
|
||||||
Block();
|
Block();
|
||||||
void init() {
|
void init() {
|
||||||
@ -75,69 +79,6 @@ namespace eaudiofx {
|
|||||||
virtual bool supportNativeTime() {
|
virtual bool supportNativeTime() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* *****************************************************************
|
|
||||||
** INPUTS **
|
|
||||||
***************************************************************** */
|
|
||||||
protected:
|
|
||||||
std::vector<std::pair<std::string, std::string>> m_inputCapabilities; //!< Description of the capabilities of all the inputs (name, capacity)
|
|
||||||
public:
|
|
||||||
int32_t getNumberOfInput() {
|
|
||||||
return m_inputCapabilities.size();
|
|
||||||
}
|
|
||||||
int32_t addInput(const std::string& _name, const std::string& _description) {
|
|
||||||
// TODO :Add check of input already exist
|
|
||||||
m_inputCapabilities.push_back(std::make_pair(_name,_description));
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
std::vector<std::string> m_inputLink; //!< Name of output linked
|
|
||||||
public:
|
|
||||||
void setInputName(size_t _inputId, const std::string& _nameDistantLink);
|
|
||||||
void setInputName(const std::string& _nameInput, const std::string& _nameDistantLink);
|
|
||||||
protected:
|
|
||||||
std::vector<std::shared_ptr<eaudiofx::Buffer>> m_inputs; //!< Link on the input buffer
|
|
||||||
public:
|
|
||||||
virtual int32_t linkAllInputs() {
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
virtual int32_t unLinkAllInputs() {
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *****************************************************************
|
|
||||||
** OUTPUTS **
|
|
||||||
***************************************************************** */
|
|
||||||
protected:
|
|
||||||
std::vector<std::pair<std::string, std::string>> m_outputCapabilities; //!< Description of the capabilities of all the outputs (name, capacity)
|
|
||||||
public:
|
|
||||||
int32_t getNumberOfOutput() {
|
|
||||||
return m_outputCapabilities.size();
|
|
||||||
}
|
|
||||||
int32_t addOutput(const std::string& _name, const std::string& _description) {
|
|
||||||
// TODO :Add check of output already exist
|
|
||||||
m_outputCapabilities.push_back(std::make_pair(_name,_description));
|
|
||||||
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
std::vector<std::string> m_outputLink; //!< Name of output linked
|
|
||||||
public:
|
|
||||||
void setOutputName(size_t _inputId, const std::string& _nameDistantLink);
|
|
||||||
void setOutputName(const std::string& _nameInput, const std::string& _nameDistantLink);
|
|
||||||
protected:
|
|
||||||
std::vector<std::shared_ptr<eaudiofx::Buffer>> m_outputs;
|
|
||||||
public:
|
|
||||||
virtual int32_t allocateAllOutputs(int64_t _processTimeSlot) {
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
virtual int32_t cleanAllOutputs() {
|
|
||||||
return eaudiofx::ERR_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Reset the block
|
* @brief Reset the block
|
||||||
* @return generic error
|
* @return generic error
|
||||||
|
@ -78,29 +78,13 @@ int32_t eaudiofx::BlockMeta::linkBlock(const std::string& _generatorBlockName,
|
|||||||
const std::string& _generatorIoName,
|
const std::string& _generatorIoName,
|
||||||
const std::string& _receiverBlockName,
|
const std::string& _receiverBlockName,
|
||||||
const std::string& _receiverIoName) {
|
const std::string& _receiverIoName) {
|
||||||
/*
|
// TODO : proxy IOs
|
||||||
eaudiofx::Block* itGenerator = getBlock(_generatorBlockName);
|
std::shared_ptr<eaudiofx::Block> receive = getBlock(_receiverBlockName);
|
||||||
eaudiofx::Block* itReceiver = getBlock(_receiverBlockName);
|
if (receive == nullptr) {
|
||||||
if ( itGenerator == nullptr
|
EAUDIOFX_ERROR("Can not find destination block : '" << _receiverBlockName << "'");
|
||||||
|| itReceiver == nullptr) {
|
|
||||||
EAUDIOFX_ERROR("Can not link : '" << _generatorBlockName << "' and '" << _receiverBlockName << "' one element does not exist ...");
|
|
||||||
return eaudiofx::ERR_FAIL;
|
return eaudiofx::ERR_FAIL;
|
||||||
}
|
}
|
||||||
eaudiofx::Buffer* outputBuffer = nullptr;
|
receive->flowSetLinkWith(_receiverIoName, _generatorBlockName, _generatorIoName);
|
||||||
if (itGenerator->getBuffer(outputBuffer, _generatorIoName) != eaudiofx::ERR_NONE) {
|
|
||||||
EAUDIOFX_ERROR("Can not get buffer : '" << _generatorBlockName << "':'" << _generatorIoName << "'");
|
|
||||||
return eaudiofx::ERR_FAIL;
|
|
||||||
}
|
|
||||||
if (outputBuffer == nullptr) {
|
|
||||||
EAUDIOFX_ERROR("Get nullptr buffer : '" << _generatorBlockName << "':'" << _generatorIoName << "'");
|
|
||||||
return eaudiofx::ERR_FAIL;
|
|
||||||
}
|
|
||||||
if (itReceiver->linkBuffer(outputBuffer, _receiverIoName) != eaudiofx::ERR_NONE) {
|
|
||||||
EAUDIOFX_ERROR("Can not Link buffer : '" << _receiverBlockName << "':'" << _receiverIoName << "'");
|
|
||||||
return eaudiofx::ERR_FAIL;
|
|
||||||
}
|
|
||||||
EAUDIOFX_INFO("Link : " << _generatorBlockName << ":" << _generatorIoName << " and " << _receiverBlockName << ":" << _receiverIoName);
|
|
||||||
*/
|
|
||||||
return eaudiofx::ERR_NONE;
|
return eaudiofx::ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ namespace eaudiofx {
|
|||||||
virtual int32_t algoUnInit();
|
virtual int32_t algoUnInit();
|
||||||
virtual int32_t algoStart();
|
virtual int32_t algoStart();
|
||||||
virtual int32_t algoStop();
|
virtual int32_t algoStop();
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
33
eaudiofx/flow/Base.cpp
Normal file
33
eaudiofx/flow/Base.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <eaudiofx/debug.h>
|
||||||
|
#include <eaudiofx/flow/Interface.h>
|
||||||
|
#include <eaudiofx/flow/Base.h>
|
||||||
|
|
||||||
|
eaudiofx::flow::Base::Base(eaudiofx::flow::Interface& _flowInterfaceLink,
|
||||||
|
bool _input,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description,
|
||||||
|
const std::string& _formatAvaillable) :
|
||||||
|
m_flowInterfaceLink(_flowInterfaceLink),
|
||||||
|
m_name(_name),
|
||||||
|
m_description(_description),
|
||||||
|
m_input(_input) {
|
||||||
|
// add a reference on the current signal ...
|
||||||
|
m_flowInterfaceLink.flowAdd(this);
|
||||||
|
m_formatAvaillable.parse(_formatAvaillable);
|
||||||
|
EAUDIOFX_INFO(" create flow : " << _name << " mode:'" << (m_input==true?"input":"output") << "' prop:");
|
||||||
|
m_formatAvaillable.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& eaudiofx::flow::operator <<(std::ostream& _os, const eaudiofx::flow::Base& _obj) {
|
||||||
|
_os << _obj.getName();
|
||||||
|
return _os;
|
||||||
|
}
|
74
eaudiofx/flow/Base.h
Normal file
74
eaudiofx/flow/Base.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __EAUDIOFX_FLOW_BASE_H__
|
||||||
|
#define __EAUDIOFX_FLOW_BASE_H__
|
||||||
|
|
||||||
|
#include <ejson/ejson.h>
|
||||||
|
#include <eaudiofx/flow/Interface.h>
|
||||||
|
#include <eaudiofx/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace eaudiofx {
|
||||||
|
namespace flow {
|
||||||
|
class Base {
|
||||||
|
protected:
|
||||||
|
eaudiofx::flow::Interface& m_flowInterfaceLink;
|
||||||
|
std::string m_name;
|
||||||
|
std::string m_description;
|
||||||
|
bool m_input;
|
||||||
|
ejson::Document m_formatAvaillable;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a parameter with a specific type.
|
||||||
|
* @param[in] _flowInterfaceLink reference on the flow list.
|
||||||
|
* @param[in] _input Select input or output.
|
||||||
|
* @param[in] _name Static name of the parameter.
|
||||||
|
* @param[in] _description description of the parameter.
|
||||||
|
* @param[in] _formatAvaillable List of format availlable (or {} of all)
|
||||||
|
*/
|
||||||
|
Base(eaudiofx::flow::Interface& _flowInterfaceLink,
|
||||||
|
bool _input,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description = "",
|
||||||
|
const std::string& _formatAvaillable="{}");
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~Base() { };
|
||||||
|
|
||||||
|
const std::string& getName() const {
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
const std::string& getDescription() const {
|
||||||
|
return m_description;
|
||||||
|
}
|
||||||
|
bool isInput() {
|
||||||
|
return m_input;
|
||||||
|
}
|
||||||
|
bool isOutput() {
|
||||||
|
return !m_input;
|
||||||
|
}
|
||||||
|
const ejson::Object& getCapabilities() {
|
||||||
|
return m_formatAvaillable;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Set the flow link name
|
||||||
|
* @param[in] _blockName Extern block name (if "" ==> upper block)
|
||||||
|
* @param[in] _flowLinkName Name of the link
|
||||||
|
*/
|
||||||
|
virtual void setLink(const std::string& _blockName,
|
||||||
|
const std::string& _flowLinkName) {
|
||||||
|
EAUDIOFX_ERROR("[" << m_name << "] Can not create a link on an Output (only manage with input ...)");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::ostream& operator <<(std::ostream& _os, const eaudiofx::flow::Base& _obj);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
#endif
|
118
eaudiofx/flow/Flow.h
Normal file
118
eaudiofx/flow/Flow.h
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __EAUDIOFX_FLOW_H__
|
||||||
|
#define __EAUDIOFX_FLOW_H__
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <eaudiofx/flow/Base.h>
|
||||||
|
#include <eaudiofx/core/Buffer.h>
|
||||||
|
#include <eaudiofx/debug.h>
|
||||||
|
|
||||||
|
namespace eaudiofx {
|
||||||
|
class Buffer;
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "Flow<T>"
|
||||||
|
template<typename T = eaudiofx::Buffer> class Flow : public flow::Base {
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<eaudiofx::Buffer> m_data;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a parameter with a specific type.
|
||||||
|
* @param[in] _flowInterfaceLink reference on the parameter lister.
|
||||||
|
* @param[in] _input Select input or output.
|
||||||
|
* @param[in] _name Static name of the flow.
|
||||||
|
* @param[in] _description description of the flow.
|
||||||
|
* @param[in] _formatAvaillable List of format availlable (or {} of all)
|
||||||
|
*/
|
||||||
|
Flow(eaudiofx::flow::Interface& _flowInterfaceLink,
|
||||||
|
bool _input,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description = "",
|
||||||
|
const std::string& _formatAvaillable="{}") :
|
||||||
|
flow::Base(_flowInterfaceLink, _input, _name, _description, _formatAvaillable) {
|
||||||
|
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~Flow() { };
|
||||||
|
void set(const std::shared_ptr<eaudiofx::Buffer>& _data){
|
||||||
|
m_data.reset();
|
||||||
|
std::shared_ptr<T> check = std::dynamic_pointer_cast<T>(_data);
|
||||||
|
if (check == nullptr) {
|
||||||
|
EAUDIOFX_ERROR("can not set buffer as flow (type uncompatible)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_data = _data;
|
||||||
|
}
|
||||||
|
T* get() {
|
||||||
|
return static_cast<T*>(*m_data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
namespace flow {
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "flow::Input"
|
||||||
|
template<typename T> class Input : public Flow<T> {
|
||||||
|
private:
|
||||||
|
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
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a parameter with a specific type.
|
||||||
|
* @param[in] _flowInterfaceLink reference on the parameter lister.
|
||||||
|
* @param[in] _name Static name of the flow.
|
||||||
|
* @param[in] _description description of the flow.
|
||||||
|
* @param[in] _formatAvaillable List of format availlable (or {} of all)
|
||||||
|
*/
|
||||||
|
Input(eaudiofx::flow::Interface& _flowInterfaceLink,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description = "",
|
||||||
|
const std::string& _formatAvaillable="{}") :
|
||||||
|
Flow<T>(_flowInterfaceLink, true, _name, _description, _formatAvaillable) {
|
||||||
|
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~Input() { };
|
||||||
|
virtual void setLink(const std::string& _blockName,
|
||||||
|
const std::string& _flowLinkName) {
|
||||||
|
m_blockName = _blockName;
|
||||||
|
m_flowName = _flowLinkName;
|
||||||
|
EAUDIOFX_INFO("[" << Base::m_name << "] Link with : '" << m_blockName << "':'" << m_flowName << "'");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ "flow::Output"
|
||||||
|
template<typename T> class Output : public Flow<T> {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Create a parameter with a specific type.
|
||||||
|
* @param[in] _flowInterfaceLink reference on the parameter lister.
|
||||||
|
* @param[in] _name Static name of the flow.
|
||||||
|
* @param[in] _description description of the flow.
|
||||||
|
* @param[in] _formatAvaillable List of format availlable (or {} of all)
|
||||||
|
*/
|
||||||
|
Output(eaudiofx::flow::Interface& _flowInterfaceLink,
|
||||||
|
const std::string& _name,
|
||||||
|
const std::string& _description = "",
|
||||||
|
const std::string& _formatAvaillable="{}") :
|
||||||
|
Flow<T>(_flowInterfaceLink, false, _name, _description, _formatAvaillable) {
|
||||||
|
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
virtual ~Output() { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
#undef __class__
|
||||||
|
#define __class__ nullptr
|
||||||
|
};
|
||||||
|
#endif
|
74
eaudiofx/flow/Interface.cpp
Normal file
74
eaudiofx/flow/Interface.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <eaudiofx/debug.h>
|
||||||
|
#include <eaudiofx/flow/Interface.h>
|
||||||
|
#include <eaudiofx/flow/Base.h>
|
||||||
|
|
||||||
|
eaudiofx::flow::Interface::Interface() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
eaudiofx::flow::Interface::~Interface() {
|
||||||
|
m_list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// note this pointer is not allocated and not free at the end of the class
|
||||||
|
void eaudiofx::flow::Interface::flowAdd(eaudiofx::flow::Base* _pointerOnFlow) {
|
||||||
|
if (_pointerOnFlow == nullptr) {
|
||||||
|
EAUDIOFX_ERROR("Try to link a nullptr flow");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_list.push_back(_pointerOnFlow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void eaudiofx::flow::Interface::flowRemove(eaudiofx::flow::Base* _pointerOnFlow) {
|
||||||
|
if (_pointerOnFlow == nullptr) {
|
||||||
|
EAUDIOFX_ERROR("Try to unlink a nullptr flow");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (auto it(m_list.begin()); it != m_list.end(); ++it) {
|
||||||
|
if (*it == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (*it == _pointerOnFlow) {
|
||||||
|
m_list.erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EAUDIOFX_ERROR("Try to unlink a Unexistant flow");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> eaudiofx::flow::Interface::flowGetAll() const {
|
||||||
|
std::vector<std::string> out;
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if(it != nullptr) {
|
||||||
|
out.push_back(it->getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
void eaudiofx::flow::Interface::flowRemoveAll() {
|
||||||
|
m_list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void eaudiofx::flow::Interface::flowSetLinkWith(const std::string& _flowName,
|
||||||
|
const std::string& _blockName,
|
||||||
|
const std::string& _flowLinkName) {
|
||||||
|
for (auto &it : m_list) {
|
||||||
|
if( it != nullptr
|
||||||
|
&& it->getName() == _flowName) {
|
||||||
|
it->setLink(_blockName, _flowLinkName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EAUDIOFX_ERROR("Can not find Flow : '" << _flowName << "'");
|
||||||
|
}
|
77
eaudiofx/flow/Interface.h
Normal file
77
eaudiofx/flow/Interface.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license APACHE v2.0 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __EAUDIOFX_FLOW_INTERFACE_H__
|
||||||
|
#define __EAUDIOFX_FLOW_INTERFACE_H__
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace eaudiofx {
|
||||||
|
namespace flow {
|
||||||
|
class Base;
|
||||||
|
class Interface {
|
||||||
|
friend class eaudiofx::flow::Base; // to register parameter in the list.
|
||||||
|
private:
|
||||||
|
std::vector<eaudiofx::flow::Base*> m_list; //!< list of availlable Flow
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Constructor.
|
||||||
|
*/
|
||||||
|
Interface();
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
*/
|
||||||
|
~Interface();
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Register a flow class pointer in the List of flow
|
||||||
|
* @note This class does not destroy the flow pointer!!!
|
||||||
|
* @param[in] _pointerOnFlow Pointer on the flow that might be added.
|
||||||
|
*/
|
||||||
|
void flowAdd(eaudiofx::flow::Base* _pointerOnFlow);
|
||||||
|
/**
|
||||||
|
* @brief Un-Register a flow class pointer in the List of flow
|
||||||
|
* @param[in] _pointerOnFlow Pointer on the flow that might be added.
|
||||||
|
*/
|
||||||
|
void flowRemove(eaudiofx::flow::Base* _pointerOnFlow);
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Get All the flow list:
|
||||||
|
* @return vector on all the flow names
|
||||||
|
*/
|
||||||
|
std::vector<std::string> flowGetAll() const;
|
||||||
|
/**
|
||||||
|
* @brief Remove all flows.
|
||||||
|
*/
|
||||||
|
void flowRemoveAll();
|
||||||
|
/**
|
||||||
|
* @brief Set the flow link name
|
||||||
|
* @param[in] _flowName Local flow name to link
|
||||||
|
* @param[in] _blockName Extern block name (if "" ==> upper block)
|
||||||
|
* @param[in] _flowLinkName Name of the link
|
||||||
|
*/
|
||||||
|
void flowSetLinkWith(const std::string& _flowName,
|
||||||
|
const std::string& _blockName,
|
||||||
|
const std::string& _flowLinkName);
|
||||||
|
public:
|
||||||
|
// get pointer on the specidic input and output from all the IOs
|
||||||
|
virtual void flowLinkAllInputOutput() {};
|
||||||
|
// check if the IOs are compatible
|
||||||
|
virtual void flowCheckAllCompatibility() {};
|
||||||
|
// Allocate all Outputs
|
||||||
|
virtual void flowAllocateOutput() {};
|
||||||
|
// Get pointer on all Inputs
|
||||||
|
virtual void flowgetInput() {};
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -13,6 +13,8 @@ def create(target):
|
|||||||
myModule.add_src_file([
|
myModule.add_src_file([
|
||||||
'eaudiofx/debug.cpp',
|
'eaudiofx/debug.cpp',
|
||||||
'eaudiofx/Thread.cpp',
|
'eaudiofx/Thread.cpp',
|
||||||
|
'eaudiofx/flow/Base.cpp',
|
||||||
|
'eaudiofx/flow/Interface.cpp',
|
||||||
'eaudiofx/core/audio.cpp',
|
'eaudiofx/core/audio.cpp',
|
||||||
'eaudiofx/core/Processing.cpp',
|
'eaudiofx/core/Processing.cpp',
|
||||||
'eaudiofx/core/Block.cpp',
|
'eaudiofx/core/Block.cpp',
|
||||||
@ -31,7 +33,7 @@ def create(target):
|
|||||||
])
|
])
|
||||||
|
|
||||||
# name of the dependency
|
# name of the dependency
|
||||||
myModule.add_module_depend(['airtaudio', 'ewol'])
|
myModule.add_module_depend(['airtaudio', 'ewol', 'ejson'])
|
||||||
|
|
||||||
myModule.add_export_path(tools.get_current_path(__file__))
|
myModule.add_export_path(tools.get_current_path(__file__))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user