mirror of https://github.com/f4exb/sdrangel.git
Fixed data race condition in spectrum vis when the FFT size is changed
This commit is contained in:
parent
91cab6c623
commit
6a59ac7e10
|
@ -1,6 +1,7 @@
|
||||||
#ifndef INCLUDE_SPECTRUMVIS_H
|
#ifndef INCLUDE_SPECTRUMVIS_H
|
||||||
#define INCLUDE_SPECTRUMVIS_H
|
#define INCLUDE_SPECTRUMVIS_H
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
#include "dsp/samplesink.h"
|
#include "dsp/samplesink.h"
|
||||||
#include "dsp/fftengine.h"
|
#include "dsp/fftengine.h"
|
||||||
#include "fftwindow.h"
|
#include "fftwindow.h"
|
||||||
|
@ -61,6 +62,8 @@ private:
|
||||||
|
|
||||||
GLSpectrum* m_glSpectrum;
|
GLSpectrum* m_glSpectrum;
|
||||||
|
|
||||||
|
QMutex m_mutex;
|
||||||
|
|
||||||
void handleConfigure(int fftSize, int overlapPercent, FFTWindow::Function window);
|
void handleConfigure(int fftSize, int overlapPercent, FFTWindow::Function window);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) :
|
||||||
m_logPowerSpectrum(MAX_FFT_SIZE),
|
m_logPowerSpectrum(MAX_FFT_SIZE),
|
||||||
m_fftBufferFill(0),
|
m_fftBufferFill(0),
|
||||||
m_needMoreSamples(false),
|
m_needMoreSamples(false),
|
||||||
m_glSpectrum(glSpectrum)
|
m_glSpectrum(glSpectrum),
|
||||||
|
m_mutex(QMutex::Recursive)
|
||||||
{
|
{
|
||||||
setObjectName("SpectrumVis");
|
setObjectName("SpectrumVis");
|
||||||
handleConfigure(1024, 0, FFTWindow::BlackmanHarris);
|
handleConfigure(1024, 0, FFTWindow::BlackmanHarris);
|
||||||
|
@ -77,6 +78,8 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
|
||||||
|
|
||||||
if (todo >= samplesNeeded)
|
if (todo >= samplesNeeded)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
|
||||||
// fill up the buffer
|
// fill up the buffer
|
||||||
std::vector<Complex>::iterator it = m_fftBuffer.begin() + m_fftBufferFill;
|
std::vector<Complex>::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)
|
void SpectrumVis::handleConfigure(int fftSize, int overlapPercent, FFTWindow::Function window)
|
||||||
{
|
{
|
||||||
|
QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
|
||||||
if (fftSize > MAX_FFT_SIZE)
|
if (fftSize > MAX_FFT_SIZE)
|
||||||
{
|
{
|
||||||
fftSize = MAX_FFT_SIZE;
|
fftSize = MAX_FFT_SIZE;
|
||||||
|
|
Loading…
Reference in New Issue