summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Daniel <cd@maintech.de>2013-09-24 16:28:57 +0200
committerChristian Daniel <cd@maintech.de>2013-09-24 16:28:57 +0200
commitc3d0a654afe2be8f8dae0d6bbcba5a06f5e407f8 (patch)
tree211933afa43a010e9fc7872c6956004543dbb687
parent9b9036cdf24fc3a5562209e3ee8e54a2c4f47c6a (diff)
fix FFTW initialisation crash
-rw-r--r--CMakeLists.txt3
-rw-r--r--include-gpl/dsp/fftwengine.h3
-rw-r--r--sdrbase/dsp/fftwengine.cpp15
3 files changed, 18 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e36db3..fe5cbf9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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
diff --git a/include-gpl/dsp/fftwengine.h b/include-gpl/dsp/fftwengine.h
index 2da5317..9224ba4 100644
--- a/include-gpl/dsp/fftwengine.h
+++ b/include-gpl/dsp/fftwengine.h
@@ -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;
diff --git a/sdrbase/dsp/fftwengine.cpp b/sdrbase/dsp/fftwengine.cpp
index a19d113..76b189e 100644
--- a/sdrbase/dsp/fftwengine.cpp
+++ b/sdrbase/dsp/fftwengine.cpp
@@ -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) {