[DEBUG] correct the segfault error

This commit is contained in:
Edouard DUPIN 2015-01-29 21:46:01 +01:00
parent 65a999c921
commit fac1f70107
16 changed files with 118 additions and 47 deletions

View File

@ -15,15 +15,15 @@ airtalgo::Algo::Algo() :
m_formatSize(0),
m_needProcess(false) {
AIRTALGO_VERBOSE("CREATE ALGO");
}
void airtalgo::Algo::init() {
// set notification callback :
m_input.setCallback(std::bind(&airtalgo::Algo::configurationChange, this));
m_output.setCallback(std::bind(&airtalgo::Algo::configurationChange, this));
// first configure ==> update the internal parameters
configurationChange();
}
airtalgo::Algo::~Algo() {
AIRTALGO_VERBOSE("Remove ALGO");
}
void airtalgo::Algo::configurationChange() {
m_needProcess = false;

View File

@ -15,6 +15,7 @@
#include <airtalgo/channel.h>
#include <chrono>
#include <functional>
#include <memory>
#include "debug.h"
namespace airtalgo{
@ -128,19 +129,20 @@ namespace airtalgo{
};
class Algo {
class Algo : public std::enable_shared_from_this<Algo> {
protected:
std::vector<int8_t> m_outputData;
int8_t m_formatSize; //!< sample size
public:
/**
* @brief Constructor
*/
Algo();
void init();
public:
/**
* @brief Destructor
*/
virtual ~Algo();
virtual ~Algo() {};
protected:
bool m_needProcess; //!< if no change, then no need to process, just forward buffer...
IOFormatInterface m_input; //!< Input audio property

View File

@ -16,10 +16,17 @@
airtalgo::ChannelReorder::ChannelReorder() {
}
airtalgo::ChannelReorder::~ChannelReorder() {
AIRTALGO_INFO("Remove ChannelReorder");
void airtalgo::ChannelReorder::init() {
airtalgo::Algo::init();
}
std::shared_ptr<airtalgo::ChannelReorder> airtalgo::ChannelReorder::create() {
std::shared_ptr<airtalgo::ChannelReorder> tmp(new airtalgo::ChannelReorder());
tmp->init();
return tmp;
}
void airtalgo::ChannelReorder::configurationChange() {
airtalgo::autoLogInOut("ChannelReorder (config)");
@ -46,7 +53,7 @@ bool airtalgo::ChannelReorder::process(std::chrono::system_clock::time_point& _t
size_t _inputNbChunk,
void*& _output,
size_t& _outputNbChunk) {
airtalgo::autoLogInOut("ChannelReorder");
airtalgo::autoLogInOut tmpLog("ChannelReorder");
_outputNbChunk = _inputNbChunk;
// check if we need to process:
if (m_needProcess == false) {

View File

@ -11,15 +11,18 @@
namespace airtalgo{
class ChannelReorder : public Algo {
public:
protected:
/**
* @brief Constructor
*/
ChannelReorder();
void init();
public:
static std::shared_ptr<ChannelReorder> create();
/**
* @brief Destructor
*/
virtual ~ChannelReorder();
virtual ~ChannelReorder() {};
protected:
virtual void configurationChange();
public:

View File

@ -11,11 +11,15 @@
namespace airtalgo{
class EndPoint : public Algo {
public:
protected:
/**
* @brief Constructor
*/
EndPoint() {};
void init() {
airtalgo::Algo::init();
};
public:
/**
* @brief Destructor
*/

View File

@ -10,20 +10,32 @@
#undef __class__
#define __class__ "EndPointCallback"
airtalgo::EndPointCallback::EndPointCallback(needDataFunction _callback) :
m_outputFunction(_callback),
airtalgo::EndPointCallback::EndPointCallback() :
m_outputFunction(nullptr),
m_inputFunction(nullptr) {
}
airtalgo::EndPointCallback::EndPointCallback(haveNewDataFunction _callback) :
m_outputFunction(nullptr),
m_inputFunction(_callback) {
void airtalgo::EndPointCallback::init(needDataFunction _callback) {
m_outputFunction = _callback;
airtalgo::EndPoint::init();
}
airtalgo::EndPointCallback::~EndPointCallback() {
AIRTALGO_INFO("Remove EndPointCallback");
void airtalgo::EndPointCallback::init(haveNewDataFunction _callback) {
m_inputFunction = _callback;
airtalgo::EndPoint::init();
}
std::shared_ptr<airtalgo::EndPointCallback> airtalgo::EndPointCallback::create(needDataFunction _callback) {
std::shared_ptr<airtalgo::EndPointCallback> tmp(new airtalgo::EndPointCallback());
tmp->init(_callback);
return tmp;
}
std::shared_ptr<airtalgo::EndPointCallback> airtalgo::EndPointCallback::create(haveNewDataFunction _callback) {
std::shared_ptr<airtalgo::EndPointCallback> tmp(new airtalgo::EndPointCallback());
tmp->init(_callback);
return tmp;
}
void airtalgo::EndPointCallback::configurationChange() {
airtalgo::EndPoint::configurationChange();
@ -37,7 +49,7 @@ bool airtalgo::EndPointCallback::process(std::chrono::system_clock::time_point&
size_t _inputNbChunk, // requested number of sample ...
void*& _output,
size_t& _outputNbChunk){
airtalgo::autoLogInOut("EndPointCallback");
airtalgo::autoLogInOut tmpLog("EndPointCallback");
if (m_outputFunction != nullptr) {
// update buffer size ...
m_outputData.resize(_inputNbChunk*m_output.getMap().size()*m_formatSize);

View File

@ -26,16 +26,20 @@ namespace airtalgo {
private:
needDataFunction m_outputFunction;
haveNewDataFunction m_inputFunction;
public:
protected:
/**
* @brief Constructor
*/
EndPointCallback(needDataFunction _callback);
EndPointCallback(haveNewDataFunction _callback);
EndPointCallback();
void init(needDataFunction _callback);
void init(haveNewDataFunction _callback);
public:
static std::shared_ptr<EndPointCallback> create(needDataFunction _callback);
static std::shared_ptr<EndPointCallback> create(haveNewDataFunction _callback);
/**
* @brief Destructor
*/
virtual ~EndPointCallback();
virtual ~EndPointCallback() {};
virtual void configurationChange();
virtual bool process(std::chrono::system_clock::time_point& _time,
void* _input,

View File

@ -14,10 +14,16 @@ airtalgo::EndPointRead::EndPointRead() {
}
airtalgo::EndPointRead::~EndPointRead() {
AIRTALGO_INFO("Remove EndPointRead");
void airtalgo::EndPointRead::init() {
airtalgo::EndPoint::init();
}
std::shared_ptr<airtalgo::EndPointRead> airtalgo::EndPointRead::create() {
std::shared_ptr<airtalgo::EndPointRead> tmp(new airtalgo::EndPointRead());
tmp->init();
return tmp;
}
void airtalgo::EndPointRead::configurationChange() {
airtalgo::EndPoint::configurationChange();
@ -30,7 +36,7 @@ bool airtalgo::EndPointRead::process(std::chrono::system_clock::time_point& _tim
size_t _inputNbChunk,
void*& _output,
size_t& _outputNbChunk){
airtalgo::autoLogInOut("EndPointRead");
airtalgo::autoLogInOut tmpLog("EndPointRead");
return false;
}

View File

@ -11,15 +11,18 @@
namespace airtalgo{
class EndPointRead : public EndPoint {
public:
protected:
/**
* @brief Constructor
*/
EndPointRead();
void init();
public:
static std::shared_ptr<EndPointRead> create();
/**
* @brief Destructor
*/
virtual ~EndPointRead();
virtual ~EndPointRead() {};
virtual void configurationChange();
virtual bool process(std::chrono::system_clock::time_point& _time,
void* _input,

View File

@ -15,10 +15,14 @@ airtalgo::EndPointWrite::EndPointWrite() :
}
void airtalgo::EndPointWrite::init() {
airtalgo::EndPoint::init();
}
airtalgo::EndPointWrite::~EndPointWrite() {
AIRTALGO_INFO("Remove EndPointWrite");
std::shared_ptr<airtalgo::EndPointWrite> airtalgo::EndPointWrite::create() {
std::shared_ptr<airtalgo::EndPointWrite> tmp(new airtalgo::EndPointWrite());
tmp->init();
return tmp;
}
void airtalgo::EndPointWrite::configurationChange() {
@ -32,7 +36,7 @@ bool airtalgo::EndPointWrite::process(std::chrono::system_clock::time_point& _ti
size_t _inputNbChunk,
void*& _output,
size_t& _outputNbChunk){
airtalgo::autoLogInOut("EndPointWrite");
airtalgo::autoLogInOut tmpLog("EndPointWrite");
//AIRTALGO_INFO(" nb Sample in buffer : " << m_tmpData.size());
if (m_function != nullptr) {
if (m_tmpData.size() <= 20000) {

View File

@ -21,15 +21,18 @@ namespace airtalgo{
std::vector<int8_t> m_tmpData;
needDataFunctionWrite m_function;
std::mutex m_mutex;
public:
protected:
/**
* @brief Constructor
*/
EndPointWrite();
void init();
public:
static std::shared_ptr<EndPointWrite> create();
/**
* @brief Destructor
*/
virtual ~EndPointWrite();
virtual ~EndPointWrite() {};
virtual void configurationChange();
virtual bool process(std::chrono::system_clock::time_point& _time,
void* _input,

View File

@ -127,11 +127,18 @@ static void convert__float__to__int32(void* _input, void* _output, size_t _nbSam
airtalgo::FormatUpdate::FormatUpdate() :
m_functionConvert(NULL) {
m_functionConvert(nullptr) {
}
airtalgo::FormatUpdate::~FormatUpdate() {
AIRTALGO_INFO("Remove FormatUpdate");
void airtalgo::FormatUpdate::init() {
airtalgo::Algo::init();
}
std::shared_ptr<airtalgo::FormatUpdate> airtalgo::FormatUpdate::create() {
std::shared_ptr<airtalgo::FormatUpdate> tmp(new airtalgo::FormatUpdate());
tmp->init();
return tmp;
}
void airtalgo::FormatUpdate::configurationChange() {
@ -240,7 +247,7 @@ bool airtalgo::FormatUpdate::process(std::chrono::system_clock::time_point& _tim
size_t _inputNbChunk,
void*& _output,
size_t& _outputNbChunk) {
airtalgo::autoLogInOut("FormatUpdate");
airtalgo::autoLogInOut tmpLog("FormatUpdate");
// chack if we need to process:
if (m_needProcess == false) {
_output = _input;

View File

@ -10,15 +10,18 @@
namespace airtalgo {
class FormatUpdate : public Algo {
public:
protected:
/**
* @brief Constructor
*/
FormatUpdate();
void init();
public:
static std::shared_ptr<FormatUpdate> create();
/**
* @brief Destructor
*/
virtual ~FormatUpdate();
virtual ~FormatUpdate() {};
protected:
virtual void configurationChange();
public:

View File

@ -31,7 +31,7 @@ bool airtalgo::Process::push(std::chrono::system_clock::time_point& _time,
size_t _nbChunk) {
void* out = nullptr;
size_t nbChunkOut;
AIRTALGO_VERBOSE(" Interface DIRECT ");
AIRTALGO_VERBOSE(" Process push");
process(_time, _data, _nbChunk, out, nbChunkOut);
return true;
}

View File

@ -19,8 +19,18 @@ airtalgo::Resampler::Resampler() :
m_positionWrite(0) {
}
void airtalgo::Resampler::init() {
airtalgo::Algo::init();
}
std::shared_ptr<airtalgo::Resampler> airtalgo::Resampler::create() {
std::shared_ptr<airtalgo::Resampler> tmp(new airtalgo::Resampler());
tmp->init();
return tmp;
}
airtalgo::Resampler::~Resampler() {
AIRTALGO_INFO("Remove Resampler");
#ifdef HAVE_SPEEX_DSP_RESAMPLE
if (m_speexResampler != nullptr) {
speex_resampler_destroy(m_speexResampler);
@ -71,7 +81,7 @@ bool airtalgo::Resampler::process(std::chrono::system_clock::time_point& _time,
size_t _inputNbChunk,
void*& _output,
size_t& _outputNbChunk) {
airtalgo::autoLogInOut("Resampler");
airtalgo::autoLogInOut tmpLog("Resampler");
_outputNbChunk = 2048;
// chack if we need to process:
if (m_needProcess == false) {
@ -95,7 +105,7 @@ bool airtalgo::Resampler::process(std::chrono::system_clock::time_point& _time,
AIRTALGO_VERBOSE(" Frame duration=" << nbInputTime);
AIRTALGO_VERBOSE(" nbInput chunk=" << _inputNbChunk << " nbOutputChunk=" << nbOutputSample);
m_outputData.resize(_outputNbChunk*m_output.getMap().size()*m_formatSize);
m_outputData.resize(_outputNbChunk*m_output.getMap().size()*m_formatSize*16);
_output = &(m_outputData[0]);
if (m_speexResampler == nullptr) {
AIRTALGO_ERROR(" No speex resampler");

View File

@ -21,11 +21,14 @@ namespace airtalgo {
#endif
size_t m_positionRead; //!< For residual data in the buffer last read number of chunk
size_t m_positionWrite; //!< Current pointer of writing new output data of resampler
public:
protected:
/**
* @brief Constructor
*/
Resampler();
void init();
public:
static std::shared_ptr<Resampler> create();
/**
* @brief Destructor
*/