[DEV] exception idea ==> but not supported on Android...

This commit is contained in:
Edouard DUPIN 2014-03-07 21:15:21 +01:00
parent fa2639a2a8
commit b666eb194d
17 changed files with 463 additions and 48 deletions

View File

@ -59,35 +59,32 @@ void eaudiofx::Block::onRemoveBuffer(const eaudiofx::Buffer* _buffer) {
}
}
int32_t eaudiofx::Block::linkBuffer(eaudiofx::Buffer* _buffer, const std::string& _name) {
void eaudiofx::Block::linkBuffer(eaudiofx::Buffer* _buffer, const std::string& _name) {
for (auto &it : m_io) {
if (it.first == _name) {
if (it.second.m_type == ioOutput) {
EAUDIOFX_ERROR("[" << getUID() << "Can not overwrite output buffer...");
return eaudiofx::ERR_FORBIDEN;
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Can not overwrite output buffer");
}
it.second.m_buffer = _buffer;
return eaudiofx::ERR_NONE;
return;
}
}
return eaudiofx::ERR_NO_IO;
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Input or buffer does not existed");
}
int32_t eaudiofx::Block::getBuffer(eaudiofx::Buffer*& _buffer, const std::string& _name) {
void eaudiofx::Block::getBuffer(eaudiofx::Buffer*& _buffer, const std::string& _name) {
for (auto &it : m_io) {
if (it.first == _name) {
if (it.second.m_type == ioInput) {
EAUDIOFX_ERROR("[" << getUID() << "Can not Request Input buffer...");
return eaudiofx::ERR_FORBIDEN;
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Can not Request Input buffer...");
}
if (it.second.m_type == ioParameter) {
EAUDIOFX_ERROR("[" << getUID() << "Can not Request Parameter buffer...");
return eaudiofx::ERR_FORBIDEN;
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Can not Request Parameter buffer...");
}
_buffer = it.second.m_buffer;
return eaudiofx::ERR_NONE;
return;
}
}
return eaudiofx::ERR_NO_IO;
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "Input or buffer does not existed");
}

View File

@ -55,7 +55,7 @@ namespace eaudiofx {
* @brief Set the block name.
* @return The block name.
*/
virtual const std::string& setName(void) {
virtual const std::string& getName(void) {
return m_name;
}
private:
@ -110,50 +110,31 @@ namespace eaudiofx {
* @param[in] _currentTime Current stream time (in second)
* @param[in] _requestTime Data requested (can be chunk number 256 samples, or data byte for stream) (-1 for automatic)
* @param[in] _timeout system time to be obsolet (for realTime streaming) (-1 for no realTime streaming)
* @return generic error
*/
virtual int32_t pull(double _currentTime, int32_t _request, float _timeout) {
return eaudiofx::ERR_NONE;
};
virtual void pull(double _currentTime, int32_t _request, float _timeout) {};
/**
* @brief Get The total stream size (in byte for streaming byte element, in second for time streaming)
* @param[out] _value Get total streaming time (-1 for unknown)
* @return generic error
* @return Get total streaming time (-1 for unknown)
*/
virtual int32_t getTotal(double& _value) {
_value = -1;
return eaudiofx::ERR_NONE;
virtual double getTotal(void) {
return -1.0;
};
/**
* @brief Seek to a specific position in the stream (in byte for streaming byte element, in second for time streaming)
* @param[out] _pos position to seek (0 for starting)
* @return generic error
*/
virtual int32_t seekTo(double _pos) {
return eaudiofx::ERR_NONE;
};
virtual void seekTo(double _pos) {};
/**
* @brief Request a flush of the current buffer
* @param[in] _currentTime Current stream time (in second)
* @param[in] _timeout system time to be obsolet (for realTime streaming) (-1 for no realTime streaming)
* @return generic error
*/
virtual int32_t flush(double _currentTime, float _timeout) {
return eaudiofx::ERR_NONE;
};
virtual void flush(double _currentTime, float _timeout) {};
/**
* @brief Reset the block
* @return generic error
*/
virtual int32_t reset(void) {
return eaudiofx::ERR_NONE;
};
virtual void reset(void) {};
public:
/**
* @brief Call when a block is removed from the system (current)
* @param[in] _block Pointer on the removed block
*/
virtual void onRemoveBlock(const eaudiofx::Block* _block) {};
/**
* @brief Call when a buffer is removed from the system (current).
* @param[in] _buffer Pointer on the removed buffer.
@ -189,16 +170,14 @@ namespace eaudiofx {
* @brief Link the provided buffer to the IO name.
* @param[in] _buffer Pointer on the buffer to link.
* @param[in] _name Name of the IO;
* @return A generic error.
*/
virtual int32_t linkBuffer(eaudiofx::Buffer* _buffer, const std::string& _name);
virtual void linkBuffer(eaudiofx::Buffer* _buffer, const std::string& _name);
/**
* @brief Request a buffer pointer on the IO named.
* @param[out] _buffer Pointer on the buffer to link.
* @param[in] _name Name of the IO;
* @return A generic error.
*/
virtual int32_t getBuffer(eaudiofx::Buffer*& _buffer, const std::string& _name);
virtual void getBuffer(eaudiofx::Buffer*& _buffer, const std::string& _name);
};
};

View File

@ -0,0 +1,11 @@
/**
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <eaudiofx/core/BlockDecoder.h>

View File

@ -0,0 +1,24 @@
/**
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EAUDIOFX_BLOCK_DECODER_H__
#define __EAUDIOFX_BLOCK_DECODER_H__
#include <eaudiofx/core/Block.h>
namespace eaudiofx {
class BlockDecoder : public eaudiofx::Block {
public:
BlockDecoder(void) {};
~BlockDecoder(void) {};
};
};
#endif

View File

@ -0,0 +1,11 @@
/**
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <eaudiofx/core/BlockEncoder.h>

View File

@ -0,0 +1,25 @@
/**
* @author Edouard DUPIN
*
* @copyright 2014, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EAUDIOFX_BLOCK_ENCODER_H__
#define __EAUDIOFX_BLOCK_ENCODER_H__
#include <eaudiofx/core/Block.h>
namespace eaudiofx {
class BlockEncoder : public eaudiofx::Block {
public:
BlockEncoder(void) {};
~BlockEncoder(void) {};
};
};
#endif

View File

@ -15,6 +15,7 @@ eaudiofx::BlockMeta::BlockMeta(void) {
}
eaudiofx::BlockMeta::~BlockMeta(void) {
// TODO : Unlink all ...
for (auto &it : m_list) {
if (it == NULL) {
continue;
@ -23,5 +24,51 @@ eaudiofx::BlockMeta::~BlockMeta(void) {
it = NULL;
delete(tmp);
}
m_list.clear();
}
void eaudiofx::BlockMeta::addBlock(eaudiofx::Block* _block) {
if (_block == NULL) {
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "] Add NULL block");
}
if (_block->getName().size() > 0 ) {
// Check if name exist :
for (auto &it : m_list) {
if (it == NULL) {
continue;
}
if (it->getName() == _block->getName()) {
throw eaudiofx::exeption::StdExeption(std::string("[") + std::to_string(getUID()) + "] Add block name '" + _block->getName() + "' already exist");
}
}
}
m_list.push_back(_block);
}
void eaudiofx::BlockMeta::addBlock(const std::string& _blockType, const std::string& _name) {
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
}
void eaudiofx::BlockMeta::removeBlock(const std::string& _name) {
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
}
void eaudiofx::BlockMeta::replaceFilter(const std::string& _nameUnLink, const std::string& _nameLink) {
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
}
void eaudiofx::BlockMeta::linkBlock(const std::string& _generatorBlockName,
const std::string& _generatorIoName,
const std::string& _receiverBlockName,
const std::string& _receiverIoName) {
}
void eaudiofx::BlockMeta::openFile(const std::string& _fileName) {
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
}
void eaudiofx::BlockMeta::openStream(const std::string& _stream) {
throw eaudiofx::exeption::StdExeption("NOT IMPLEMENTED");
}

View File

@ -19,7 +19,52 @@ namespace eaudiofx {
~BlockMeta(void);
private:
std::vector<eaudiofx::Block*> m_list; //!< list of all block to process.
public:
/**
* @brief Add a block in the Meta-block
* @param[in] _block Pointer on the block (do not free yourself)
*/
void addBlock(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.
*/
void 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
*/
void removeBlock(const std::string& _name);
/**
* @brief Replace a block with an other
* @param[in] _nameUnLink Name of the block to UnLink
* @param[in] _nameLink Name of the block to Link
* @note This free the block pointer
*/
void replaceFilter(const std::string& _nameUnLink, const std::string& _nameLink);
/**
* @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
*/
void 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
*/
void openFile(const std::string& _fileName);
/**
* @brief Open stream property
* @param[in] _stream data stream to open
*/
void openStream(const std::string& _stream);
};
};

View File

@ -74,10 +74,33 @@ namespace eaudiofx {
#define CHANNEL_HEIGHT_TOP 0x04
#define CHANNEL_HEIGHT_BOTTOM 0x08
enum {
ERR_NONE = 0,
ERR_FORBIDEN,
ERR_NO_IO,
namespace exeption {
class StdExeption: public std::exception {
private:
std::string m_comment;
public:
StdExeption(const char* _comment) :
m_comment(_comment) {
}
StdExeption(const std::string& _comment) :
m_comment(_comment) {
}
virtual const char* what() const throw() {
if (m_comment.size() == 0) {
return "No exeption comment define ...";
} else {
return m_comment.c_str();
}
};
};
extern const StdExeption g_nullInput;
extern const StdExeption g_blockAlreadyExist;
extern const StdExeption g_blockHasNoInput;
extern const StdExeption g_blockHasNoOuput;
extern const StdExeption g_blockHasNoParameter;
extern const StdExeption g_forbiden;
};
};

View File

@ -12,12 +12,15 @@ def create(target):
# System core
myModule.add_src_file([
'eaudiofx/debug.cpp',
'eaudiofx/core/audio.cpp',
'eaudiofx/core/Processing.cpp',
'eaudiofx/core/Block.cpp',
'eaudiofx/core/BlockMeta.cpp',
'eaudiofx/core/BlockGenerator.cpp',
'eaudiofx/core/BlockReceiver.cpp',
'eaudiofx/core/BlockFilter.cpp',
'eaudiofx/core/BlockDecoder.cpp',
'eaudiofx/core/BlockEncoder.cpp',
'eaudiofx/core/Buffer.cpp',
'eaudiofx/core/BufferMessage.cpp',
'eaudiofx/core/BufferStream.cpp',

27
lutin_eaudiofx_test.py Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/python
import lutinModule as module
import lutinTools as tools
import lutinDebug as debug
def get_desc():
return "eaudiofx_test : Audio interface FX system test example system"
def create(target):
myModule = module.Module(__file__, 'eaudiofx_test', 'BINARY')
# basic GUI :
myModule.add_src_file([
'test/debug.cpp',
'test/main.cpp',
'test/windows.cpp',
])
# name of the dependency
myModule.add_module_depend(['ewol', 'eaudiofx'])
myModule.add_export_path(tools.get_current_path(__file__))
# add the currrent module at the
return myModule

69
test/Main.cpp Normal file
View File

@ -0,0 +1,69 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#include <etk/types.h>
#include <ewol/ewol.h>
#include <ewol/context/commandLine.h>
#include <appl/debug.h>
#include <appl/Windows.h>
#include <ewol/object/Object.h>
#include <ewol/widget/Manager.h>
#include <ewol/context/Context.h>
#include <appl/widget/VectorDisplay.h>
/**
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
* @param std IO
* @return std IO
*/
int main(int argc, const char *argv[]) {
// only one things to do :
return ewol::run(argc, argv);
}
/**
* @brief main application function Initialisation
*/
bool APP_Init(ewol::Context& _context) {
APPL_INFO("==> Init APPL (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
// TODO : Remove this : Move if in the windows properties
_context.setSize(vec2(800, 600));
// select internal data for font ...
_context.getFontDefault().setUseExternal(true);
_context.getFontDefault().set("FreeSerif;DejaVuSansMono", 19);
appl::widget::VectorDisplay::init(_context.getWidgetManager());
ewol::widget::Windows* basicWindows = new appl::Windows();
// create the specific windows
_context.setWindows(basicWindows);
APPL_INFO("==> Init APPL (END)");
return true;
}
/**
* @brief main application function Un-Initialisation
*/
void APP_UnInit(ewol::Context& _context) {
APPL_INFO("==> Un-Init APPL (START)");
// Nothing to do (main windows will be remove after this call if not done...
ewol::widget::Windows* basicWindows = _context.getWindows();
if (NULL != basicWindows) {
basicWindows->removeObject();
basicWindows = NULL;
}
_context.setWindows(NULL);
APPL_INFO("==> Un-Init APPL (END)");
}

14
test/Main.h Normal file
View File

@ -0,0 +1,14 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __APPL_MAIN_H__
#define __APPL_MAIN_H__
#endif

71
test/Windows.cpp Normal file
View File

@ -0,0 +1,71 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#include <ewol/ewol.h>
#include <test/debug.h>
#include <test/Windows.h>
#include <ewol/widget/Label.h>
#include <etk/tool.h>
#undef __class__
#define __class__ "Windows"
static const char* const g_eventPlay1 = "appl-play-1";
static const char* const g_eventPlay2 = "appl-play-2";
appl::Windows::Windows(void) :
m_composer(NULL) {
setTitle("example 001_HelloWord");
std::string composition = std::string("");
composition += "<sizer mode='vert'>\n";
composition += " <sizer mode='hori'>\n";
composition += " <button name='bt-play1'>\n";
composition += " <label>\n";
composition += " Play 1\n";
composition += " </label>\n";
composition += " </button>\n";
composition += " <button name='bt-play2'>\n";
composition += " <label>\n";
composition += " Play 2\n";
composition += " </label>\n";
composition += " </button>\n";
composition += " </sizer>\n";
composition += " <spacer expand='true' fill='true'/>\n";
composition += "</sizer>\n";
m_composer = new ewol::widget::Composer(ewol::widget::Composer::String, composition);
if (m_composer == NULL) {
APPL_CRITICAL(" An error occured ... in the windows creatrion ...");
return;
}
setSubWidget(m_composer);
m_composer->registerOnEventNameWidget(this, "bt-play1", "pressed", g_eventPlay1);
m_composer->registerOnEventNameWidget(this, "bt-play2", "pressed", g_eventPlay2);
}
void appl::Windows::onObjectRemove(ewol::Object * _removeObject) {
if (_removeObject == m_composer) {
m_composer = NULL;
markToRedraw();
return;
}
}
void appl::Windows::onReceiveMessage(const ewol::object::Message& _msg) {
if (_msg.getMessage() == g_eventChangeValues) {
return;
}
if (_msg.getMessage() == g_eventAutoMode) {
return;
}
}

28
test/Windows.h Normal file
View File

@ -0,0 +1,28 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __APPL_WINDOWS_H__
#define __APPL_WINDOWS_H__
#include <ewol/widget/Windows.h>
#include <ewol/widget/Composer.h>
namespace appl {
class Windows : public ewol::widget::Windows {
private:
ewol::widget::Composer* m_composer;
public:
Windows(void);
public: // herited functions
virtual void onObjectRemove(ewol::Object * _removeObject);
virtual void onReceiveMessage(const ewol::object::Message& _msg);
};
};
#endif

12
test/debug.cpp Normal file
View File

@ -0,0 +1,12 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#include <appl/debug.h>
const char * applLogName = "example ";

29
test/debug.h Normal file
View File

@ -0,0 +1,29 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __APPL_DEBUG_H__
#define __APPL_DEBUG_H__
#include <etk/types.h>
#include <etk/debugGeneric.h>
extern const char * applLogName;
#define APPL_CRITICAL(data) ETK_CRITICAL(applLogName, data)
#define APPL_WARNING(data) ETK_WARNING(applLogName, data)
#define APPL_ERROR(data) ETK_ERROR(applLogName, data)
#define APPL_INFO(data) ETK_INFO(applLogName, data)
#define APPL_DEBUG(data) ETK_DEBUG(applLogName, data)
#define APPL_VERBOSE(data) ETK_VERBOSE(applLogName, data)
#define APPL_ASSERT(cond, data) ETK_ASSERT(applLogName, cond, data)
#define APPL_CHECK_INOUT(cond) ETK_CHECK_INOUT(applLogName, cond)
#define APPL_TODO(cond) ETK_TODO(applLogName, cond)
#endif