[DEV] change basic namespace to be compatible with musicdsp environement

This commit is contained in:
Edouard DUPIN 2016-10-04 21:42:09 +02:00
parent c01b518f05
commit f08abb713d
66 changed files with 2104 additions and 2053 deletions

View File

@ -0,0 +1,248 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/Thread.hpp>
#include <unistd.h>
static const char* threadGetCharState(enum audio::blockEngine::status state) {
const char* ret = (const char*)"";
switch (state) {
case audio::blockEngine::statusNotStarted:
ret = (const char*)"NOT_STARTED";
break;
case audio::blockEngine::statusCreating:
ret = (const char*)"CREATING";
break;
case audio::blockEngine::statusStart:
ret = (const char*)"START";
break;
case audio::blockEngine::statusRun:
ret = (const char*)"RUN";
break;
case audio::blockEngine::statusStop:
ret = (const char*)"STOP";
break;
case audio::blockEngine::statusDie:
ret = (const char*)"DIE";
break;
default:
ret = (const char*)"???";
break;
}
return ret;
}
/**
* @brief change the current state of the thread.
* @param[in] _newState The new state for the thread.
*/
void audio::blockEngine::Thread::threadChangeState(enum audio::blockEngine::status _newState) {
int ret;
std::unique_lock<std::mutex> lock(m_interfaceMutex);
// debug display :
ABE_DEBUG("[" << m_id << "] '" << m_name << "' Change state : " << threadGetCharState(m_state) << " ==> " << threadGetCharState(_newState));
// set the New state
m_state = _newState;
return;
}
audio::blockEngine::Thread::Thread(const std::string& _chainName) {
if (_chainName != "") {
m_name = _chainName;
} else {
m_name = "No-name";
ABE_WARNING("the thread has no name");
}
static int32_t threadIDBasic = 100;
m_id = threadIDBasic++;
ABE_INFO("THREAD : Allocate [" << m_id << "] name='" << m_name << "'");
m_state = audio::blockEngine::statusNotStarted;
}
audio::blockEngine::Thread::~Thread() {
ABE_INFO("THREAD : Destroy [" << m_id << "] name='" << m_name << "'");
stop();
m_thread->join();
m_thread.reset();
}
int32_t audio::blockEngine::Thread::start() {
int ret;
if (audio::blockEngine::statusDie == m_state) {
ABE_INFO("Thread [" << m_id << "] name='" << m_name << "' ==> state die ... ==> delete it ...");
stopAtEnd();
}
if (audio::blockEngine::statusNotStarted != m_state) {
ABE_ERROR("Failed to create [" << m_id << "] name='" << m_name << "' ==> the thread is not stopped ...");
return audio::blockEngine::ERR_FAIL;
}
m_state = audio::blockEngine::statusCreating;
m_thread = std::make_shared<std::thread>(audio::blockEngine::Thread::genericThreadCall, reinterpret_cast<void*>(this));
// no else ==> the thread is started corectly... (we think)
return audio::blockEngine::ERR_NONE;
}
int32_t audio::blockEngine::Thread::stop() {
ABE_INFO(" Stop [" << m_id << "] name='" << m_name << "'");
// Set the stop flag for the thread :
std::unique_lock<std::mutex> lock(m_interfaceMutex);
m_flags |= 1;
return audio::blockEngine::ERR_NONE;
}
int32_t audio::blockEngine::Thread::stopAtEnd() {
int systemRet;
int32_t ret = audio::blockEngine::ERR_NONE;
ABE_INFO(" Delete [" << m_id << "] name='" << m_name << "' (StopAtEnd)");
// Request the thread stop:
ret = stop();
if (audio::blockEngine::ERR_NONE != ret) {
ABE_ERROR("The thread have a problem to stop");
return ret;
}
if (audio::blockEngine::statusNotStarted != m_state) {
m_thread.reset();
}
std::unique_lock<std::mutex> lock(m_interfaceMutex);
m_flags = 0;
m_state = audio::blockEngine::statusNotStarted;
return ret;
}
// function that might be writen for every thread
bool audio::blockEngine::Thread::stateStart() {
ABE_DEBUG("Not overwrited in the herited classes: StateStart");
// virtual function ...
return false;
}
bool audio::blockEngine::Thread::stateRun() {
ABE_DEBUG("Not overwrited in the herited classes: StateRun");
// virtual function ...
usleep(100000);
// Force the stop if this function is not overwritte
return false;
}
bool audio::blockEngine::Thread::stateStop() {
ABE_DEBUG("Not overwrited in the herited classes: StateStop");
// virtual function ...
return false;
}
void audio::blockEngine::Thread::genericThreadCall(void* _data) {
audio::blockEngine::Thread * self = reinterpret_cast<audio::blockEngine::Thread*>(_data);
if (self != nullptr) {
self->threadCall();
} else {
ABE_ERROR("can not start th ethraead ...");
}
}
void audio::blockEngine::Thread::threadCall() {
bool autoKill = false;
// Endless loop.
while(audio::blockEngine::statusDie != m_state) {
int32_t flags = 0;
{
std::unique_lock<std::mutex> lock(m_interfaceMutex);
flags = m_flags;
m_flags = 0;
}
if (flags == 1 ) {
ABE_DEBUG("Detect stop request by user...");
// action depend on the current state :
switch (m_state) {
case audio::blockEngine::statusCreating:
threadChangeState(audio::blockEngine::statusDie);
break;
case audio::blockEngine::statusStart:
threadChangeState(audio::blockEngine::statusStop);
break;
case audio::blockEngine::statusRun:
threadChangeState(audio::blockEngine::statusStop);
break;
case audio::blockEngine::statusStop:
// nothing to do ...
break;
case audio::blockEngine::statusDie:
// impossible state
break;
default:
// Should not happen
ABE_CRITICAL("Base: [" << m_id << "] '" << m_name << "' state failure ...");
break;
}
}
// Retrieve current action.
switch (m_state) {
case audio::blockEngine::statusCreating:
ABE_DEBUG("audio::blockEngine::statusCreating");
// change state :
threadChangeState(audio::blockEngine::statusStart);
break;
case audio::blockEngine::statusStart:
ABE_DEBUG("audio::blockEngine::statusStart");
// call function
autoKill = stateStart();
// a problem occured to the function
if (true == autoKill) {
// error in start ==> direct end
threadChangeState(audio::blockEngine::statusDie);
} else {
// change state :
threadChangeState(audio::blockEngine::statusRun);
}
break;
case audio::blockEngine::statusRun:
ABE_DEBUG("audio::blockEngine::statusRun");
// call function
autoKill = stateRun();
if (true == autoKill) {
ABE_DEBUG("Request AutoKill");
// error in start ==> direct end
threadChangeState(audio::blockEngine::statusStop);
}
// no else
break;
case audio::blockEngine::statusStop:
ABE_DEBUG("audio::blockEngine::statusStop");
// call function
autoKill = stateStop();
// a problem occured to the function
if (true == autoKill) {
// error in stop ==> direct end
threadChangeState(audio::blockEngine::statusDie);
} else {
// change state :
threadChangeState(audio::blockEngine::statusDie);
}
break;
case audio::blockEngine::statusDie:
ABE_DEBUG("audio::blockEngine::statusDie");
break;
default:
// Should not happen
ABE_CRITICAL("Base: state failure: [" << m_id << "] name='" << m_name << "'");
return;
}
}
// exit the thread...
ABE_INFO("Base: THEAD (END): [" << m_id << "] name='" << m_name << "'");
return;
}

View File

@ -0,0 +1,71 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <thread>
#include <mutex>
#include <etk/os/Fifo.hpp>
#include <audio/blockEngine/core/audio.hpp>
/**
* @brief Tanho thread system (parent class)
*/
namespace audio {
namespace blockEngine {
enum status {
statusNotStarted, //!< The thread is creating itself
statusCreating, //!< The thread is creating itself
statusStart, //!< The element is starting
statusRun, //!< The thread is running
statusStop, //!< The thread is stoping
statusDie, //!< the thread is diing or dead
};
class Thread {
private:
static void genericThreadCall(void * data);
protected:
std::shared_ptr<std::thread> m_thread;
std::mutex m_interfaceMutex;
int32_t m_flags;
public:
Thread(const std::string& _name="not-set-name");
~Thread();
int32_t start(); //!< start the thread
int32_t stop(); //!< stop this current thread (request the stop of the process) ==> a-synchronous request
int32_t stopAtEnd(); //!< stop when the process is ended (when possible) ==> stop and wait hte real end of the thread
void setRepeating(int32_t delayBetweenRestart, int32_t maxTimeRestart); //!< configure repeating
void setNoRepeating(); //!< cancel SetRepeating
protected:
void threadCall(); //!< internal call of sup thread system (call from GenericThreadCall)
private:
void threadChangeState(enum status _newState); //!< information about state change
protected:
std::string m_name; //!< curent thread name
private:
uint32_t m_id; //!< Thread Id it will be Unique
enum status m_state; //!< Thread current state
protected:
enum status getState() {
return m_state;
};
/**
* @brief Thread state "Start" process
* @return true if an error occured ==> this kill the thread.
*/
virtual bool stateStart();
/**
* @brief Thread state "Run" process
* @return true if an error occured or a kill is requested by a block
*/
virtual bool stateRun();
/**
* @brief Thread state "Stop" process
* @return true if an error occured
*/
virtual bool stateStop();
};
}
}

View File

@ -0,0 +1,83 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/base/GeneratorSignal.hpp>
#include <audio/blockEngine/core/BufferStream.hpp>
#include <audio/blockEngine/base/GeneratorFile.hpp>
audio::blockEngine::GeneratorFile::GeneratorFile() :
m_file(nullptr) {
// set output :
m_io.insert(
std::pair<std::string, audio::blockEngine::Block::IOProperty>(
"out",
audio::blockEngine::Block::IOProperty(
audio::blockEngine::Block::ioOutput,
"{ type:'bitstream', format:'file' }",
new audio::blockEngine::BufferStream(*this)
) ) );
}
int32_t audio::blockEngine::GeneratorFile::pull(double _currentTime, int32_t _request, float _timeout) {
auto it = m_io.find("out");
if (it == m_io.end()) {
ABE_WARNING("request to pull data with no output !!!");
return audio::blockEngine::ERR_FAIL;
}
audio::blockEngine::BufferStream* buffer = dynamic_cast<audio::blockEngine::BufferStream*>(it->second.m_buffer);
//ABE_ERROR("Generate data, request : " << _request << " at time : " << _currentTime);
if (buffer == nullptr) {
// !! impossible case => a buffer can not be removed ...
ABE_ERROR("Buffer has been removed... OR change type ...");
return audio::blockEngine::ERR_FAIL;
}
//request outpuffer needed size :
buffer->setProperty(_request);
uint8_t* data = buffer->getData();
if (m_file == nullptr) {
ABE_ERROR("Buffer output error ==> !!ERROR!!");
return audio::blockEngine::ERR_FAIL;
}
int64_t nbRead = m_file->fileRead(data, sizeof(uint8_t), _request);
buffer->setAvaillableSize(nbRead);
return audio::blockEngine::ERR_NONE;
}
int32_t audio::blockEngine::GeneratorFile::init() {
m_file = new etk::FSNode("DATA:menu.wav");
if (m_file == nullptr) {
ABE_ERROR("Can not allocate the input file ...");
return audio::blockEngine::ERR_FAIL;
}
if (m_file->fileOpenRead() == false) {
ABE_ERROR("Can not open the input file ...");
return audio::blockEngine::ERR_FAIL;
}
return audio::blockEngine::ERR_NONE;
}
int32_t audio::blockEngine::GeneratorFile::unInit() {
if (m_file == nullptr) {
return audio::blockEngine::ERR_NONE;
}
if (m_file->fileClose() == false) {
ABE_ERROR("Can not close the input file ...");
delete(m_file);
m_file = nullptr;
return audio::blockEngine::ERR_FAIL;
}
delete(m_file);
m_file = nullptr;
return audio::blockEngine::ERR_NONE;
}

View File

@ -0,0 +1,28 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/BlockGenerator.hpp>
#include <etk/os/FSNode.hpp>
namespace audio {
namespace blockEngine {
class GeneratorFile : public audio::blockEngine::BlockGenerator {
public:
GeneratorFile();
virtual ~GeneratorFile() {};
protected:
etk::FSNode* m_file;
public: // herieted function :
virtual int32_t pull(double _currentTime, int32_t _request, float _timeout);
virtual int32_t init();
virtual int32_t unInit();
};
}
}

View File

@ -0,0 +1,25 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/base/GeneratorRtAudio.hpp>
#include <audio/blockEngine/core/BufferAudioRaw.hpp>
#include <airtaudio/Interface.hpp>
audio::blockEngine::GeneratorRiver::GeneratorRiver() {
setLive(true);
// set output :
m_io.insert(
std::pair<std::string, audio::blockEngine::Block::IOProperty>(
"out",
audio::blockEngine::Block::IOProperty(
audio::blockEngine::Block::ioOutput,
"",
new audio::blockEngine::BufferAudioRaw(*this, 48000, 2)
) ) );
};

View File

@ -0,0 +1,23 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/BlockGenerator.hpp>
namespace audio {
namespace blockEngine {
class GeneratorRiver : public audio::blockEngine::BlockGenerator {
public:
GeneratorRiver();
virtual ~GeneratorRiver() {};
public:
int32_t pull(double _currentTime, int32_t _request, float _timeout);
};
}
}

View File

@ -0,0 +1,61 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/base/GeneratorSignal.hpp>
#include <audio/blockEngine/core/BufferAudio.hpp>
#include <cmath>
void audio::blockEngine::GeneratorSignal::init() {
audio::blockEngine::Block::init();
}
audio::blockEngine::GeneratorSignal::GeneratorSignal() :
m_phase(0),
m_output(*this, "out", "Output sinus generated", "{ type:'audio', freq:48000, format:['int16','int32'], channels:2}") {
addObjectType("audio::blockEngine::GeneratorSignal");
}
int32_t audio::blockEngine::GeneratorSignal::algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
ABE_INFO("Process: " << _currentTime << " chunkTime=" << _processTimeSlot);
return audio::blockEngine::ERR_NONE;
}
#if 0
int32_t audio::blockEngine::GeneratorSignal::pull(double _currentTime, int32_t _request, float _timeout) {
auto it = m_io.find("out");
if (it == m_io.end()) {
ABE_WARNING("request to pull data with no output !!!");
return audio::blockEngine::ERR_FAIL;
}
audio::blockEngine::BufferAudioRaw* buffer = dynamic_cast<audio::blockEngine::BufferAudioRaw*>(it->second.m_buffer);
//ABE_ERROR("Generate data, request : " << _request << " at time : " << _currentTime);
if (buffer == nullptr) {
// !! impossible case => a buffer can not be removed ...
ABE_ERROR("Buffer has been removed... OR change type ...");
return audio::blockEngine::ERR_FAIL;
}
//request outpuffer needed size :
buffer->setProperty(48000, 2, _request);
float* data = buffer->getData();
for (int32_t iii=0; iii<_request; ++iii) {
for (int32_t jjj=0; jjj<2; ++jjj) {
*data++ = cos(m_phase)*0.5f;
}
m_phase += 0.1;
if (m_phase > 4.0*M_PI) {
m_phase -= 4.0*M_PI;
}
}
/*
FILE* plopppp = fopen("plop.raw", "a");
fwrite(buffer->getData(), sizeof(float), _request*2, plopppp);
fflush(plopppp);
fclose(plopppp);
*/
return audio::blockEngine::ERR_NONE;
}
#endif

