diff --git a/include/dsp/spectrumvis.h b/include/dsp/spectrumvis.h index 9edbbe9ef..46820dbd6 100644 --- a/include/dsp/spectrumvis.h +++ b/include/dsp/spectrumvis.h @@ -1,6 +1,7 @@ #ifndef INCLUDE_SPECTRUMVIS_H #define INCLUDE_SPECTRUMVIS_H +#include #include "dsp/samplesink.h" #include "dsp/fftengine.h" #include "fftwindow.h" @@ -61,6 +62,8 @@ private: GLSpectrum* m_glSpectrum; + QMutex m_mutex; + void handleConfigure(int fftSize, int overlapPercent, FFTWindow::Function window); }; diff --git a/sdrbase/dsp/spectrumvis.cpp b/sdrbase/dsp/spectrumvis.cpp index b8b90763a..aa10c6fbe 100644 --- a/sdrbase/dsp/spectrumvis.cpp +++ b/sdrbase/dsp/spectrumvis.cpp @@ -21,7 +21,8 @@ SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) : m_logPowerSpectrum(MAX_FFT_SIZE), m_fftBufferFill(0), m_needMoreSamples(false), - m_glSpectrum(glSpectrum) + m_glSpectrum(glSpectrum), + m_mutex(QMutex::Recursive) { setObjectName("SpectrumVis"); handleConfigure(1024, 0, FFTWindow::BlackmanHarris); @@ -77,6 +78,8 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV if (todo >= samplesNeeded) { + QMutexLocker mutexLocker(&m_mutex); + // fill up the buffer std::vector::iterator it = m_fftBuffer.begin() + m_fftBufferFill; @@ -174,6 +177,8 @@ bool SpectrumVis::handleMessage(const Message& message) void SpectrumVis::handleConfigure(int fftSize, int overlapPercent, FFTWindow::Function window) { + QMutexLocker mutexLocker(&m_mutex); + if (fftSize > MAX_FFT_SIZE) { fftSize = MAX_FFT_SIZE;