# HG changeset patch # User Chris Cannam # Date 1147452679 0 # Node ID 8ce53683d0d7ba8c892b333c396522247aaaf007 # Parent 0f36cdf407a684653a2b7cf496272b1d417169d4 * I wonder if the fftw_ functions are not as thread-safe as I'd hoped? diff -r 0f36cdf407a6 -r 8ce53683d0d7 layer/SpectrogramLayer.cpp --- 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 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;