View File

@ -0,0 +1,30 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/Block.hpp>
#include <audio/blockEngine/core/BufferAudio.hpp>
namespace audio {
namespace blockEngine {
class GeneratorSignal : public audio::blockEngine::Block {
protected:
float m_phase;
protected:
GeneratorSignal();
void init();
public:
DECLARE_FACTORY(GeneratorSignal);
virtual ~GeneratorSignal() {};
public:
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot);
protected:
audio::blockEngine::flow::Output<audio::blockEngine::BufferAudio> m_output;
};
}
}

View File

@ -0,0 +1,94 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/base/ReceiverFile.hpp>
audio::blockEngine::ReceiverFile::ReceiverFile() :
m_file(nullptr),
m_channels(4),
m_frequency(16000),
m_requestSize(256),
m_processStarted(false) {
// set input :
m_io.insert(
std::pair<std::string, audio::blockEngine::Block::IOProperty>(
"in",
audio::blockEngine::Block::IOProperty(
audio::blockEngine::Block::ioInput,
"{ type:'audio', compression:'raw', frequency:16000, channel:4, format:'int16_t' }",
nullptr
) ) );
}
int32_t audio::blockEngine::ReceiverFile::init() {
m_file = new etk::FSNode("ouput.raw");
if (m_file == nullptr) {
ABE_ERROR("Can not allocate the output file ...");
return audio::blockEngine::ERR_FAIL;
}
if (m_file->fileOpenWrite() == false) {
ABE_ERROR("Can not open the output file ...");
return audio::blockEngine::ERR_FAIL;
}
return audio::blockEngine::ERR_NONE;
};
int32_t audio::blockEngine::ReceiverFile::unInit() {
ABE_DEBUG("un-init Stream ...");
if (m_file == nullptr) {
return audio::blockEngine::ERR_NONE;
}
if (m_file->fileClose() == false) {
ABE_ERROR("Can not close the input file ...");
delete(m_file);
m_file = nullptr;
return audio::blockEngine::ERR_FAIL;
}
delete(m_file);
m_file = nullptr;
return audio::blockEngine::ERR_NONE;
};
int32_t audio::blockEngine::ReceiverFile::start() {
ABE_DEBUG("Start stream ...");
m_processStarted = true;
return audio::blockEngine::ERR_NONE;
};
int32_t audio::blockEngine::ReceiverFile::stop() {
ABE_DEBUG("Stop Stream ...");
m_processStarted = false;
return audio::blockEngine::ERR_NONE;
};
/*
int32_t audio::blockEngine::ReceiverFile::pull(double _currentTime, int32_t _request, float _timeout) {
auto it = m_io.find("out");
if (it == m_io.end()) {
ABE_WARNING("request to pull data with no output !!!");
return audio::blockEngine::ERR_FAIL;
}
audio::blockEngine::BufferStream* buffer = dynamic_cast<audio::blockEngine::BufferStream*>(it->second.m_buffer);
//ABE_ERROR("Generate data, request : " << _request << " at time : " << _currentTime);
if (buffer == nullptr) {
// !! impossible case => a buffer can not be removed ...
ABE_ERROR("Buffer has been removed... OR change type ...");
return audio::blockEngine::ERR_FAIL;
}
//request outpuffer needed size :
buffer->setProperty(_request);
uint8_t* data = buffer->getData();
if (m_file == nullptr) {
ABE_ERROR("Buffer output error ==> !!ERROR!!");
return audio::blockEngine::ERR_FAIL;
}
int64_t nbRead = m_file->fileRead(data, sizeof(uint8_t), _request);
buffer->setAvaillableSize(nbRead);
return audio::blockEngine::ERR_NONE;
}
*/

View File

@ -0,0 +1,33 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/BlockReceiver.hpp>
#include <etk/os/FSNode.hpp>
namespace audio {
namespace blockEngine {
class ReceiverFile : public audio::blockEngine::BlockReceiver {
public:
ReceiverFile();
virtual ~ReceiverFile() {};
public: // herieted function :
virtual int32_t init();
virtual int32_t unInit();
private:
etk::FSNode* m_file;
uint32_t m_channels;
uint32_t m_frequency;
uint32_t m_requestSize;
bool m_processStarted;
public:
virtual int32_t start();
virtual int32_t stop();
};
}
}

View File

@ -4,53 +4,53 @@
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/base/ReceiverRiver.hpp>
#include <eaudiofx/core/BufferAudio.hpp>
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/base/ReceiverRiver.hpp>
#include <audio/blockEngine/core/BufferAudio.hpp>
int32_t eaudiofx::ReceiverRiver::algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
EAUDIOFX_INFO("Process: " << _currentTime << " chunkTime=" << _processTimeSlot);
return eaudiofx::ERR_NONE;
int32_t audio::blockEngine::ReceiverRiver::algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
ABE_INFO("Process: " << _currentTime << " chunkTime=" << _processTimeSlot);
return audio::blockEngine::ERR_NONE;
}
void eaudiofx::ReceiverRiver::init() {
eaudiofx::Block::init();
void audio::blockEngine::ReceiverRiver::init() {
audio::blockEngine::Block::init();
}
eaudiofx::ReceiverRiver::ReceiverRiver() :
audio::blockEngine::ReceiverRiver::ReceiverRiver() :
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']}") {
addObjectType("eaudiofx::ReceiverRtAudio");
addObjectType("audio::blockEngine::ReceiverRtAudio");
};
void eaudiofx::ReceiverRiver::onDataNeeded(void* _data,
void audio::blockEngine::ReceiverRiver::onDataNeeded(void* _data,
const audio::Time& _time,
size_t _nbChunk,
enum audio::format _format,
uint32_t _frequency,
const std::vector<audio::channel>& _map) {
if (_format != audio::format_int16) {
EAUDIOFX_ERROR("call wrong type ... (need int16_t)");
ABE_ERROR("call wrong type ... (need int16_t)");
}
int16_t* data = static_cast<int16_t*>(_data);
int32_t nbData = std::min(m_buffer.size()/2, _nbChunk*2);
for (int32_t iii=0; iii<nbData*2; ++iii) {
((int8_t*)_data)[iii] = m_buffer[iii];
//EAUDIOFX_ERROR("write : " << data[iii]);
//ABE_ERROR("write : " << data[iii]);
}
}
int32_t eaudiofx::ReceiverRiver::algoInit() {
EAUDIOFX_DEBUG("Intanciate audio::river Manager ...");
int32_t audio::blockEngine::ReceiverRiver::algoInit() {
ABE_DEBUG("Intanciate audio::river Manager ...");
m_manager = audio::river::Manager::create("eaudio-fx-output");
if (m_manager == nullptr) {
EAUDIOFX_ERROR("Can not intanciate RIVER interface");
return eaudiofx::ERR_FAIL;
ABE_ERROR("Can not intanciate RIVER interface");
return audio::blockEngine::ERR_FAIL;
}
//Set stereo output:
std::vector<audio::channel> channelMap;
@ -61,8 +61,8 @@ int32_t eaudiofx::ReceiverRiver::algoInit() {
audio::format_int16,
"speaker");
if(m_interface == nullptr) {
EAUDIOFX_ERROR("nullptr interface");
return eaudiofx::ERR_FAIL;
ABE_ERROR("nullptr interface");
return audio::blockEngine::ERR_FAIL;
}
// set callback mode ...
m_interface->setOutputCallback(std::bind(&ReceiverRiver::onDataNeeded,
@ -74,37 +74,37 @@ int32_t eaudiofx::ReceiverRiver::algoInit() {
std::placeholders::_5,
std::placeholders::_6));
m_interface->start();
return eaudiofx::ERR_NONE;
return audio::blockEngine::ERR_NONE;
};
int32_t eaudiofx::ReceiverRiver::algoUnInit() {
EAUDIOFX_DEBUG("un-init Stream ...");
int32_t audio::blockEngine::ReceiverRiver::algoUnInit() {
ABE_DEBUG("un-init Stream ...");
if(m_interface == nullptr) {
EAUDIOFX_ERROR("nullptr interface");
return eaudiofx::ERR_FAIL;
ABE_ERROR("nullptr interface");
return audio::blockEngine::ERR_FAIL;
}
m_interface.reset();
m_manager.reset();
return eaudiofx::ERR_NONE;
return audio::blockEngine::ERR_NONE;
};
int32_t eaudiofx::ReceiverRiver::algoStart() {
EAUDIOFX_DEBUG("Start stream ...");
int32_t audio::blockEngine::ReceiverRiver::algoStart() {
ABE_DEBUG("Start stream ...");
if(m_interface == nullptr) {
EAUDIOFX_ERROR("nullptr interface");
return eaudiofx::ERR_FAIL;
ABE_ERROR("nullptr interface");
return audio::blockEngine::ERR_FAIL;
}
m_interface->start();
return eaudiofx::ERR_NONE;
return audio::blockEngine::ERR_NONE;
};
int32_t eaudiofx::ReceiverRiver::algoStop() {
EAUDIOFX_DEBUG("Stop Stream ...");
int32_t audio::blockEngine::ReceiverRiver::algoStop() {
ABE_DEBUG("Stop Stream ...");
if(m_interface == nullptr) {
EAUDIOFX_ERROR("nullptr interface");
return eaudiofx::ERR_FAIL;
ABE_ERROR("nullptr interface");
return audio::blockEngine::ERR_FAIL;
}
m_interface->stop();
return eaudiofx::ERR_NONE;
return audio::blockEngine::ERR_NONE;
};

View File

@ -0,0 +1,50 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/Block.hpp>
#include <audio/river/Interface.hpp>
#include <audio/river/Manager.hpp>
#include <audio/blockEngine/core/BufferAudio.hpp>
namespace audio {
namespace blockEngine {
class ReceiverRiver : public audio::blockEngine::Block {
private:
void onDataNeeded(void* _data,
const audio::Time& _time,
size_t _nbChunk,
enum audio::format _format,
uint32_t _frequency,
const std::vector<audio::channel>& _map);
protected:
ReceiverRiver();
void init();
public:
DECLARE_FACTORY(ReceiverRiver);
virtual ~ReceiverRiver() {};
public: // herieted function :
virtual int32_t algoInit();
virtual int32_t algoUnInit();
private:
bool m_processStarted;
public:
virtual int32_t algoStart();
virtual int32_t algoStop();
protected:
ememory::SharedPtr<audio::river::Manager> m_manager;
ememory::SharedPtr<audio::river::Interface> m_interface;
std::vector<int8_t> m_buffer;
public:
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot);
protected:
audio::blockEngine::flow::Input<audio::blockEngine::BufferAudio> m_input;
};
}
}

View File

@ -0,0 +1,38 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/core/Block.hpp>
#include <audio/blockEngine/core/Buffer.hpp>
#include <audio/blockEngine/core/BlockMeta.hpp>
audio::blockEngine::Block::Block() {
addObjectType("audio::blockEngine::Block");
}
audio::blockEngine::Block::~Block() {
}
ememory::SharedPtr<audio::blockEngine::Block> audio::blockEngine::Block::getBlockNamed(const std::string& _name) {
ememory::SharedPtr<audio::blockEngine::Block> out;
ABE_INFO(" get block : " << _name);
ewol::ObjectShared parrent = m_parent.lock();
if (parrent != nullptr) {
ememory::SharedPtr<audio::blockEngine::Block> parrentBlock = ememory::dynamicPointerCast<audio::blockEngine::Block>(parrent);
if (parrentBlock != nullptr) {
return parrentBlock->getBlockNamed(_name);
} else {
ABE_INFO(" Parent is not a Block ...");
}
} else {
ABE_INFO(" No parent ...");
}
return out;
}

View File

@ -0,0 +1,96 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <string>
#include <mutex>
#include <map>
#include <ewol/object/Object.hpp>
#include <audio/blockEngine/core/audio.hpp>
#include <audio/blockEngine/flow/Interface.hpp>
#include <audio/blockEngine/flow/Flow.hpp>
namespace audio {
namespace blockEngine {
class Buffer;
class BlockMeta;
class Block : public ewol::Object,
public audio::blockEngine::flow::Interface {
protected:
Block();
void init() {
ewol::Object::init();
}
public:
DECLARE_FACTORY(Block);
virtual ~Block();
protected:
std::mutex m_mutex; //!< Block mutex access
public:
/**
* @brief Init the block with the properties
* @return A generic error.
*/
virtual int32_t algoInit() {
return audio::blockEngine::ERR_NONE;
};
/**
* @brief UnInit the block with the properties
* @return A generic error.
*/
virtual int32_t algoUnInit() {
return audio::blockEngine::ERR_NONE;
};
virtual int32_t algoStart() {
return audio::blockEngine::ERR_NONE;
};
virtual int32_t algoStop() {
return audio::blockEngine::ERR_NONE;
};
public:
/**
* @brief get if the block support the native push interface
* @return true if the mode is supported
*/
virtual bool supportNativePush() {
return false;
}
/**
* @brief get if the block support the native pull interface
* @return true if the mode is supported
*/
virtual bool supportNativePull() {
return false;
}
/**
* @brief get if the block support the native Time interface
* @return true if the mode is supported
*/
virtual bool supportNativeTime() {
return false;
}
/**
* @brief Reset the block
* @return generic error
*/
virtual int32_t algoReset() {
return audio::blockEngine::ERR_NONE;
};
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
return audio::blockEngine::ERR_NONE;
}
virtual ememory::SharedPtr<audio::blockEngine::Block> getBlockNamed(const std::string& _name);
};
}
}

View File

@ -0,0 +1,244 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/core/BlockMeta.hpp>
audio::blockEngine::BlockMeta::BlockMeta() {
addObjectType("audio::blockEngine::BlockMeta");
}
audio::blockEngine::BlockMeta::~BlockMeta() {
// TODO : Unlink all ...
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
ememory::SharedPtr<audio::blockEngine::Block> tmp = it;
it.reset();
}
m_list.clear();
}
ememory::SharedPtr<audio::blockEngine::Block> audio::blockEngine::BlockMeta::getBlock(const std::string& _name) {
if (_name.size() == 0) {
return nullptr;
}
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->propertyName.get() == _name) {
return it;
}
}
return nullptr;
}
int32_t audio::blockEngine::BlockMeta::addBlock(ememory::SharedPtr<audio::blockEngine::Block> _block) {
if (_block == nullptr) {
ABE_ERROR("[" << getId() << "] Add nullptr block");
return audio::blockEngine::ERR_INPUT_NULL;
}
if (_block->propertyName.get().size() > 0 ) {
// Check if name exist :
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->propertyName.get() == _block->propertyName.get()) {
ABE_ERROR("[" << getId() << "] Add block name '" << _block->propertyName.get() << "' already exist");
return audio::blockEngine::ERR_ALREADY_EXIST;
}
}
}
m_list.push_back(_block);
_block->setParent(sharedFromThis());
return audio::blockEngine::ERR_NONE;
}
int32_t audio::blockEngine::BlockMeta::addBlock(const std::string& _blockType, const std::string& _name) {
ABE_ERROR("NOT IMPLEMENTED");
return audio::blockEngine::ERR_NOT_IMPLEMENTED;
}
int32_t audio::blockEngine::BlockMeta::removeBlock(const std::string& _name) {
ABE_ERROR("NOT IMPLEMENTED");
return audio::blockEngine::ERR_NOT_IMPLEMENTED;
}
int32_t audio::blockEngine::BlockMeta::linkBlock(const std::string& _generatorBlockName,
const std::string& _generatorIoName,
const std::string& _receiverBlockName,
const std::string& _receiverIoName) {
// TODO : proxy IOs
ememory::SharedPtr<audio::blockEngine::Block> receive = getBlock(_receiverBlockName);
if (receive == nullptr) {
ABE_ERROR("Can not find destination block : '" << _receiverBlockName << "'");
return audio::blockEngine::ERR_FAIL;
}
receive->flowSetLinkWith(_receiverIoName, _generatorBlockName, _generatorIoName);
return audio::blockEngine::ERR_NONE;
}
int32_t audio::blockEngine::BlockMeta::openFile(const std::string& _fileName) {
ABE_ERROR("NOT IMPLEMENTED");
return audio::blockEngine::ERR_NOT_IMPLEMENTED;
}
int32_t audio::blockEngine::BlockMeta::openStream(const std::string& _stream) {
ABE_ERROR("NOT IMPLEMENTED");
return audio::blockEngine::ERR_NOT_IMPLEMENTED;
}
int32_t audio::blockEngine::BlockMeta::algoInit() {
ABE_INFO("[" << getId() << "]Init Meta block : '" << propertyName << "'");
int32_t ret = audio::blockEngine::ERR_NONE;
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->algoInit() != audio::blockEngine::ERR_NONE) {
ret = audio::blockEngine::ERR_FAIL;
}
}
if (ret != audio::blockEngine::ERR_NONE) {
ABE_WARNING("Pb when init the Meta-block '" << propertyName << "' ");
}
return ret;
};
int32_t audio::blockEngine::BlockMeta::algoUnInit() {
int32_t ret = audio::blockEngine::ERR_NONE;
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->algoUnInit() != audio::blockEngine::ERR_NONE) {
ret = audio::blockEngine::ERR_FAIL;
}
}
if (ret != audio::blockEngine::ERR_NONE) {
ABE_WARNING("Pb when un-init the Meta-block '" << propertyName << "' ");
}
return ret;
};
int32_t audio::blockEngine::BlockMeta::algoStart() {
ABE_INFO("[" << getId() << "] Start Meta block : '" << propertyName << "'");
int32_t ret = audio::blockEngine::ERR_NONE;
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->algoStart() != audio::blockEngine::ERR_NONE) {
ret = audio::blockEngine::ERR_FAIL;
}
}
if (ret != audio::blockEngine::ERR_NONE) {
ABE_WARNING("Pb when start the Meta-block '" << propertyName << "' ");
}
return ret;
};
int32_t audio::blockEngine::BlockMeta::algoStop() {
ABE_INFO("[" << getId() << "] Stop Meta block : '" << propertyName << "'");
int32_t ret = audio::blockEngine::ERR_NONE;
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->algoStop() != audio::blockEngine::ERR_NONE) {
ret = audio::blockEngine::ERR_FAIL;
}
}
if (ret != audio::blockEngine::ERR_NONE) {
ABE_WARNING("Pb when stop the Meta-block '" << propertyName << "' ");
}
return ret;
};
ememory::SharedPtr<audio::blockEngine::Block> audio::blockEngine::BlockMeta::getBlockNamed(const std::string& _name) {
ememory::SharedPtr<audio::blockEngine::Block> out;
ABE_DEBUG("[" << propertyName << "] try get Block : " << _name);
// Special case for proxy flow ...
if ( _name == ""
|| _name == propertyName.get()) {
ABE_DEBUG(" ==> find Him");
return ememory::staticPointerCast<audio::blockEngine::Block>(sharedFromThis());
}
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
ABE_DEBUG(" check : " << it->propertyName.get());
if (it->propertyName.get() == _name) {
out = it;
ABE_DEBUG(" ==> find this one");
break;
}
}
return out;
}
void audio::blockEngine::BlockMeta::flowLinkInput() {
ABE_INFO("[" << getId() << "] Meta block Link: '" << propertyName << "'");
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
it->flowLinkInput();
}
// Call upper class
audio::blockEngine::Block::flowLinkInput();
}
void audio::blockEngine::BlockMeta::flowCheckAllCompatibility() {
ABE_INFO("[" << getId() << "] Meta block check compatibilities: '" << propertyName << "'");
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
it->flowCheckAllCompatibility();
}
// Call upper class
audio::blockEngine::Block::flowCheckAllCompatibility();
}
void audio::blockEngine::BlockMeta::flowAllocateOutput() {
ABE_INFO("[" << getId() << "] Meta block allocate output: '" << propertyName << "'");
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
it->flowAllocateOutput();
}
// Call upper class
audio::blockEngine::Block::flowAllocateOutput();
}
void audio::blockEngine::BlockMeta::flowGetInput() {
ABE_INFO("[" << getId() << "] Meta block get input ... : '" << propertyName << "'");
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
it->flowGetInput();
}
// Call upper class
audio::blockEngine::Block::flowGetInput();
}

