changeset 102:8ce53683d0d7 sv1-v0.9rc2

* I wonder if the fftw_ functions are not as thread-safe as I'd hoped?
author Chris Cannam
date Fri, 12 May 2006 16:51:19 +0000
parents 0f36cdf407a6
children 5064eeb1c76f
files layer/SpectrogramLayer.cpp
diffstat 1 files changed, 20 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Fri May 12 14:40:43 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Fri May 12 16:51:19 2006 +0000
@@ -1328,6 +1328,26 @@
 	    m_layer.setColourmap();
 //!!!	    m_layer.m_writeCache->reset();
 
+	    double *input = (double *)
+		fftw_malloc(windowSize * sizeof(double));
+
+	    fftw_complex *output = (fftw_complex *)
+		fftw_malloc(windowSize * sizeof(fftw_complex));
+
+            float *workbuffer = (float *)
+                fftw_malloc(windowSize * sizeof(float));
+
+	    fftw_plan plan = fftw_plan_dft_r2c_1d(windowSize, input,
+						  output, FFTW_ESTIMATE);
+
+	    if (!plan) {
+		std::cerr << "WARNING: fftw_plan_dft_r2c_1d(" << windowSize << ") failed!" << std::endl;
+		fftw_free(input);
+		fftw_free(output);
+                fftw_free(workbuffer);
+		continue;
+	    }
+
 	    // We don't need a lock when writing to or reading from
 	    // the pixels in the cache.  We do need to ensure we have
 	    // the width and height of the cache and the FFT
@@ -1339,29 +1359,8 @@
 	    // manages, not the layer's).
 	    m_layer.m_mutex.unlock();
 
-	    double *input = (double *)
-		fftw_malloc(windowSize * sizeof(double));
-
-	    fftw_complex *output = (fftw_complex *)
-		fftw_malloc(windowSize * sizeof(fftw_complex));
-
-            float *workbuffer = (float *)
-                fftw_malloc(windowSize * sizeof(float));
-
-	    fftw_plan plan = fftw_plan_dft_r2c_1d(windowSize, input,
-						  output, FFTW_ESTIMATE);
-
 	    Window<double> windower(windowType, windowSize);
 
-	    if (!plan) {
-		std::cerr << "WARNING: fftw_plan_dft_r2c_1d(" << windowSize << ") failed!" << std::endl;
-		fftw_free(input);
-		fftw_free(output);
-                fftw_free(workbuffer);
-		m_layer.m_mutex.lock();
-		continue;
-	    }
-
 	    int counter = 0;
 	    int updateAt = (end / windowIncrement) / 20;
 	    if (updateAt < 100) updateAt = 100;