[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_formatSize(0),
m_needProcess(false) { m_needProcess(false) {
AIRTALGO_VERBOSE("CREATE ALGO"); AIRTALGO_VERBOSE("CREATE ALGO");
}
void airtalgo::Algo::init() {
// set notification callback : // set notification callback :
m_input.setCallback(std::bind(&airtalgo::Algo::configurationChange, this)); m_input.setCallback(std::bind(&airtalgo::Algo::configurationChange, this));
m_output.setCallback(std::bind(&airtalgo::Algo::configurationChange, this)); m_output.setCallback(std::bind(&airtalgo::Algo::configurationChange, this));
// first configure ==> update the internal parameters // first configure ==> update the internal parameters
configurationChange(); configurationChange();
} }
airtalgo::Algo::~Algo() {
AIRTALGO_VERBOSE("Remove ALGO");
}
void airtalgo::Algo::configurationChange() { void airtalgo::Algo::configurationChange() {
m_needProcess = false; m_needProcess = false;

View File

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

View File

@ -16,10 +16,17 @@
airtalgo::ChannelReorder::ChannelReorder() { 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() { void airtalgo::ChannelReorder::configurationChange() {
airtalgo::autoLogInOut("ChannelReorder (config)"); airtalgo::autoLogInOut("ChannelReorder (config)");
@ -46,7 +53,7 @@ bool airtalgo::ChannelReorder::process(std::chrono::system_clock::time_point& _t
size_t _inputNbChunk, size_t _inputNbChunk,
void*& _output, void*& _output,
size_t& _outputNbChunk) { size_t& _outputNbChunk) {
airtalgo::autoLogInOut("ChannelReorder"); airtalgo::autoLogInOut tmpLog("ChannelReorder");
_outputNbChunk = _inputNbChunk; _outputNbChunk = _inputNbChunk;
// check if we need to process: // check if we need to process:
if (m_needProcess == false) { if (m_needProcess == false) {

View File

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

View File

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

View File

@ -10,20 +10,32 @@
#undef __class__ #undef __class__
#define __class__ "EndPointCallback" #define __class__ "EndPointCallback"
airtalgo::EndPointCallback::EndPointCallback(needDataFunction _callback) : airtalgo::EndPointCallback::EndPointCallback() :
m_outputFunction(_callback), m_outputFunction(nullptr),
m_inputFunction(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() { void airtalgo::EndPointCallback::init(haveNewDataFunction _callback) {
AIRTALGO_INFO("Remove EndPointCallback"); 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() { void airtalgo::EndPointCallback::configurationChange() {
airtalgo::EndPoint::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 ... size_t _inputNbChunk, // requested number of sample ...
void*& _output, void*& _output,
size_t& _outputNbChunk){ size_t& _outputNbChunk){
airtalgo::autoLogInOut("EndPointCallback"); airtalgo::autoLogInOut tmpLog("EndPointCallback");
if (m_outputFunction != nullptr) { if (m_outputFunction != nullptr) {
// update buffer size ... // update buffer size ...
m_outputData.resize(_inputNbChunk*m_output.getMap().size()*m_formatSize); m_outputData.resize(_inputNbChunk*m_output.getMap().size()*m_formatSize);

View File

@ -26,16 +26,20 @@ namespace airtalgo {
private: private:
needDataFunction m_outputFunction; needDataFunction m_outputFunction;
haveNewDataFunction m_inputFunction; haveNewDataFunction m_inputFunction;
public: protected:
/** /**
* @brief Constructor * @brief Constructor
*/ */
EndPointCallback(needDataFunction _callback); EndPointCallback();
EndPointCallback(haveNewDataFunction _callback); 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 * @brief Destructor
*/ */
virtual ~EndPointCallback(); virtual ~EndPointCallback() {};
virtual void configurationChange(); virtual void configurationChange();
virtual bool process(std::chrono::system_clock::time_point& _time, virtual bool process(std::chrono::system_clock::time_point& _time,
void* _input, 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() { void airtalgo::EndPointRead::configurationChange() {
airtalgo::EndPoint::configurationChange(); airtalgo::EndPoint::configurationChange();
@ -30,7 +36,7 @@ bool airtalgo::EndPointRead::process(std::chrono::system_clock::time_point& _tim
size_t _inputNbChunk, size_t _inputNbChunk,
void*& _output, void*& _output,
size_t& _outputNbChunk){ size_t& _outputNbChunk){
airtalgo::autoLogInOut("EndPointRead"); airtalgo::autoLogInOut tmpLog("EndPointRead");
return false; return false;
} }

View File

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

View File

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

View File

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

View File

@ -127,11 +127,18 @@ static void convert__float__to__int32(void* _input, void* _output, size_t _nbSam
airtalgo::FormatUpdate::FormatUpdate() : 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() { void airtalgo::FormatUpdate::configurationChange() {
@ -240,7 +247,7 @@ bool airtalgo::FormatUpdate::process(std::chrono::system_clock::time_point& _tim
size_t _inputNbChunk, size_t _inputNbChunk,
void*& _output, void*& _output,
size_t& _outputNbChunk) { size_t& _outputNbChunk) {
airtalgo::autoLogInOut("FormatUpdate"); airtalgo::autoLogInOut tmpLog("FormatUpdate");
// chack if we need to process: // chack if we need to process:
if (m_needProcess == false) { if (m_needProcess == false) {
_output = _input; _output = _input;

View File

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

View File

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

View File

@ -19,8 +19,18 @@ airtalgo::Resampler::Resampler() :
m_positionWrite(0) { 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::Resampler::~Resampler() {
AIRTALGO_INFO("Remove Resampler");
#ifdef HAVE_SPEEX_DSP_RESAMPLE #ifdef HAVE_SPEEX_DSP_RESAMPLE
if (m_speexResampler != nullptr) { if (m_speexResampler != nullptr) {
speex_resampler_destroy(m_speexResampler); speex_resampler_destroy(m_speexResampler);
@ -71,7 +81,7 @@ bool airtalgo::Resampler::process(std::chrono::system_clock::time_point& _time,
size_t _inputNbChunk, size_t _inputNbChunk,
void*& _output, void*& _output,
size_t& _outputNbChunk) { size_t& _outputNbChunk) {
airtalgo::autoLogInOut("Resampler"); airtalgo::autoLogInOut tmpLog("Resampler");
_outputNbChunk = 2048; _outputNbChunk = 2048;
// chack if we need to process: // chack if we need to process:
if (m_needProcess == false) { 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(" Frame duration=" << nbInputTime);
AIRTALGO_VERBOSE(" nbInput chunk=" << _inputNbChunk << " nbOutputChunk=" << nbOutputSample); 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]); _output = &(m_outputData[0]);
if (m_speexResampler == nullptr) { if (m_speexResampler == nullptr) {
AIRTALGO_ERROR(" No speex resampler"); AIRTALGO_ERROR(" No speex resampler");

View File

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