View File

@ -0,0 +1,92 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/Block.hpp>
#include <vector>
namespace audio {
namespace blockEngine {
class BlockMeta : public audio::blockEngine::Block {
protected:
BlockMeta();
void init() {
audio::blockEngine::Block::init();
}
public:
DECLARE_FACTORY(BlockMeta);
virtual ~BlockMeta();
private:
std::vector<ememory::SharedPtr<audio::blockEngine::Block>> m_list; //!< list of all block to process.
protected:
/**
* @brief Get a pointer on a specific block.
* @param[in] _name Name of the block.
* @return generic error
*/
ememory::SharedPtr<audio::blockEngine::Block> getBlock(const std::string& _name);
public:
/**
* @brief Add a block in the Meta-block
* @param[in] _block Pointer on the block (do not free yourself)
* @return generic error
*/
int32_t addBlock(ememory::SharedPtr<audio::blockEngine::Block> _block);
/**
* @brief Add a block in the Meta-block.
* @param[in] _blockType Name of the type of block to add.
* @param[in] _name Name of the block to add.
* @return generic error
*/
int32_t addBlock(const std::string& _blockType, const std::string& _name = "");
/**
* @brief Remove a block from the Meta-block
* @param[in] _name Name of the block to remove
* @note This free the block pointer
* @return generic error
*/
int32_t removeBlock(const std::string& _name);
/**
* @brief Link 2 IO.
* @param[in] _generatorBlockName Name ot the generator Block
* @param[in] _generatorIoName Name of the outout
* @param[in] _receiverBlockName Name ot the receiver Block
* @param[in] _receiverIoName Name of the input
* @return generic error
*/
int32_t linkBlock(const std::string& _generatorBlockName,
const std::string& _generatorIoName,
const std::string& _receiverBlockName,
const std::string& _receiverIoName);
/**
* @brief Open file property
* @param[in] _fileName Name of the file to open
* @return generic error
*/
int32_t openFile(const std::string& _fileName);
/**
* @brief Open stream property
* @param[in] _stream data stream to open
* @return generic error
*/
int32_t openStream(const std::string& _stream);
public: // herited function
virtual int32_t algoInit();
virtual int32_t algoUnInit();
virtual int32_t algoStart();
virtual int32_t algoStop();
virtual ememory::SharedPtr<audio::blockEngine::Block> getBlockNamed(const std::string& _name);
virtual void flowLinkInput();
virtual void flowCheckAllCompatibility();
virtual void flowAllocateOutput();
virtual void flowGetInput();
};
}
}

View File

