Use global FFT planner lock in GUI

This *should* not be needed since the GUI is single
threaded, but it doesn't hurt, just in case some
someday someone uses a background thread :)
This commit is contained in:
Robin Gareus
2025-03-21 15:43:32 +01:00
parent 9f9c775830
commit 2139349468
2 changed files with 6 additions and 0 deletions

View File

@@ -22,6 +22,8 @@
#include <string.h>
#include <math.h>
#include "ardour/ardour.h"
using namespace GTKArdour;
FFT::FFT(uint32_t windowSize)
@@ -37,6 +39,7 @@ FFT::FFT(uint32_t windowSize)
_power_at_bin = (float *) malloc(sizeof(float) * _data_size);
_phase_at_bin = (float *) malloc(sizeof(float) * _data_size);
Glib::Threads::Mutex::Lock lk (ARDOUR::fft_planner_lock);
_plan = fftwf_plan_r2r_1d(_window_size, _fftInput, _fftOutput, FFTW_R2HC, FFTW_ESTIMATE);
reset();
@@ -138,6 +141,7 @@ FFT::~FFT()
if (_hann_window) {
free(_hann_window);
}
Glib::Threads::Mutex::Lock lk (ARDOUR::fft_planner_lock);
fftwf_destroy_plan(_plan);
free(_power_at_bin);
free(_phase_at_bin);

View File

@@ -92,6 +92,7 @@ FFTGraph::setWindowSize_internal (int windowSize)
_windowSize = windowSize;
_dataSize = windowSize / 2;
if (_in != 0) {
Glib::Threads::Mutex::Lock lk (ARDOUR::fft_planner_lock);
fftwf_destroy_plan (_plan);
free (_in);
_in = 0;
@@ -143,6 +144,7 @@ FFTGraph::setWindowSize_internal (int windowSize)
for (unsigned int i = 0; i < _dataSize; i++) {
_logScale[i] = 0;
}
Glib::Threads::Mutex::Lock lk (ARDOUR::fft_planner_lock);
_plan = fftwf_plan_r2r_1d (_windowSize, _in, _out, FFTW_R2HC, FFTW_MEASURE);
}