fix FFTW initialisation crash

This commit is contained in:
Christian Daniel 2013-09-24 16:28:57 +02:00
parent 9b9036cdf2
commit c3d0a654af
3 changed files with 18 additions and 3 deletions

View File

@ -109,9 +109,12 @@ set(sdrbase_HEADERS
include-gpl/dsp/dspengine.h
include/dsp/dsptypes.h
include-gpl/dsp/fftengine.h
include-gpl/dsp/fftwengine.h
include-gpl/dsp/fftwindow.h
include-gpl/dsp/interpolator.h
include-gpl/dsp/inthalfbandfilter.h
include/dsp/kissfft.h
include-gpl/dsp/kissengine.h
include-gpl/dsp/lowpass.h
include-gpl/dsp/movingaverage.h
include-gpl/dsp/nco.h

View File

@ -1,6 +1,7 @@
#ifndef INCLUDE_FFTWENGINE_H
#define INCLUDE_FFTWENGINE_H
#include <QMutex>
#include <fftw3.h>
#include <list>
#include "dsp/fftengine.h"
@ -17,6 +18,8 @@ public:
Complex* out();
protected:
static QMutex m_globalPlanMutex;
struct Plan {
int n;
bool inverse;

View File

@ -28,26 +28,35 @@ void FFTWEngine::configure(int n, bool inverse)
m_currentPlan->out = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * n);
QTime t;
t.start();
m_globalPlanMutex.lock();
m_currentPlan->plan = fftwf_plan_dft_1d(n, m_currentPlan->in, m_currentPlan->out, inverse ? FFTW_BACKWARD : FFTW_FORWARD, FFTW_PATIENT);
m_globalPlanMutex.unlock();
qDebug("FFT: creating FFTW plan (n=%d,%s) took %dms", n, inverse ? "inverse" : "forward", t.elapsed());
m_plans.push_back(m_currentPlan);
}
void FFTWEngine::transform()
{
fftwf_execute(m_currentPlan->plan);
if(m_currentPlan != NULL)
fftwf_execute(m_currentPlan->plan);
}
Complex* FFTWEngine::in()
{
return reinterpret_cast<Complex*>(m_currentPlan->in);
if(m_currentPlan != NULL)
return reinterpret_cast<Complex*>(m_currentPlan->in);
else return NULL;
}
Complex* FFTWEngine::out()
{
return reinterpret_cast<Complex*>(m_currentPlan->out);
if(m_currentPlan != NULL)
return reinterpret_cast<Complex*>(m_currentPlan->out);
else return NULL;
}
QMutex FFTWEngine::m_globalPlanMutex;
void FFTWEngine::freeAll()
{
for(Plans::iterator it = m_plans.begin(); it != m_plans.end(); ++it) {