@ -4,9 +4,9 @@
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/core/Buffer.hpp>
#include <audio/blockEngine/core/Buffer.hpp>
eaudiofx::Buffer::Buffer(eaudiofx::Block& _parent) :
audio::blockEngine::Buffer::Buffer(audio::blockEngine::Block& _parent) :
m_parent(_parent),
m_timestamp(0),
m_timeSize(0) {

View File

@ -0,0 +1,27 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/audio.hpp>
#include <audio/blockEngine/core/Block.hpp>
namespace audio {
namespace blockEngine {
class Block;
class Buffer : public ememory::EnableSharedFromThis<Buffer> {
public:
Buffer(audio::blockEngine::Block& _parent);
virtual ~Buffer() {};
protected:
audio::blockEngine::Block& m_parent; //!< parrent Block of this Buffer
protected:
int64_t m_timestamp; //!< current buffer time
int64_t m_timeSize; //!< current buffer data time size
};
}
}

View File

@ -4,12 +4,12 @@
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/core/BufferAudio.hpp>
#include <eaudiofx/debug.hpp>
#include <audio/blockEngine/core/BufferAudio.hpp>
#include <audio/blockEngine/debug.hpp>
eaudiofx::BufferAudio::BufferAudio(eaudiofx::Block& _parent, const std::string& _description) :
eaudiofx::Buffer(_parent),
audio::blockEngine::BufferAudio::BufferAudio(audio::blockEngine::Block& _parent, const std::string& _description) :
audio::blockEngine::Buffer(_parent),
m_frequency(48000),
m_channelMap({audioChannelFrontLeft,audioChannelFrontRight}),
m_format(audioFormatInt16),
@ -19,11 +19,11 @@ eaudiofx::BufferAudio::BufferAudio(eaudiofx::Block& _parent, const std::string&
resize(32);
}
eaudiofx::BufferAudio::BufferAudio(eaudiofx::Block& _parent,
audio::blockEngine::BufferAudio::BufferAudio(audio::blockEngine::Block& _parent,
int32_t _frequency,
const std::vector<enum audioChannel>& _map,
enum audioFormat _format) :
eaudiofx::Buffer(_parent),
audio::blockEngine::Buffer(_parent),
m_frequency(_frequency),
m_channelMap(_map),
m_format(_format),
@ -51,21 +51,21 @@ eaudiofx::BufferAudio::BufferAudio(eaudiofx::Block& _parent,
resize(32);
}
eaudiofx::BufferAudio::~BufferAudio() {
audio::blockEngine::BufferAudio::~BufferAudio() {
}
void eaudiofx::BufferAudio::clear() {
void audio::blockEngine::BufferAudio::clear() {
for (auto &it : m_data) {
it = 0;
}
}
void eaudiofx::BufferAudio::resize(size_t _nbChunks) {
void audio::blockEngine::BufferAudio::resize(size_t _nbChunks) {
m_data.resize(m_chunkSize*_nbChunks, 0);
}
size_t eaudiofx::BufferAudio::size() {
size_t audio::blockEngine::BufferAudio::size() {
return m_data.size() / m_chunkSize;
}

View File

@ -0,0 +1,75 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/Buffer.hpp>
namespace audio {
namespace blockEngine {
enum audioFormat {
audioFormatInt8,
audioFormatInt16,
audioFormatInt24,
audioFormatInt32,
audioFormatIntFloat,
audioFormatIntDouble,
audioFormatInt16OverInt32
};
enum audioChannel {
audioChannelFrontLeft, //!< channel Front Left
audioChannelFrontCenter, //!< channel Front Center
audioChannelFrontRight, //!< channel Front Right
audioChannelRearLeft, //!< channel rear Left
audioChannelRearCenter, //!< channel rear Center
audioChannelRearRight, //!< channel rear Right
audioChannelSurroundLeft, //!< channel surround Left
audioChannelSurroundRight, //!< channel surround Right
audioChannelSubWoofer, //!< channel Sub-woofer
audioChannelLFE //!< channel Low frequency
};
class BufferAudio : public audio::blockEngine::Buffer {
public:
BufferAudio(audio::blockEngine::Block& _parent,
int32_t _frequency=48000,
const std::vector<enum audioChannel>& _map={audioChannelFrontLeft,audioChannelFrontRight},
enum audioFormat _format=audioFormatInt16);
BufferAudio(audio::blockEngine::Block& _parent,
const std::string& _description);
virtual ~BufferAudio();
protected:
int32_t m_frequency;
std::vector<enum audioChannel> m_channelMap;
enum audioFormat m_format;
protected:
std::vector<int8_t> m_data; //!< pointer on the data.
int8_t m_sampleSize; //!< Size of one sample
int8_t m_chunkSize; //!< Size of one chunk Size
public:
/**
* @brief Get the buffer casted in float*
* @return Pointer on the buffer with correct cast.
*/
template<typename T> T* getData() {
return static_cast<T*>(&m_data[0]);
}
/**
* @breif Clean all sample in the buffer
*/
void clear();
/**
* @brief Resize the buffer at a new size.
* @param[in] _nbChunks Number of chunk requested.
*/
void resize(size_t _nbChunks);
/**
* @brief Get number of chunk in the buffer.
* @return Number of chunk in the buffer.
*/
size_t size();
};
}
}

View File

@ -0,0 +1,12 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/core/BufferAudioFreq.hpp>
audio::blockEngine::BufferAudioFreq::BufferAudioFreq(audio::blockEngine::Block& _parent) :
audio::blockEngine::BufferAudio(_parent) {
}

View File

@ -0,0 +1,20 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/BufferAudio.hpp>
namespace audio {
namespace blockEngine {
class BufferAudioFreq : public audio::blockEngine::BufferAudio {
public:
BufferAudioFreq(audio::blockEngine::Block& _parent);
virtual ~BufferAudioFreq() {};
};
}
}

View File

@ -0,0 +1,75 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/core/Processing.hpp>
#include <unistd.h>
audio::blockEngine::Processing::Processing() {
addObjectType("audio::blockEngine::Processing");
};
int32_t audio::blockEngine::Processing::process() {
ABE_INFO("Start process : '" << propertyName << "'");
return audio::blockEngine::ERR_NONE;
}
int32_t audio::blockEngine::Processing::start() {
audio::blockEngine::Thread::start();
return audio::blockEngine::ERR_NONE;
}
int32_t audio::blockEngine::Processing::stop() {
audio::blockEngine::Thread::stop();
return audio::blockEngine::ERR_NONE;
}
int32_t audio::blockEngine::Processing::waitEndOfProcess() {
ABE_INFO("wait end of Processing : '" << propertyName << "'");
return audio::blockEngine::ERR_NONE;
}
bool audio::blockEngine::Processing::stateStart() {
ABE_INFO("Start Processing : '" << propertyName << "'");
// TODO : Add return code ... and test all of theses events ...
ABE_ERROR("======================================");
// Init request flow update:
flowLinkInput();
ABE_ERROR("======================================");
// check if the IOs are compatible
flowCheckAllCompatibility();
ABE_ERROR("======================================");
// Allocate all Outputs
flowAllocateOutput();
ABE_ERROR("======================================");
// Get pointer on all Inputs
flowGetInput();
ABE_ERROR("======================================");
// init algorithm
int32_t ret = algoInit();
if (ret != audio::blockEngine::ERR_NONE) {
return ret;
}
audio::blockEngine::BlockMeta::algoStart();
return false;
}
bool audio::blockEngine::Processing::stateRun() {
ABE_INFO("Process : '" << propertyName << "'");
usleep(10000);
return false;
}
bool audio::blockEngine::Processing::stateStop() {
ABE_INFO("Stop Processing : '" << propertyName << "'");
int32_t ret = audio::blockEngine::BlockMeta::algoStop();
if (ret != audio::blockEngine::ERR_NONE) {
return ret;
}
algoUnInit();
return false;
}

View File

@ -0,0 +1,40 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/audio.hpp>
#include <audio/blockEngine/core/Buffer.hpp>
#include <audio/blockEngine/core/Block.hpp>
#include <audio/blockEngine/core/BlockMeta.hpp>
#include <audio/blockEngine/Thread.hpp>
#include <vector>
namespace audio {
namespace blockEngine {
class Processing : public audio::blockEngine::BlockMeta, audio::blockEngine::Thread {
protected:
Processing();
void init() {
audio::blockEngine::BlockMeta::init();
};
public:
DECLARE_FACTORY(Processing);
virtual ~Processing() {};
public:
int32_t process();
int32_t start();
int32_t stop();
int32_t waitEndOfProcess();
// Thread interface :
virtual bool stateStart();
virtual bool stateRun();
virtual bool stateStop();
};
}
}

View File

@ -4,6 +4,6 @@
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/core/audio.hpp>
#include <audio/blockEngine/core/audio.hpp>

View File

@ -0,0 +1,24 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
namespace audio {
namespace blockEngine {
enum {
ERR_NONE = 0,
ERR_NOT_IMPLEMENTED,
ERR_FAIL,
ERR_ALREADY_EXIST,
ERR_INPUT_NULL,
ERR_FORBIDEN,
ERR_NO_IO,
};
}
}

View File

@ -4,9 +4,9 @@
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <audio/blockEngine/debug.hpp>
int32_t eaudiofx::getLogId() {
int32_t audio::blockEngine::getLogId() {
static int32_t g_val = elog::registerInstance("eaudiofx");
return g_val;
}

View File

@ -0,0 +1,41 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <elog/log.hpp>
namespace audio {
namespace blockEngine {
int32_t getLogId();
}
}
#define ABE_BASE(info,data) ELOG_BASE(audio::blockEngine::getLogId(),info,data)
#define ABE_PRINT(data) ABE_BASE(1, data)
#define ABE_CRITICAL(data) ABE_BASE(1, data)
#define ABE_ERROR(data) ABE_BASE(2, data)
#define ABE_WARNING(data) ABE_BASE(3, data)
#ifdef DEBUG
#define ABE_INFO(data) ABE_BASE(4, data)
#define ABE_DEBUG(data) ABE_BASE(5, data)
#define ABE_VERBOSE(data) ABE_BASE(6, data)
#define ABE_TODO(data) ABE_BASE(4, "TODO : " << data)
#else
#define ABE_INFO(data) do { } while(false)
#define ABE_DEBUG(data) do { } while(false)
#define ABE_VERBOSE(data) do { } while(false)
#define ABE_TODO(data) do { } while(false)
#endif
#define ABE_ASSERT(cond,data) \
do { \
if (!(cond)) { \
ABE_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)

View File

@ -0,0 +1,14 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <audio/blockEngine/core/audio.hpp>
#include <audio/blockEngine/core/Block.hpp>
#include <audio/blockEngine/core/Buffer.hpp>
#include <audio/blockEngine/core/Processing.hpp>

View File

@ -0,0 +1,78 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/flow/Interface.hpp>
#include <audio/blockEngine/flow/Base.hpp>
#include <audio/blockEngine/core/Block.hpp>
audio::blockEngine::flow::Base::Base(audio::blockEngine::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) {
m_ref = ememory::makeShared<BaseReference>(this);
// add a reference on the current signal ...
m_flowInterfaceLink.flowAdd(this);
m_formatAvaillable.parse(_formatAvaillable);
ABE_INFO("Create flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' prop:");
m_formatAvaillable.display();
}
audio::blockEngine::flow::Base::~Base() {
m_ref->removeBase();
ABE_INFO("Remove flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "'");
};
std::ostream& audio::blockEngine::flow::operator <<(std::ostream& _os, const audio::blockEngine::flow::Base& _obj) {
_os << _obj.getName();
return _os;
}
void audio::blockEngine::flow::Base::link() {
ABE_INFO(" link flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' (no code)");
}
int32_t audio::blockEngine::flow::Base::checkCompatibility() {
ABE_INFO(" check flow : '" << m_name << "' (no code)");
return -1;
}
void audio::blockEngine::flow::Base::getInputBuffer() {
ABE_INFO(" get Buffers : '" << m_name << "' (no code)");
}
// due to the fact it acces at the block interface, we need to write it here ...
ememory::SharedPtr<audio::blockEngine::flow::BaseReference> audio::blockEngine::flow::Base::getFlowReference(const std::string& _blockName,
const std::string& _flowLinkName) {
ememory::SharedPtr<audio::blockEngine::flow::BaseReference> out;
if (_flowLinkName == "") {
ABE_INFO(" Get flow : " << _blockName << ":" << _flowLinkName << " nothing to do ==> no connection ...");
}
ememory::SharedPtr<audio::blockEngine::Block> blockRemote = m_flowInterfaceLink.getBlockNamed(_blockName);
if (blockRemote == nullptr) {
ABE_ERROR(" Get flow : '" << m_name << "' mode:'input' to " << _blockName << ":" << _flowLinkName << " Error no remote block");
} else {
out = blockRemote->getFlowReference(_flowLinkName);
if (out == nullptr) {
ABE_ERROR(" Get flow : '" << m_name << "' mode:'input' to " << _blockName << ":" << _flowLinkName << " Error no Flow found");
} else {
ABE_INFO(" Get flow : " << _blockName << ":" << _flowLinkName);
}
}
return out;
}
/*
ememory::SharedPtr<audio::blockEngine::Block> audio::blockEngine::flow::Base::getBlockNamed(const std::string& _name) {
ABE_ERROR("NEED to call Parrent ...");
return nullptr;
}
*/

View File

@ -0,0 +1,108 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <ejson/ejson.hpp>
#include <audio/blockEngine/flow/Interface.hpp>
#include <audio/blockEngine/debug.hpp>
#include <ememory/memory.hpp>
namespace audio {
namespace blockEngine {
namespace flow {
class BaseReference;
class Base {
protected:
audio::blockEngine::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(audio::blockEngine::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) {
ABE_ERROR("[" << m_name << "] Can not create a link on an Output (only manage with input ...)");
}
protected:
ememory::SharedPtr<BaseReference> m_ref; //!< To simplify implementation code we use a temporary variable to shared the current reference...
public:
ememory::SharedPtr<BaseReference> getReference() {
return m_ref;
}
virtual void addReference(const ememory::SharedPtr<BaseReference>& _reference) {
ABE_ERROR("[" << m_name << "] Can not add reference ...");
}
protected:
ememory::SharedPtr<BaseReference> getFlowReference(const std::string& _blockName,
const std::string& _flowLinkName);
public:
virtual void link();
virtual int32_t checkCompatibility();
virtual void getInputBuffer();
//virtual ememory::SharedPtr<audio::blockEngine::Block> getBlockNamed(const std::string& _name);
};
std::ostream& operator <<(std::ostream& _os, const audio::blockEngine::flow::Base& _obj);
// we use a reference to simplify code of every blocks...
//! @not-in-doc
class BaseReference : public ememory::EnableSharedFromThis<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;
}
};
}
}
}

View File

@ -0,0 +1,146 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <functional>
#include <audio/blockEngine/flow/Base.hpp>
#include <audio/blockEngine/core/Buffer.hpp>
#include <audio/blockEngine/debug.hpp>
namespace audio {
namespace blockEngine {
class Buffer;
template<typename T = audio::blockEngine::Buffer> class Flow : public flow::Base {
protected:
ememory::SharedPtr<audio::blockEngine::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(audio::blockEngine::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 ememory::SharedPtr<audio::blockEngine::Buffer>& _data){
m_data.reset();
ememory::SharedPtr<T> check = ememory::dynamicPointerCast<T>(_data);
if (check == nullptr) {
ABE_ERROR("can not set buffer as flow (type uncompatible)");
return;
}
m_data = _data;
}
T* get() {
return static_cast<T*>(*m_data);
}
};
namespace flow {
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
ememory::WeakPtr<BaseReference> m_remoteFlow; //!< reference on the remote flow.
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(audio::blockEngine::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;
ABE_INFO("[" << Base::m_name << "] Link with : '" << m_blockName << "':'" << m_flowName << "'");
}
virtual void link() {
ABE_INFO(" link flow : '" << Base::m_name << "' mode:'input' to " << m_blockName << ":" << m_flowName);
ememory::SharedPtr<BaseReference> remoteFlow = Base::getFlowReference(m_blockName, m_flowName);
m_remoteFlow = remoteFlow;
if (remoteFlow == nullptr) {
ABE_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());
}
};
template<typename T> class Output : public Flow<T> {
protected:
std::vector<ememory::WeakPtr<BaseReference>> m_remoteFlow; //!< List of reference on the remote flow (multiple childs).
ejson::Object m_formatMix; //!< current format that is now availlable on the flow (can be on error) represent the intersection of all flow connected
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(audio::blockEngine::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() { };
virtual void addReference(const ememory::SharedPtr<BaseReference>& _reference) {
m_remoteFlow.push_back(_reference);
}
virtual int32_t checkCompatibility() {
ABE_INFO(" check for : '" << Base::m_name << "' to " << m_remoteFlow.size() << " links");
std::vector<ejson::Object> list;
list.push_back(Base::getCapabilities());
for (auto &it : m_remoteFlow) {
ememory::SharedPtr<BaseReference> tmp = it.lock();
if (tmp != nullptr) {
if (tmp->getBase() != nullptr) {
list.push_back(tmp->getBase()->getCapabilities());
}
}
}
m_formatMix = Base::m_flowInterfaceLink.getFlowIntersection(list);
// TODO : Check input property
ABE_INFO("[" << Base::m_name << "] mix signal : ");
m_formatMix.display();
return 0;
}
};
}
}
}

View File

@ -4,30 +4,30 @@
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/flow/Interface.hpp>
#include <eaudiofx/flow/Base.hpp>
#include <audio/blockEngine/debug.hpp>
#include <audio/blockEngine/flow/Interface.hpp>
#include <audio/blockEngine/flow/Base.hpp>
eaudiofx::flow::Interface::Interface() {
audio::blockEngine::flow::Interface::Interface() {
}
eaudiofx::flow::Interface::~Interface() {
audio::blockEngine::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) {
void audio::blockEngine::flow::Interface::flowAdd(audio::blockEngine::flow::Base* _pointerOnFlow) {
if (_pointerOnFlow == nullptr) {
EAUDIOFX_ERROR("Try to link a nullptr flow");
ABE_ERROR("Try to link a nullptr flow");
return;
}
m_list.push_back(_pointerOnFlow);
}
void eaudiofx::flow::Interface::flowRemove(eaudiofx::flow::Base* _pointerOnFlow) {
void audio::blockEngine::flow::Interface::flowRemove(audio::blockEngine::flow::Base* _pointerOnFlow) {
if (_pointerOnFlow == nullptr) {
EAUDIOFX_ERROR("Try to unlink a nullptr flow");
ABE_ERROR("Try to unlink a nullptr flow");
return;
}
for (auto it(m_list.begin()); it != m_list.end(); ++it) {
@ -39,10 +39,10 @@ void eaudiofx::flow::Interface::flowRemove(eaudiofx::flow::Base* _pointerOnFlow)
return;
}
}
EAUDIOFX_ERROR("Try to unlink a Unexistant flow");
ABE_ERROR("Try to unlink a Unexistant flow");
}
std::vector<std::string> eaudiofx::flow::Interface::flowGetAll() const {
std::vector<std::string> audio::blockEngine::flow::Interface::flowGetAll() const {
std::vector<std::string> out;
for (auto &it : m_list) {
if(it != nullptr) {
@ -52,12 +52,12 @@ std::vector<std::string> eaudiofx::flow::Interface::flowGetAll() const {
return out;
}
void eaudiofx::flow::Interface::flowRemoveAll() {
void audio::blockEngine::flow::Interface::flowRemoveAll() {
m_list.clear();
}
void eaudiofx::flow::Interface::flowSetLinkWith(const std::string& _flowName,
void audio::blockEngine::flow::Interface::flowSetLinkWith(const std::string& _flowName,
const std::string& _blockName,
const std::string& _flowLinkName) {
for (auto &it : m_list) {
@ -67,11 +67,11 @@ void eaudiofx::flow::Interface::flowSetLinkWith(const std::string& _flowName,
return;
}
}
EAUDIOFX_ERROR("Can not find Flow : '" << _flowName << "'");
ABE_ERROR("Can not find Flow : '" << _flowName << "'");
}
void eaudiofx::flow::Interface::flowLinkInput() {
EAUDIOFX_INFO(" Block update the flows links (" << m_list.size() << " flows)");
void audio::blockEngine::flow::Interface::flowLinkInput() {
ABE_INFO(" Block update the flows links (" << m_list.size() << " flows)");
for (auto &it : m_list) {
if(it != nullptr) {
it->link();
@ -79,8 +79,8 @@ void eaudiofx::flow::Interface::flowLinkInput() {
}
}
void eaudiofx::flow::Interface::flowCheckAllCompatibility() {
EAUDIOFX_INFO(" Block Check the flows Capabilities (" << m_list.size() << " flows)");
void audio::blockEngine::flow::Interface::flowCheckAllCompatibility() {
ABE_INFO(" Block Check the flows Capabilities (" << m_list.size() << " flows)");
for (auto &it : m_list) {
if(it != nullptr) {
it->checkCompatibility();
@ -88,12 +88,12 @@ void eaudiofx::flow::Interface::flowCheckAllCompatibility() {
}
}
void eaudiofx::flow::Interface::flowAllocateOutput() {
EAUDIOFX_WARNING(" Block need to allocate all his output");
void audio::blockEngine::flow::Interface::flowAllocateOutput() {
ABE_WARNING(" Block need to allocate all his output");
}
void eaudiofx::flow::Interface::flowGetInput() {
EAUDIOFX_WARNING(" Block Get input data pointers");
void audio::blockEngine::flow::Interface::flowGetInput() {
ABE_WARNING(" Block Get input data pointers");
for (auto &it : m_list) {
if(it != nullptr) {
it->getInputBuffer();
@ -102,8 +102,8 @@ void eaudiofx::flow::Interface::flowGetInput() {
}
ememory::SharedPtr<eaudiofx::flow::BaseReference> eaudiofx::flow::Interface::getFlowReference(const std::string& _flowName) {
ememory::SharedPtr<eaudiofx::flow::BaseReference> out;
ememory::SharedPtr<audio::blockEngine::flow::BaseReference> audio::blockEngine::flow::Interface::getFlowReference(const std::string& _flowName) {
ememory::SharedPtr<audio::blockEngine::flow::BaseReference> out;
for (auto &it : m_list) {
if( it != nullptr
&& it->getName() == _flowName) {
@ -118,7 +118,7 @@ static ejson::Value intersect(const ejson::Value& _obj1, const ejson::Value& _ob
ejson::Value out;
if (_obj1.exist() == false) {
if (_obj2.exist() == false) {
EAUDIOFX_ERROR("intersect 2 null ptr ...");
ABE_ERROR("intersect 2 null ptr ...");
return ejson::Null();
} else {
return _obj2.clone();
@ -137,7 +137,7 @@ static ejson::Value intersect(const ejson::Value& _obj1, const ejson::Value& _ob
if (value == _obj2.toNumber().get()) {
return ejson::Number(value);
}
EAUDIOFX_ERROR("Not the same number value");
ABE_ERROR("Not the same number value");
}
if (_obj2.isArray() == true) {
const ejson::Array obj = _obj2.toArray();
@ -148,7 +148,7 @@ static ejson::Value intersect(const ejson::Value& _obj1, const ejson::Value& _ob
}
}
}
EAUDIOFX_ERROR("Not the same values ...");
ABE_ERROR("Not the same values ...");
}
}
if (_obj1.isString() == true) {
@ -158,7 +158,7 @@ static ejson::Value intersect(const ejson::Value& _obj1, const ejson::Value& _ob
if (value == _obj2.toString().get()) {
return ejson::String(value);
}
EAUDIOFX_ERROR("Not the same string value");
ABE_ERROR("Not the same string value");
}
if (_obj2.isArray() == true) {
const ejson::Array obj = _obj2.toArray();
@ -169,37 +169,37 @@ static ejson::Value intersect(const ejson::Value& _obj1, const ejson::Value& _ob
}
}
}
EAUDIOFX_ERROR("Not the same values ...");
ABE_ERROR("Not the same values ...");
}
}
if (_obj1.isArray() == true) {
EAUDIOFX_TODO(" manage array");
ABE_TODO(" manage array");
}
EAUDIOFX_ERROR("Can not intersect elements : (obj1)");
ABE_ERROR("Can not intersect elements : (obj1)");
_obj1.display();
EAUDIOFX_ERROR(" (obj2)");
ABE_ERROR(" (obj2)");
_obj2.display();
// remove sublist if it is reduce to 1
return ejson::Null();
}
ejson::Object eaudiofx::flow::Interface::getFlowIntersection(const std::vector<ejson::Object>& _list) {
EAUDIOFX_ERROR("-------------- start intersection --------------");
ejson::Object audio::blockEngine::flow::Interface::getFlowIntersection(const std::vector<ejson::Object>& _list) {
ABE_ERROR("-------------- start intersection --------------");
ejson::Object out;
if (_list.size() == 0) {
return out;
}
if (_list.size() == 1) {
out = _list[0].clone().toObject();
EAUDIOFX_INFO("List clone : ");
ABE_INFO("List clone : ");
out.display();
EAUDIOFX_ERROR("-------------- stop intersection (no link ...) --------------");
ABE_ERROR("-------------- stop intersection (no link ...) --------------");
return out;
}
// check all same type :
for (int32_t iii=1; iii<_list.size(); ++iii) {
if (_list[iii].toString().get("type") != _list[0].toString().get("type")) {
EAUDIOFX_ERROR("All stream have not the same Type ...");
ABE_ERROR("All stream have not the same Type ...");
return out;
}
}
@ -230,10 +230,10 @@ ejson::Object eaudiofx::flow::Interface::getFlowIntersection(const std::vector<e
}
} else {
EAUDIOFX_ERROR("not manage interface for mix ... '" << out["type"].toString().get() << "'");
ABE_ERROR("not manage interface for mix ... '" << out["type"].toString().get() << "'");
}
out.display();
EAUDIOFX_ERROR("-------------- stop intersection --------------");
ABE_ERROR("-------------- stop intersection --------------");
return out;
}

View File

@ -0,0 +1,87 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <vector>
#include <map>
#include <ejson/ejson.hpp>
namespace audio {
namespace blockEngine {
class Block;
namespace flow {
class Base;
class BaseReference;
class Interface {
friend class audio::blockEngine::flow::Base; // to register parameter in the list.
private:
std::vector<audio::blockEngine::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(audio::blockEngine::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(audio::blockEngine::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 flowLinkInput();
// check if the IOs are compatible
virtual void flowCheckAllCompatibility();
// Allocate all Outputs
virtual void flowAllocateOutput();
// Get pointer on all Inputs
virtual void flowGetInput();
/**
* @brief Get The block named ...
* @param[in] _name Name of the block requested
* @return The block requested if it exist.
*/
virtual ememory::SharedPtr<audio::blockEngine::Block> getBlockNamed(const std::string& _name) {
return nullptr;
}
ememory::SharedPtr<audio::blockEngine::flow::BaseReference> getFlowReference(const std::string& _name);
public:
ejson::Object getFlowIntersection(const std::vector<ejson::Object>& _list);
};
}
}
}

View File

@ -1,248 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/Thread.hpp>
#include <unistd.h>
static const char* threadGetCharState(enum eaudiofx::status state) {
const char* ret = (const char*)"";
switch (state) {
case eaudiofx::statusNotStarted:
ret = (const char*)"NOT_STARTED";
break;
case eaudiofx::statusCreating:
ret = (const char*)"CREATING";
break;
case eaudiofx::statusStart:
ret = (const char*)"START";
break;
case eaudiofx::statusRun:
ret = (const char*)"RUN";
break;
case eaudiofx::statusStop:
ret = (const char*)"STOP";
break;
case eaudiofx::statusDie:
ret = (const char*)"DIE";
break;
default:
ret = (const char*)"???";
break;
}
return ret;
}
/**
* @brief change the current state of the thread.
* @param[in] _newState The new state for the thread.
*/
void eaudiofx::Thread::threadChangeState(enum eaudiofx::status _newState) {
int ret;
std::unique_lock<std::mutex> lock(m_interfaceMutex);
// debug display :
EAUDIOFX_DEBUG("[" << m_id << "] '" << m_name << "' Change state : " << threadGetCharState(m_state) << " ==> " << threadGetCharState(_newState));
// set the New state
m_state = _newState;
return;
}
eaudiofx::Thread::Thread(const std::string& _chainName) {
if (_chainName != "") {
m_name = _chainName;
} else {
m_name = "No-name";
EAUDIOFX_WARNING("the thread has no name");
}
static int32_t threadIDBasic = 100;
m_id = threadIDBasic++;
EAUDIOFX_INFO("THREAD : Allocate [" << m_id << "] name='" << m_name << "'");
m_state = eaudiofx::statusNotStarted;
}
eaudiofx::Thread::~Thread() {
EAUDIOFX_INFO("THREAD : Destroy [" << m_id << "] name='" << m_name << "'");
stop();
m_thread->join();
m_thread.reset();
}
int32_t eaudiofx::Thread::start() {
int ret;
if (eaudiofx::statusDie == m_state) {
EAUDIOFX_INFO("Thread [" << m_id << "] name='" << m_name << "' ==> state die ... ==> delete it ...");
stopAtEnd();
}
if (eaudiofx::statusNotStarted != m_state) {
EAUDIOFX_ERROR("Failed to create [" << m_id << "] name='" << m_name << "' ==> the thread is not stopped ...");
return eaudiofx::ERR_FAIL;
}
m_state = eaudiofx::statusCreating;
m_thread = std::make_shared<std::thread>(eaudiofx::Thread::genericThreadCall, reinterpret_cast<void*>(this));
// no else ==> the thread is started corectly... (we think)
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::Thread::stop() {
EAUDIOFX_INFO(" Stop [" << m_id << "] name='" << m_name << "'");
// Set the stop flag for the thread :
std::unique_lock<std::mutex> lock(m_interfaceMutex);
m_flags |= 1;
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::Thread::stopAtEnd() {
int systemRet;
int32_t ret = eaudiofx::ERR_NONE;
EAUDIOFX_INFO(" Delete [" << m_id << "] name='" << m_name << "' (StopAtEnd)");
// Request the thread stop:
ret = stop();
if (eaudiofx::ERR_NONE != ret) {
EAUDIOFX_ERROR("The thread have a problem to stop");
return ret;
}
if (eaudiofx::statusNotStarted != m_state) {
m_thread.reset();
}
std::unique_lock<std::mutex> lock(m_interfaceMutex);
m_flags = 0;
m_state = eaudiofx::statusNotStarted;
return ret;
}
// function that might be writen for every thread
bool eaudiofx::Thread::stateStart() {
EAUDIOFX_DEBUG("Not overwrited in the herited classes: StateStart");
// virtual function ...
return false;
}
bool eaudiofx::Thread::stateRun() {
EAUDIOFX_DEBUG("Not overwrited in the herited classes: StateRun");
// virtual function ...
usleep(100000);
// Force the stop if this function is not overwritte
return false;
}
bool eaudiofx::Thread::stateStop() {
EAUDIOFX_DEBUG("Not overwrited in the herited classes: StateStop");
// virtual function ...
return false;
}
void eaudiofx::Thread::genericThreadCall(void* _data) {
eaudiofx::Thread * self = reinterpret_cast<eaudiofx::Thread*>(_data);
if (self != nullptr) {
self->threadCall();
} else {
EAUDIOFX_ERROR("can not start th ethraead ...");
}
}
void eaudiofx::Thread::threadCall() {
bool autoKill = false;
// Endless loop.
while(eaudiofx::statusDie != m_state) {
int32_t flags = 0;
{
std::unique_lock<std::mutex> lock(m_interfaceMutex);
flags = m_flags;
m_flags = 0;
}
if (flags == 1 ) {
EAUDIOFX_DEBUG("Detect stop request by user...");
// action depend on the current state :
switch (m_state) {
case eaudiofx::statusCreating:
threadChangeState(eaudiofx::statusDie);
break;
case eaudiofx::statusStart:
threadChangeState(eaudiofx::statusStop);
break;
case eaudiofx::statusRun:
threadChangeState(eaudiofx::statusStop);
break;
case eaudiofx::statusStop:
// nothing to do ...
break;
case eaudiofx::statusDie:
// impossible state
break;
default:
// Should not happen
EAUDIOFX_CRITICAL("Base: [" << m_id << "] '" << m_name << "' state failure ...");
break;
}
}
// Retrieve current action.
switch (m_state) {
case eaudiofx::statusCreating:
EAUDIOFX_DEBUG("eaudiofx::statusCreating");
// change state :
threadChangeState(eaudiofx::statusStart);
break;
case eaudiofx::statusStart:
EAUDIOFX_DEBUG("eaudiofx::statusStart");
// call function
autoKill = stateStart();
// a problem occured to the function
if (true == autoKill) {
// error in start ==> direct end
threadChangeState(eaudiofx::statusDie);
} else {
// change state :
threadChangeState(eaudiofx::statusRun);
}
break;
case eaudiofx::statusRun:
EAUDIOFX_DEBUG("eaudiofx::statusRun");
// call function
autoKill = stateRun();
if (true == autoKill) {
EAUDIOFX_DEBUG("Request AutoKill");
// error in start ==> direct end
threadChangeState(eaudiofx::statusStop);
}
// no else
break;
case eaudiofx::statusStop:
EAUDIOFX_DEBUG("eaudiofx::statusStop");
// call function
autoKill = stateStop();
// a problem occured to the function
if (true == autoKill) {
// error in stop ==> direct end
threadChangeState(eaudiofx::statusDie);
} else {
// change state :
threadChangeState(eaudiofx::statusDie);
}
break;
case eaudiofx::statusDie:
EAUDIOFX_DEBUG("eaudiofx::statusDie");
break;
default:
// Should not happen
EAUDIOFX_CRITICAL("Base: state failure: [" << m_id << "] name='" << m_name << "'");
return;
}
}
// exit the thread...
EAUDIOFX_INFO("Base: THEAD (END): [" << m_id << "] name='" << m_name << "'");
return;
}

View File

@ -1,70 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <thread>
#include <mutex>
#include <etk/os/Fifo.hpp>
#include <eaudiofx/core/audio.hpp>
/**
* @brief Tanho thread system (parent class)
*/
namespace eaudiofx {
enum status {
statusNotStarted, //!< The thread is creating itself
statusCreating, //!< The thread is creating itself
statusStart, //!< The element is starting
statusRun, //!< The thread is running
statusStop, //!< The thread is stoping
statusDie, //!< the thread is diing or dead
};
class Thread {
private:
static void genericThreadCall(void * data);
protected:
std::shared_ptr<std::thread> m_thread;
std::mutex m_interfaceMutex;
int32_t m_flags;
public:
Thread(const std::string& _name="not-set-name");
~Thread();
int32_t start(); //!< start the thread
int32_t stop(); //!< stop this current thread (request the stop of the process) ==> a-synchronous request
int32_t stopAtEnd(); //!< stop when the process is ended (when possible) ==> stop and wait hte real end of the thread
void setRepeating(int32_t delayBetweenRestart, int32_t maxTimeRestart); //!< configure repeating
void setNoRepeating(); //!< cancel SetRepeating
protected:
void threadCall(); //!< internal call of sup thread system (call from GenericThreadCall)
private:
void threadChangeState(enum status _newState); //!< information about state change
protected:
std::string m_name; //!< curent thread name
private:
uint32_t m_id; //!< Thread Id it will be Unique
enum status m_state; //!< Thread current state
protected:
enum status getState() {
return m_state;
};
/**
* @brief Thread state "Start" process
* @return true if an error occured ==> this kill the thread.
*/
virtual bool stateStart();
/**
* @brief Thread state "Run" process
* @return true if an error occured or a kill is requested by a block
*/
virtual bool stateRun();
/**
* @brief Thread state "Stop" process
* @return true if an error occured
*/
virtual bool stateStop();
};
};

View File

@ -1,83 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/base/GeneratorSignal.hpp>
#include <eaudiofx/core/BufferStream.hpp>
#include <eaudiofx/base/GeneratorFile.hpp>
eaudiofx::GeneratorFile::GeneratorFile() :
m_file(nullptr) {
// set output :
m_io.insert(
std::pair<std::string, eaudiofx::Block::IOProperty>(
"out",
eaudiofx::Block::IOProperty(
eaudiofx::Block::ioOutput,
"{ type:'bitstream', format:'file' }",
new eaudiofx::BufferStream(*this)
) ) );
}
int32_t eaudiofx::GeneratorFile::pull(double _currentTime, int32_t _request, float _timeout) {
auto it = m_io.find("out");
if (it == m_io.end()) {
EAUDIOFX_WARNING("request to pull data with no output !!!");
return eaudiofx::ERR_FAIL;
}
eaudiofx::BufferStream* buffer = dynamic_cast<eaudiofx::BufferStream*>(it->second.m_buffer);
//EAUDIOFX_ERROR("Generate data, request : " << _request << " at time : " << _currentTime);
if (buffer == nullptr) {
// !! impossible case => a buffer can not be removed ...
EAUDIOFX_ERROR("Buffer has been removed... OR change type ...");
return eaudiofx::ERR_FAIL;
}
//request outpuffer needed size :
buffer->setProperty(_request);
uint8_t* data = buffer->getData();
if (m_file == nullptr) {
EAUDIOFX_ERROR("Buffer output error ==> !!ERROR!!");
return eaudiofx::ERR_FAIL;
}
int64_t nbRead = m_file->fileRead(data, sizeof(uint8_t), _request);
buffer->setAvaillableSize(nbRead);
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::GeneratorFile::init() {
m_file = new etk::FSNode("DATA:menu.wav");
if (m_file == nullptr) {
EAUDIOFX_ERROR("Can not allocate the input file ...");
return eaudiofx::ERR_FAIL;
}
if (m_file->fileOpenRead() == false) {
EAUDIOFX_ERROR("Can not open the input file ...");
return eaudiofx::ERR_FAIL;
}
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::GeneratorFile::unInit() {
if (m_file == nullptr) {
return eaudiofx::ERR_NONE;
}
if (m_file->fileClose() == false) {
EAUDIOFX_ERROR("Can not close the input file ...");
delete(m_file);
m_file = nullptr;
return eaudiofx::ERR_FAIL;
}
delete(m_file);
m_file = nullptr;
return eaudiofx::ERR_NONE;
}

View File

@ -1,26 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/BlockGenerator.hpp>
#include <etk/os/FSNode.hpp>
namespace eaudiofx {
class GeneratorFile : public eaudiofx::BlockGenerator {
public:
GeneratorFile();
virtual ~GeneratorFile() {};
protected:
etk::FSNode* m_file;
public: // herieted function :
virtual int32_t pull(double _currentTime, int32_t _request, float _timeout);
virtual int32_t init();
virtual int32_t unInit();
};
};

View File

@ -1,25 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/base/GeneratorRtAudio.hpp>
#include <eaudiofx/core/BufferAudioRaw.hpp>
#include <airtaudio/Interface.hpp>
eaudiofx::GeneratorRiver::GeneratorRiver() {
setLive(true);
// set output :
m_io.insert(
std::pair<std::string, eaudiofx::Block::IOProperty>(
"out",
eaudiofx::Block::IOProperty(
eaudiofx::Block::ioOutput,
"",
new eaudiofx::BufferAudioRaw(*this, 48000, 2)
) ) );
};

View File

@ -1,21 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/BlockGenerator.hpp>
namespace eaudiofx {
class GeneratorRiver : public eaudiofx::BlockGenerator {
public:
GeneratorRiver();
virtual ~GeneratorRiver() {};
public:
int32_t pull(double _currentTime, int32_t _request, float _timeout);
};
};

View File

@ -1,61 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/base/GeneratorSignal.hpp>
#include <eaudiofx/core/BufferAudio.hpp>
#include <cmath>
void eaudiofx::GeneratorSignal::init() {
eaudiofx::Block::init();
}
eaudiofx::GeneratorSignal::GeneratorSignal() :
m_phase(0),
m_output(*this, "out", "Output sinus generated", "{ type:'audio', freq:48000, format:['int16','int32'], channels:2}") {
addObjectType("eaudiofx::GeneratorSignal");
}
int32_t eaudiofx::GeneratorSignal::algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
EAUDIOFX_INFO("Process: " << _currentTime << " chunkTime=" << _processTimeSlot);
return eaudiofx::ERR_NONE;
}
#if 0
int32_t eaudiofx::GeneratorSignal::pull(double _currentTime, int32_t _request, float _timeout) {
auto it = m_io.find("out");
if (it == m_io.end()) {
EAUDIOFX_WARNING("request to pull data with no output !!!");
return eaudiofx::ERR_FAIL;
}
eaudiofx::BufferAudioRaw* buffer = dynamic_cast<eaudiofx::BufferAudioRaw*>(it->second.m_buffer);
//EAUDIOFX_ERROR("Generate data, request : " << _request << " at time : " << _currentTime);
if (buffer == nullptr) {
// !! impossible case => a buffer can not be removed ...
EAUDIOFX_ERROR("Buffer has been removed... OR change type ...");
return eaudiofx::ERR_FAIL;
}
//request outpuffer needed size :
buffer->setProperty(48000, 2, _request);
float* data = buffer->getData();
for (int32_t iii=0; iii<_request; ++iii) {
for (int32_t jjj=0; jjj<2; ++jjj) {
*data++ = cos(m_phase)*0.5f;
}
m_phase += 0.1;
if (m_phase > 4.0*M_PI) {
m_phase -= 4.0*M_PI;
}
}
/*
FILE* plopppp = fopen("plop.raw", "a");
fwrite(buffer->getData(), sizeof(float), _request*2, plopppp);
fflush(plopppp);
fclose(plopppp);
*/
return eaudiofx::ERR_NONE;
}
#endif

View File

@ -1,28 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/Block.hpp>
#include <eaudiofx/core/BufferAudio.hpp>
namespace eaudiofx {
class GeneratorSignal : public eaudiofx::Block {
protected:
float m_phase;
protected:
GeneratorSignal();
void init();
public:
DECLARE_FACTORY(GeneratorSignal);
virtual ~GeneratorSignal() {};
public:
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot);
protected:
eaudiofx::flow::Output<eaudiofx::BufferAudio> m_output;
};
};

View File

@ -1,94 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/base/ReceiverFile.hpp>
eaudiofx::ReceiverFile::ReceiverFile() :
m_file(nullptr),
m_channels(4),
m_frequency(16000),
m_requestSize(256),
m_processStarted(false) {
// set input :
m_io.insert(
std::pair<std::string, eaudiofx::Block::IOProperty>(
"in",
eaudiofx::Block::IOProperty(
eaudiofx::Block::ioInput,
"{ type:'audio', compression:'raw', frequency:16000, channel:4, format:'int16_t' }",
nullptr
) ) );
}
int32_t eaudiofx::ReceiverFile::init() {
m_file = new etk::FSNode("ouput.raw");
if (m_file == nullptr) {
EAUDIOFX_ERROR("Can not allocate the output file ...");
return eaudiofx::ERR_FAIL;
}
if (m_file->fileOpenWrite() == false) {
EAUDIOFX_ERROR("Can not open the output file ...");
return eaudiofx::ERR_FAIL;
}
return eaudiofx::ERR_NONE;
};
int32_t eaudiofx::ReceiverFile::unInit() {
EAUDIOFX_DEBUG("un-init Stream ...");
if (m_file == nullptr) {
return eaudiofx::ERR_NONE;
}
if (m_file->fileClose() == false) {
EAUDIOFX_ERROR("Can not close the input file ...");
delete(m_file);
m_file = nullptr;
return eaudiofx::ERR_FAIL;
}
delete(m_file);
m_file = nullptr;
return eaudiofx::ERR_NONE;
};
int32_t eaudiofx::ReceiverFile::start() {
EAUDIOFX_DEBUG("Start stream ...");
m_processStarted = true;
return eaudiofx::ERR_NONE;
};
int32_t eaudiofx::ReceiverFile::stop() {
EAUDIOFX_DEBUG("Stop Stream ...");
m_processStarted = false;
return eaudiofx::ERR_NONE;
};
/*
int32_t eaudiofx::ReceiverFile::pull(double _currentTime, int32_t _request, float _timeout) {
auto it = m_io.find("out");
if (it == m_io.end()) {
EAUDIOFX_WARNING("request to pull data with no output !!!");
return eaudiofx::ERR_FAIL;
}
eaudiofx::BufferStream* buffer = dynamic_cast<eaudiofx::BufferStream*>(it->second.m_buffer);
//EAUDIOFX_ERROR("Generate data, request : " << _request << " at time : " << _currentTime);
if (buffer == nullptr) {
// !! impossible case => a buffer can not be removed ...
EAUDIOFX_ERROR("Buffer has been removed... OR change type ...");
return eaudiofx::ERR_FAIL;
}
//request outpuffer needed size :
buffer->setProperty(_request);
uint8_t* data = buffer->getData();
if (m_file == nullptr) {
EAUDIOFX_ERROR("Buffer output error ==> !!ERROR!!");
return eaudiofx::ERR_FAIL;
}
int64_t nbRead = m_file->fileRead(data, sizeof(uint8_t), _request);
buffer->setAvaillableSize(nbRead);
return eaudiofx::ERR_NONE;
}
*/

View File

@ -1,31 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/BlockReceiver.hpp>
#include <etk/os/FSNode.hpp>
namespace eaudiofx {
class ReceiverFile : public eaudiofx::BlockReceiver {
public:
ReceiverFile();
virtual ~ReceiverFile() {};
public: // herieted function :
virtual int32_t init();
virtual int32_t unInit();
private:
etk::FSNode* m_file;
uint32_t m_channels;
uint32_t m_frequency;
uint32_t m_requestSize;
bool m_processStarted;
public:
virtual int32_t start();
virtual int32_t stop();
};
};

View File

@ -1,48 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/Block.hpp>
#include <audio/river/Interface.hpp>
#include <audio/river/Manager.hpp>
#include <eaudiofx/core/BufferAudio.hpp>
namespace eaudiofx {
class ReceiverRiver : public eaudiofx::Block {
private:
void onDataNeeded(void* _data,
const audio::Time& _time,
size_t _nbChunk,
enum audio::format _format,
uint32_t _frequency,
const std::vector<audio::channel>& _map);
protected:
ReceiverRiver();
void init();
public:
DECLARE_FACTORY(ReceiverRiver);
virtual ~ReceiverRiver() {};
public: // herieted function :
virtual int32_t algoInit();
virtual int32_t algoUnInit();
private:
bool m_processStarted;
public:
virtual int32_t algoStart();
virtual int32_t algoStop();
protected:
ememory::SharedPtr<audio::river::Manager> m_manager;
ememory::SharedPtr<audio::river::Interface> m_interface;
std::vector<int8_t> m_buffer;
public:
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot);
protected:
eaudiofx::flow::Input<eaudiofx::BufferAudio> m_input;
};
};

View File

@ -1,38 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/core/Block.hpp>
#include <eaudiofx/core/Buffer.hpp>
#include <eaudiofx/core/BlockMeta.hpp>
eaudiofx::Block::Block() {
addObjectType("eaudiofx::Block");
}
eaudiofx::Block::~Block() {
}
ememory::SharedPtr<eaudiofx::Block> eaudiofx::Block::getBlockNamed(const std::string& _name) {
ememory::SharedPtr<eaudiofx::Block> out;
EAUDIOFX_INFO(" get block : " << _name);
ewol::ObjectShared parrent = m_parent.lock();
if (parrent != nullptr) {
ememory::SharedPtr<eaudiofx::Block> parrentBlock = ememory::dynamicPointerCast<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;
}

View File

@ -1,94 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <string>
#include <mutex>
#include <map>
#include <ewol/object/Object.hpp>
#include <eaudiofx/core/audio.hpp>
#include <eaudiofx/flow/Interface.hpp>
#include <eaudiofx/flow/Flow.hpp>
namespace eaudiofx {
class Buffer;
class BlockMeta;
class Block : public ewol::Object,
public eaudiofx::flow::Interface {
protected:
Block();
void init() {
ewol::Object::init();
}
public:
DECLARE_FACTORY(Block);
virtual ~Block();
protected:
std::mutex m_mutex; //!< Block mutex access
public:
/**
* @brief Init the block with the properties
* @return A generic error.
*/
virtual int32_t algoInit() {
return eaudiofx::ERR_NONE;
};
/**
* @brief UnInit the block with the properties
* @return A generic error.
*/
virtual int32_t algoUnInit() {
return eaudiofx::ERR_NONE;
};
virtual int32_t algoStart() {
return eaudiofx::ERR_NONE;
};
virtual int32_t algoStop() {
return eaudiofx::ERR_NONE;
};
public:
/**
* @brief get if the block support the native push interface
* @return true if the mode is supported
*/
virtual bool supportNativePush() {
return false;
}
/**
* @brief get if the block support the native pull interface
* @return true if the mode is supported
*/
virtual bool supportNativePull() {
return false;
}
/**
* @brief get if the block support the native Time interface
* @return true if the mode is supported
*/
virtual bool supportNativeTime() {
return false;
}
/**
* @brief Reset the block
* @return generic error
*/
virtual int32_t algoReset() {
return eaudiofx::ERR_NONE;
};
int32_t algoProcess(int64_t _currentTime, int64_t _processTimeSlot) {
return eaudiofx::ERR_NONE;
}
virtual ememory::SharedPtr<eaudiofx::Block> getBlockNamed(const std::string& _name);
};
};

View File

@ -1,244 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/core/BlockMeta.hpp>
eaudiofx::BlockMeta::BlockMeta() {
addObjectType("eaudiofx::BlockMeta");
}
eaudiofx::BlockMeta::~BlockMeta() {
// TODO : Unlink all ...
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
ememory::SharedPtr<eaudiofx::Block> tmp = it;
it.reset();
}
m_list.clear();
}
ememory::SharedPtr<eaudiofx::Block> eaudiofx::BlockMeta::getBlock(const std::string& _name) {
if (_name.size() == 0) {
return nullptr;
}
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->propertyName.get() == _name) {
return it;
}
}
return nullptr;
}
int32_t eaudiofx::BlockMeta::addBlock(ememory::SharedPtr<eaudiofx::Block> _block) {
if (_block == nullptr) {
EAUDIOFX_ERROR("[" << getId() << "] Add nullptr block");
return eaudiofx::ERR_INPUT_NULL;
}
if (_block->propertyName.get().size() > 0 ) {
// Check if name exist :
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->propertyName.get() == _block->propertyName.get()) {
EAUDIOFX_ERROR("[" << getId() << "] Add block name '" << _block->propertyName.get() << "' already exist");
return eaudiofx::ERR_ALREADY_EXIST;
}
}
}
m_list.push_back(_block);
_block->setParent(sharedFromThis());
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::BlockMeta::addBlock(const std::string& _blockType, const std::string& _name) {
EAUDIOFX_ERROR("NOT IMPLEMENTED");
return eaudiofx::ERR_NOT_IMPLEMENTED;
}
int32_t eaudiofx::BlockMeta::removeBlock(const std::string& _name) {
EAUDIOFX_ERROR("NOT IMPLEMENTED");
return eaudiofx::ERR_NOT_IMPLEMENTED;
}
int32_t eaudiofx::BlockMeta::linkBlock(const std::string& _generatorBlockName,
const std::string& _generatorIoName,
const std::string& _receiverBlockName,
const std::string& _receiverIoName) {
// TODO : proxy IOs
ememory::SharedPtr<eaudiofx::Block> receive = getBlock(_receiverBlockName);
if (receive == nullptr) {
EAUDIOFX_ERROR("Can not find destination block : '" << _receiverBlockName << "'");
return eaudiofx::ERR_FAIL;
}
receive->flowSetLinkWith(_receiverIoName, _generatorBlockName, _generatorIoName);
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::BlockMeta::openFile(const std::string& _fileName) {
EAUDIOFX_ERROR("NOT IMPLEMENTED");
return eaudiofx::ERR_NOT_IMPLEMENTED;
}
int32_t eaudiofx::BlockMeta::openStream(const std::string& _stream) {
EAUDIOFX_ERROR("NOT IMPLEMENTED");
return eaudiofx::ERR_NOT_IMPLEMENTED;
}
int32_t eaudiofx::BlockMeta::algoInit() {
EAUDIOFX_INFO("[" << getId() << "]Init Meta block : '" << propertyName << "'");
int32_t ret = eaudiofx::ERR_NONE;
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->algoInit() != eaudiofx::ERR_NONE) {
ret = eaudiofx::ERR_FAIL;
}
}
if (ret != eaudiofx::ERR_NONE) {
EAUDIOFX_WARNING("Pb when init the Meta-block '" << propertyName << "' ");
}
return ret;
};
int32_t eaudiofx::BlockMeta::algoUnInit() {
int32_t ret = eaudiofx::ERR_NONE;
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->algoUnInit() != eaudiofx::ERR_NONE) {
ret = eaudiofx::ERR_FAIL;
}
}
if (ret != eaudiofx::ERR_NONE) {
EAUDIOFX_WARNING("Pb when un-init the Meta-block '" << propertyName << "' ");
}
return ret;
};
int32_t eaudiofx::BlockMeta::algoStart() {
EAUDIOFX_INFO("[" << getId() << "] Start Meta block : '" << propertyName << "'");
int32_t ret = eaudiofx::ERR_NONE;
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->algoStart() != eaudiofx::ERR_NONE) {
ret = eaudiofx::ERR_FAIL;
}
}
if (ret != eaudiofx::ERR_NONE) {
EAUDIOFX_WARNING("Pb when start the Meta-block '" << propertyName << "' ");
}
return ret;
};
int32_t eaudiofx::BlockMeta::algoStop() {
EAUDIOFX_INFO("[" << getId() << "] Stop Meta block : '" << propertyName << "'");
int32_t ret = eaudiofx::ERR_NONE;
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
if (it->algoStop() != eaudiofx::ERR_NONE) {
ret = eaudiofx::ERR_FAIL;
}
}
if (ret != eaudiofx::ERR_NONE) {
EAUDIOFX_WARNING("Pb when stop the Meta-block '" << propertyName << "' ");
}
return ret;
};
ememory::SharedPtr<eaudiofx::Block> eaudiofx::BlockMeta::getBlockNamed(const std::string& _name) {
ememory::SharedPtr<eaudiofx::Block> out;
EAUDIOFX_DEBUG("[" << propertyName << "] try get Block : " << _name);
// Special case for proxy flow ...
if ( _name == ""
|| _name == propertyName.get()) {
EAUDIOFX_DEBUG(" ==> find Him");
return ememory::staticPointerCast<eaudiofx::Block>(sharedFromThis());
}
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
EAUDIOFX_DEBUG(" check : " << it->propertyName.get());
if (it->propertyName.get() == _name) {
out = it;
EAUDIOFX_DEBUG(" ==> find this one");
break;
}
}
return out;
}
void eaudiofx::BlockMeta::flowLinkInput() {
EAUDIOFX_INFO("[" << getId() << "] Meta block Link: '" << propertyName << "'");
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
it->flowLinkInput();
}
// Call upper class
eaudiofx::Block::flowLinkInput();
}
void eaudiofx::BlockMeta::flowCheckAllCompatibility() {
EAUDIOFX_INFO("[" << getId() << "] Meta block check compatibilities: '" << propertyName << "'");
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
it->flowCheckAllCompatibility();
}
// Call upper class
eaudiofx::Block::flowCheckAllCompatibility();
}
void eaudiofx::BlockMeta::flowAllocateOutput() {
EAUDIOFX_INFO("[" << getId() << "] Meta block allocate output: '" << propertyName << "'");
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
it->flowAllocateOutput();
}
// Call upper class
eaudiofx::Block::flowAllocateOutput();
}
void eaudiofx::BlockMeta::flowGetInput() {
EAUDIOFX_INFO("[" << getId() << "] Meta block get input ... : '" << propertyName << "'");
// find in sub elements.
for (auto &it : m_list) {
if (it == nullptr) {
continue;
}
it->flowGetInput();
}
// Call upper class
eaudiofx::Block::flowGetInput();
}

View File

@ -1,90 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/Block.hpp>
#include <vector>
namespace eaudiofx {
class BlockMeta : public eaudiofx::Block {
protected:
BlockMeta();
void init() {
eaudiofx::Block::init();
}
public:
DECLARE_FACTORY(BlockMeta);
virtual ~BlockMeta();
private:
std::vector<ememory::SharedPtr<eaudiofx::Block>> m_list; //!< list of all block to process.
protected:
/**
* @brief Get a pointer on a specific block.
* @param[in] _name Name of the block.
* @return generic error
*/
ememory::SharedPtr<eaudiofx::Block> getBlock(const std::string& _name);
public:
/**
* @brief Add a block in the Meta-block
* @param[in] _block Pointer on the block (do not free yourself)
* @return generic error
*/
int32_t addBlock(ememory::SharedPtr<eaudiofx::Block> _block);
/**
* @brief Add a block in the Meta-block.
* @param[in] _blockType Name of the type of block to add.
* @param[in] _name Name of the block to add.
* @return generic error
*/
int32_t addBlock(const std::string& _blockType, const std::string& _name = "");
/**
* @brief Remove a block from the Meta-block
* @param[in] _name Name of the block to remove
* @note This free the block pointer
* @return generic error
*/
int32_t removeBlock(const std::string& _name);
/**
* @brief Link 2 IO.
* @param[in] _generatorBlockName Name ot the generator Block
* @param[in] _generatorIoName Name of the outout
* @param[in] _receiverBlockName Name ot the receiver Block
* @param[in] _receiverIoName Name of the input
* @return generic error
*/
int32_t linkBlock(const std::string& _generatorBlockName,
const std::string& _generatorIoName,
const std::string& _receiverBlockName,
const std::string& _receiverIoName);
/**
* @brief Open file property
* @param[in] _fileName Name of the file to open
* @return generic error
*/
int32_t openFile(const std::string& _fileName);
/**
* @brief Open stream property
* @param[in] _stream data stream to open
* @return generic error
*/
int32_t openStream(const std::string& _stream);
public: // herited function
virtual int32_t algoInit();
virtual int32_t algoUnInit();
virtual int32_t algoStart();
virtual int32_t algoStop();
virtual ememory::SharedPtr<eaudiofx::Block> getBlockNamed(const std::string& _name);
virtual void flowLinkInput();
virtual void flowCheckAllCompatibility();
virtual void flowAllocateOutput();
virtual void flowGetInput();
};
};

View File

@ -1,26 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/audio.hpp>
#include <eaudiofx/core/Block.hpp>
namespace eaudiofx {
class Block;
class Buffer : public ememory::EnableSharedFromThis<Buffer> {
public:
Buffer(eaudiofx::Block& _parent);
virtual ~Buffer() {};
protected:
eaudiofx::Block& m_parent; //!< parrent Block of this Buffer
protected:
int64_t m_timestamp; //!< current buffer time
int64_t m_timeSize; //!< current buffer data time size
};
};

View File

@ -1,74 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/Buffer.hpp>
namespace eaudiofx {
enum audioFormat {
audioFormatInt8,
audioFormatInt16,
audioFormatInt24,
audioFormatInt32,
audioFormatIntFloat,
audioFormatIntDouble,
audioFormatInt16OverInt32
};
enum audioChannel {
audioChannelFrontLeft, //!< channel Front Left
audioChannelFrontCenter, //!< channel Front Center
audioChannelFrontRight, //!< channel Front Right
audioChannelRearLeft, //!< channel rear Left
audioChannelRearCenter, //!< channel rear Center
audioChannelRearRight, //!< channel rear Right
audioChannelSurroundLeft, //!< channel surround Left
audioChannelSurroundRight, //!< channel surround Right
audioChannelSubWoofer, //!< channel Sub-woofer
audioChannelLFE //!< channel Low frequency
};
class BufferAudio : public eaudiofx::Buffer {
public:
BufferAudio(eaudiofx::Block& _parent,
int32_t _frequency=48000,
const std::vector<enum audioChannel>& _map={audioChannelFrontLeft,audioChannelFrontRight},
enum audioFormat _format=audioFormatInt16);
BufferAudio(eaudiofx::Block& _parent,
const std::string& _description);
virtual ~BufferAudio();
protected:
int32_t m_frequency;
std::vector<enum audioChannel> m_channelMap;
enum audioFormat m_format;
protected:
std::vector<int8_t> m_data; //!< pointer on the data.
int8_t m_sampleSize; //!< Size of one sample
int8_t m_chunkSize; //!< Size of one chunk Size
public:
/**
* @brief Get the buffer casted in float*
* @return Pointer on the buffer with correct cast.
*/
template<typename T> T* getData() {
return static_cast<T*>(&m_data[0]);
}
/**
* @breif Clean all sample in the buffer
*/
void clear();
/**
* @brief Resize the buffer at a new size.
* @param[in] _nbChunks Number of chunk requested.
*/
void resize(size_t _nbChunks);
/**
* @brief Get number of chunk in the buffer.
* @return Number of chunk in the buffer.
*/
size_t size();
};
};

View File

@ -1,12 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/core/BufferAudioFreq.hpp>
eaudiofx::BufferAudioFreq::BufferAudioFreq(eaudiofx::Block& _parent) :
eaudiofx::BufferAudio(_parent) {
}

View File

@ -1,18 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/BufferAudio.hpp>
namespace eaudiofx {
class BufferAudioFreq : public eaudiofx::BufferAudio {
public:
BufferAudioFreq(eaudiofx::Block& _parent);
virtual ~BufferAudioFreq() {};
};
};

View File

@ -1,75 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/core/Processing.hpp>
#include <unistd.h>
eaudiofx::Processing::Processing() {
addObjectType("eaudiofx::Processing");
};
int32_t eaudiofx::Processing::process() {
EAUDIOFX_INFO("Start process : '" << propertyName << "'");
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::Processing::start() {
eaudiofx::Thread::start();
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::Processing::stop() {
eaudiofx::Thread::stop();
return eaudiofx::ERR_NONE;
}
int32_t eaudiofx::Processing::waitEndOfProcess() {
EAUDIOFX_INFO("wait end of Processing : '" << propertyName << "'");
return eaudiofx::ERR_NONE;
}
bool eaudiofx::Processing::stateStart() {
EAUDIOFX_INFO("Start Processing : '" << propertyName << "'");
// TODO : Add return code ... and test all of theses events ...
EAUDIOFX_ERROR("======================================");
// Init request flow update:
flowLinkInput();
EAUDIOFX_ERROR("======================================");
// check if the IOs are compatible
flowCheckAllCompatibility();
EAUDIOFX_ERROR("======================================");
// Allocate all Outputs
flowAllocateOutput();
EAUDIOFX_ERROR("======================================");
// Get pointer on all Inputs
flowGetInput();
EAUDIOFX_ERROR("======================================");
// init algorithm
int32_t ret = algoInit();
if (ret != eaudiofx::ERR_NONE) {
return ret;
}
eaudiofx::BlockMeta::algoStart();
return false;
}
bool eaudiofx::Processing::stateRun() {
EAUDIOFX_INFO("Process : '" << propertyName << "'");
usleep(10000);
return false;
}
bool eaudiofx::Processing::stateStop() {
EAUDIOFX_INFO("Stop Processing : '" << propertyName << "'");
int32_t ret = eaudiofx::BlockMeta::algoStop();
if (ret != eaudiofx::ERR_NONE) {
return ret;
}
algoUnInit();
return false;
}

View File

@ -1,38 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/audio.hpp>
#include <eaudiofx/core/Buffer.hpp>
#include <eaudiofx/core/Block.hpp>
#include <eaudiofx/core/BlockMeta.hpp>
#include <eaudiofx/Thread.hpp>
#include <vector>
namespace eaudiofx {
class Processing : public eaudiofx::BlockMeta, eaudiofx::Thread {
protected:
Processing();
void init() {
eaudiofx::BlockMeta::init();
};
public:
DECLARE_FACTORY(Processing);
virtual ~Processing() {};
public:
int32_t process();
int32_t start();
int32_t stop();
int32_t waitEndOfProcess();
// Thread interface :
virtual bool stateStart();
virtual bool stateRun();
virtual bool stateStop();
};
};

View File

@ -1,23 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
namespace eaudiofx {
enum {
ERR_NONE = 0,
ERR_NOT_IMPLEMENTED,
ERR_FAIL,
ERR_ALREADY_EXIST,
ERR_INPUT_NULL,
ERR_FORBIDEN,
ERR_NO_IO,
};
};

View File

@ -1,39 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <elog/log.hpp>
namespace eaudiofx {
int32_t getLogId();
};
#define EAUDIOFX_BASE(info,data) ELOG_BASE(eaudiofx::getLogId(),info,data)
#define EAUDIOFX_PRINT(data) EAUDIOFX_BASE(1, data)
#define EAUDIOFX_CRITICAL(data) EAUDIOFX_BASE(1, data)
#define EAUDIOFX_ERROR(data) EAUDIOFX_BASE(2, data)
#define EAUDIOFX_WARNING(data) EAUDIOFX_BASE(3, data)
#ifdef DEBUG
#define EAUDIOFX_INFO(data) EAUDIOFX_BASE(4, data)
#define EAUDIOFX_DEBUG(data) EAUDIOFX_BASE(5, data)
#define EAUDIOFX_VERBOSE(data) EAUDIOFX_BASE(6, data)
#define EAUDIOFX_TODO(data) EAUDIOFX_BASE(4, "TODO : " << data)
#else
#define EAUDIOFX_INFO(data) do { } while(false)
#define EAUDIOFX_DEBUG(data) do { } while(false)
#define EAUDIOFX_VERBOSE(data) do { } while(false)
#define EAUDIOFX_TODO(data) do { } while(false)
#endif
#define EAUDIOFX_ASSERT(cond,data) \
do { \
if (!(cond)) { \
EAUDIOFX_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)

View File

@ -1,14 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <eaudiofx/core/audio.hpp>
#include <eaudiofx/core/Block.hpp>
#include <eaudiofx/core/Buffer.hpp>
#include <eaudiofx/core/Processing.hpp>

View File

@ -1,78 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#include <eaudiofx/debug.hpp>
#include <eaudiofx/flow/Interface.hpp>
#include <eaudiofx/flow/Base.hpp>
#include <eaudiofx/core/Block.hpp>
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) {
m_ref = ememory::makeShared<BaseReference>(this);
// add a reference on the current signal ...
m_flowInterfaceLink.flowAdd(this);
m_formatAvaillable.parse(_formatAvaillable);
EAUDIOFX_INFO("Create flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' prop:");
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) {
_os << _obj.getName();
return _os;
}
void eaudiofx::flow::Base::link() {
EAUDIOFX_INFO(" link flow : '" << m_name << "' mode:'" << (m_input==true?"input":"output") << "' (no code)");
}
int32_t eaudiofx::flow::Base::checkCompatibility() {
EAUDIOFX_INFO(" check flow : '" << m_name << "' (no code)");
return -1;
}
void eaudiofx::flow::Base::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 ...
ememory::SharedPtr<eaudiofx::flow::BaseReference> eaudiofx::flow::Base::getFlowReference(const std::string& _blockName,
const std::string& _flowLinkName) {
ememory::SharedPtr<eaudiofx::flow::BaseReference> out;
if (_flowLinkName == "") {
EAUDIOFX_INFO(" Get flow : " << _blockName << ":" << _flowLinkName << " nothing to do ==> no connection ...");
}
ememory::SharedPtr<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;
}
/*
ememory::SharedPtr<eaudiofx::Block> eaudiofx::flow::Base::getBlockNamed(const std::string& _name) {
EAUDIOFX_ERROR("NEED to call Parrent ...");
return nullptr;
}
*/

View File

@ -1,107 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <ejson/ejson.hpp>
#include <eaudiofx/flow/Interface.hpp>
#include <eaudiofx/debug.hpp>
#include <ememory/memory.hpp>
namespace eaudiofx {
namespace flow {
class BaseReference;
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 ...)");
}
protected:
ememory::SharedPtr<BaseReference> m_ref; //!< To simplify implementation code we use a temporary variable to shared the current reference...
public:
ememory::SharedPtr<BaseReference> getReference() {
return m_ref;
}
virtual void addReference(const ememory::SharedPtr<BaseReference>& _reference) {
EAUDIOFX_ERROR("[" << m_name << "] Can not add reference ...");
}
protected:
ememory::SharedPtr<BaseReference> getFlowReference(const std::string& _blockName,
const std::string& _flowLinkName);
public:
virtual void link();
virtual int32_t checkCompatibility();
virtual void getInputBuffer();
//virtual ememory::SharedPtr<eaudiofx::Block> getBlockNamed(const std::string& _name);
};
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 ememory::EnableSharedFromThis<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;
}
};
};
};

View File

@ -1,144 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <functional>
#include <eaudiofx/flow/Base.hpp>
#include <eaudiofx/core/Buffer.hpp>
#include <eaudiofx/debug.hpp>
namespace eaudiofx {
class Buffer;
template<typename T = eaudiofx::Buffer> class Flow : public flow::Base {
protected:
ememory::SharedPtr<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 ememory::SharedPtr<eaudiofx::Buffer>& _data){
m_data.reset();
ememory::SharedPtr<T> check = ememory::dynamicPointerCast<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 {
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
ememory::WeakPtr<BaseReference> m_remoteFlow; //!< reference on the remote flow.
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 << "'");
}
virtual void link() {
EAUDIOFX_INFO(" link flow : '" << Base::m_name << "' mode:'input' to " << m_blockName << ":" << m_flowName);
ememory::SharedPtr<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());
}
};
template<typename T> class Output : public Flow<T> {
protected:
std::vector<ememory::WeakPtr<BaseReference>> m_remoteFlow; //!< List of reference on the remote flow (multiple childs).
ejson::Object m_formatMix; //!< current format that is now availlable on the flow (can be on error) represent the intersection of all flow connected
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() { };
virtual void addReference(const ememory::SharedPtr<BaseReference>& _reference) {
m_remoteFlow.push_back(_reference);
}
virtual int32_t checkCompatibility() {
EAUDIOFX_INFO(" check for : '" << Base::m_name << "' to " << m_remoteFlow.size() << " links");
std::vector<ejson::Object> list;
list.push_back(Base::getCapabilities());
for (auto &it : m_remoteFlow) {
ememory::SharedPtr<BaseReference> tmp = it.lock();
if (tmp != nullptr) {
if (tmp->getBase() != nullptr) {
list.push_back(tmp->getBase()->getCapabilities());
}
}
}
m_formatMix = Base::m_flowInterfaceLink.getFlowIntersection(list);
// TODO : Check input property
EAUDIOFX_INFO("[" << Base::m_name << "] mix signal : ");
m_formatMix.display();
return 0;
}
};
};
};

View File

@ -1,85 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2014, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <vector>
#include <map>
#include <ejson/ejson.hpp>
namespace eaudiofx {
class Block;
namespace flow {
class Base;
class BaseReference;
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 flowLinkInput();
// check if the IOs are compatible
virtual void flowCheckAllCompatibility();
// Allocate all Outputs
virtual void flowAllocateOutput();
// Get pointer on all Inputs
virtual void flowGetInput();
/**
* @brief Get The block named ...
* @param[in] _name Name of the block requested
* @return The block requested if it exist.
*/
virtual ememory::SharedPtr<eaudiofx::Block> getBlockNamed(const std::string& _name) {
return nullptr;
}
ememory::SharedPtr<eaudiofx::flow::BaseReference> getFlowReference(const std::string& _name);
public:
ejson::Object getFlowIntersection(const std::vector<ejson::Object>& _list);
};
};
};

View File

@ -33,25 +33,25 @@ def create(target, module_name):
my_module = module.Module(__file__, module_name, get_type())
# System core
my_module.add_src_file([
'eaudiofx/debug.cpp',
'eaudiofx/Thread.cpp',
'eaudiofx/flow/Base.cpp',
'eaudiofx/flow/Interface.cpp',
'eaudiofx/core/audio.cpp',
'eaudiofx/core/Processing.cpp',
'eaudiofx/core/Block.cpp',
'eaudiofx/core/BlockMeta.cpp',
'eaudiofx/core/Buffer.cpp',
'eaudiofx/core/BufferAudio.cpp',
'eaudiofx/core/BufferAudioFreq.cpp'
'audio/blockEngine/debug.cpp',
'audio/blockEngine/Thread.cpp',
'audio/blockEngine/flow/Base.cpp',
'audio/blockEngine/flow/Interface.cpp',
'audio/blockEngine/core/audio.cpp',
'audio/blockEngine/core/Processing.cpp',
'audio/blockEngine/core/Block.cpp',
'audio/blockEngine/core/BlockMeta.cpp',
'audio/blockEngine/core/Buffer.cpp',
'audio/blockEngine/core/BufferAudio.cpp',
'audio/blockEngine/core/BufferAudioFreq.cpp'
])
# basic nodes:
my_module.add_src_file([
#'eaudiofx/base/GeneratorFile.cpp',
#'eaudiofx/base/ReceiverFile.cpp',
#'eaudiofx/base/GeneratorRiver.cpp',
'eaudiofx/base/ReceiverRiver.cpp',
'eaudiofx/base/GeneratorSignal.cpp'
#'audio/blockEngine/base/GeneratorFile.cpp',
#'audio/blockEngine/base/ReceiverFile.cpp',
#'audio/blockEngine/base/GeneratorRiver.cpp',
'audio//blockEngine/base/ReceiverRiver.cpp',
'audio/blockEngine/base/GeneratorSignal.cpp'
])
# name of the dependency
@ -61,7 +61,29 @@ def create(target, module_name):
'ejson'
])
my_module.add_path(tools.get_current_path(__file__), export=True)
my_module.add_header_file([
'audio/blockEngine/Thread.hpp',
'audio/blockEngine/flow/Base.hpp',
'audio/blockEngine/flow/Flow.hpp',
'audio/blockEngine/flow/Interface.hpp',
'audio/blockEngine/core/Buffer.hpp',
'audio/blockEngine/core/BufferAudioFreq.hpp',
'audio/blockEngine/core/Block.hpp',
'audio/blockEngine/core/BlockMeta.hpp',
'audio/blockEngine/core/Processing.hpp',
'audio/blockEngine/core/BufferAudio.hpp',
'audio/blockEngine/core/audio.hpp',
'audio/blockEngine/base/GeneratorRiver.hpp',
'audio/blockEngine/base/GeneratorFile.hpp',
'audio/blockEngine/base/ReceiverFile.hpp',
'audio/blockEngine/base/ReceiverRiver.hpp',
'audio/blockEngine/base/GeneratorSignal.hpp',
'audio/blockEngine/debug.hpp',
'audio/blockEngine/eaudiofx.hpp',
])
#my_module.add_path(tools.get_current_path(__file__))
return my_module

View File

@ -9,12 +9,12 @@
#include <test/Windows.hpp>
#include <ewol/widget/Label.hpp>
#include <etk/tool.hpp>
#include <eaudiofx/eaudiofx.hpp>
#include <audio/blockEngine/eaudiofx.hpp>
#include <ewol/widget/Button.hpp>
#include <unistd.h>
#include <eaudiofx/base/GeneratorSignal.hpp>
#include <eaudiofx/base/ReceiverRiver.hpp>
#include <audio/blockEngine/base/GeneratorSignal.hpp>
#include <audio/blockEngine/base/ReceiverRiver.hpp>
static const char* const g_eventPlay1 = "appl-play-1";
@ -68,13 +68,13 @@ void appl::Windows::onCallbackPlayStop() {
void appl::Windows::onCallbackPlay() {
#if 0
APPL_INFO("Play Requested ...");
m_process = eaudiofx::Processing::create();
m_process = audio::blockEngine::Processing::create();
if (m_process == nullptr) {
APPL_ERROR("can not create processing ...");
return;
}
APPL_INFO("Create Generator ...");
ememory::SharedPtr<eaudiofx::GeneratorFile> generator = eaudiofx::GeneratorFile::create();
ememory::SharedPtr<audio::blockEngine::GeneratorFile> generator = audio::blockEngine::GeneratorFile::create();
if (generator == nullptr) {
APPL_ERROR("can not create Generator ...");
return;
@ -83,7 +83,7 @@ void appl::Windows::onCallbackPlay() {
m_process->addBlock(generator);
APPL_INFO("Create DECODER ...");
ememory::SharedPtr<eaudiofx::BlockDecoder> decoder = eaudiofx::BlockDecoder::create();
ememory::SharedPtr<audio::blockEngine::BlockDecoder> decoder = audio::blockEngine::BlockDecoder::create();
if (decoder == nullptr) {
APPL_ERROR("can not create Generator ...");
return;
@ -92,7 +92,7 @@ void appl::Windows::onCallbackPlay() {
m_process->addBlock(decoder);
APPL_INFO("Create Receiver ...");
ememory::SharedPtr<eaudiofx::ReceiverRtAudio> receiver = eaudiofx::ReceiverRtAudio::create();
ememory::SharedPtr<audio::blockEngine::ReceiverRtAudio> receiver = audio::blockEngine::ReceiverRtAudio::create();
if (receiver == nullptr) {
APPL_ERROR("can not create Receiver ...");
return;
@ -107,14 +107,14 @@ void appl::Windows::onCallbackPlay() {
return;
#else
APPL_INFO("Play Requested ...");
m_process = eaudiofx::Processing::create();
m_process = audio::blockEngine::Processing::create();
if (m_process == nullptr) {
APPL_ERROR("can not create processing ...");
return;
}
m_process->propertyName.set("main Process");
APPL_INFO("Create Generator Sinus");
ememory::SharedPtr<eaudiofx::GeneratorSignal> generator = eaudiofx::GeneratorSignal::create();
ememory::SharedPtr<audio::blockEngine::GeneratorSignal> generator = audio::blockEngine::GeneratorSignal::create();
if (generator == nullptr) {
APPL_ERROR("can not create Generator ...");
return;
@ -123,7 +123,7 @@ void appl::Windows::onCallbackPlay() {
m_process->addBlock(generator);
APPL_INFO("Create Receiver ...");
ememory::SharedPtr<eaudiofx::ReceiverRiver> receiver = eaudiofx::ReceiverRiver::create();
ememory::SharedPtr<audio::blockEngine::ReceiverRiver> receiver = audio::blockEngine::ReceiverRiver::create();
if (receiver == nullptr) {
APPL_ERROR("can not create Receiver ...");
return;

View File

@ -7,7 +7,7 @@
#include <ewol/widget/Windows.hpp>
#include <ewol/widget/Composer.hpp>
#include <eaudiofx/core/Processing.hpp>
#include <audio/blockEngine/core/Processing.hpp>
namespace appl {
class Windows : public ewol::widget::Windows {
@ -22,7 +22,7 @@ namespace appl {
void onCallbackPlay();
void onCallbackStop();
void onCallbackPlayStop();
ememory::SharedPtr<eaudiofx::Processing> m_process;
ememory::SharedPtr<audio::blockEngine::Processing> m_process;
};
}

View File

@ -9,7 +9,7 @@
namespace appl {
int32_t getLogId();
};
}
#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)
#define APPL_PRINT(data) APPL_BASE(-1, data)