mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-24 11:12:27 -04:00
Deep redesign: NFM and WFM: Mutex to prevent concurrent critical updates with feed method
This commit is contained in:
parent
ca86cb781b
commit
69986fd186
@ -8,9 +8,9 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
|
||||
project(sdrangelove)
|
||||
|
||||
#set(CMAKE_BUILD_TYPE "Release")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
#set(CMAKE_BUILD_TYPE "ReleaseWithDebugInfo")
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
#set(CMAKE_BUILD_TYPE "Debug")
|
||||
|
||||
set(QT_USE_QTOPENGL TRUE)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
@ -35,7 +35,8 @@ NFMDemod::NFMDemod() :
|
||||
m_sampleCount(0),
|
||||
m_afSquelch(2, afSqTones),
|
||||
m_squelchOpen(false),
|
||||
m_audioFifo(4, 48000)
|
||||
m_audioFifo(4, 48000),
|
||||
m_settingsMutex(QMutex::Recursive)
|
||||
{
|
||||
setObjectName("NFMDemod");
|
||||
|
||||
@ -109,10 +110,7 @@ void NFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
||||
{
|
||||
Complex ci;
|
||||
|
||||
if (m_audioFifo.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_settingsMutex.lock();
|
||||
|
||||
for (SampleVector::const_iterator it = begin; it != end; ++it)
|
||||
{
|
||||
@ -257,6 +255,8 @@ void NFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
||||
}
|
||||
|
||||
m_sampleBuffer.clear();
|
||||
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
void NFMDemod::start()
|
||||
@ -322,16 +322,20 @@ void NFMDemod::apply()
|
||||
if((m_config.m_inputSampleRate != m_running.m_inputSampleRate) ||
|
||||
(m_config.m_rfBandwidth != m_running.m_rfBandwidth))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
m_interpolator.create(16, m_config.m_inputSampleRate, m_config.m_rfBandwidth / 2.2);
|
||||
m_interpolatorDistanceRemain = 0;
|
||||
m_interpolatorDistance = (Real) m_config.m_inputSampleRate / (Real) m_config.m_audioSampleRate;
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if((m_config.m_afBandwidth != m_running.m_afBandwidth) ||
|
||||
(m_config.m_audioSampleRate != m_running.m_audioSampleRate))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
m_lowpass.create(301, m_config.m_audioSampleRate, 250.0);
|
||||
m_bandpass.create(301, m_config.m_audioSampleRate, 300.0, m_config.m_afBandwidth);
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if(m_config.m_squelch != m_running.m_squelch)
|
||||
|
@ -18,6 +18,7 @@
|
||||
#ifndef INCLUDE_NFMDEMOD_H
|
||||
#define INCLUDE_NFMDEMOD_H
|
||||
|
||||
#include <QMutex>
|
||||
#include <vector>
|
||||
#include "dsp/samplesink.h"
|
||||
#include "dsp/nco.h"
|
||||
@ -156,6 +157,7 @@ private:
|
||||
SampleVector m_sampleBuffer;
|
||||
|
||||
NFMDemodGUI *m_nfmDemodGUI;
|
||||
QMutex m_settingsMutex;
|
||||
|
||||
void apply();
|
||||
};
|
||||
|
@ -29,7 +29,8 @@ MESSAGE_CLASS_DEFINITION(WFMDemod::MsgConfigureWFMDemod, Message)
|
||||
|
||||
WFMDemod::WFMDemod(SampleSink* sampleSink) :
|
||||
m_sampleSink(sampleSink),
|
||||
m_audioFifo(4, 250000)
|
||||
m_audioFifo(4, 250000),
|
||||
m_settingsMutex(QMutex::Recursive)
|
||||
{
|
||||
setObjectName("WFMDemod");
|
||||
|
||||
@ -75,8 +76,7 @@ void WFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
||||
int rf_out;
|
||||
Real msq, demod;
|
||||
|
||||
if (m_audioFifo.size() <= 0)
|
||||
return;
|
||||
m_settingsMutex.lock();
|
||||
|
||||
for (SampleVector::const_iterator it = begin; it != end; ++it)
|
||||
{
|
||||
@ -160,6 +160,8 @@ void WFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter
|
||||
}
|
||||
|
||||
m_sampleBuffer.clear();
|
||||
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
void WFMDemod::start()
|
||||
@ -235,27 +237,33 @@ void WFMDemod::apply()
|
||||
if((m_config.m_inputSampleRate != m_running.m_inputSampleRate) ||
|
||||
(m_config.m_afBandwidth != m_running.m_afBandwidth))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
qDebug() << "WFMDemod::handleMessage: m_interpolator.create";
|
||||
m_interpolator.create(16, m_config.m_inputSampleRate, m_config.m_afBandwidth);
|
||||
m_interpolatorDistanceRemain = (Real) m_config.m_inputSampleRate / m_config.m_audioSampleRate;
|
||||
m_interpolatorDistance = (Real) m_config.m_inputSampleRate / (Real) m_config.m_audioSampleRate;
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if((m_config.m_inputSampleRate != m_running.m_inputSampleRate) ||
|
||||
(m_config.m_rfBandwidth != m_running.m_rfBandwidth) ||
|
||||
(m_config.m_inputFrequencyOffset != m_running.m_inputFrequencyOffset))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
qDebug() << "WFMDemod::handleMessage: m_rfFilter->create_filter";
|
||||
Real lowCut = (m_config.m_inputFrequencyOffset - (m_config.m_rfBandwidth / 2.0)) / m_config.m_inputSampleRate;
|
||||
Real hiCut = (m_config.m_inputFrequencyOffset + (m_config.m_rfBandwidth / 2.0)) / m_config.m_inputSampleRate;
|
||||
m_rfFilter->create_filter(lowCut, hiCut);
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if((m_config.m_afBandwidth != m_running.m_afBandwidth) ||
|
||||
(m_config.m_audioSampleRate != m_running.m_audioSampleRate))
|
||||
{
|
||||
m_settingsMutex.lock();
|
||||
qDebug() << "WFMDemod::handleMessage: m_lowpass.create";
|
||||
m_lowpass.create(21, m_config.m_audioSampleRate, m_config.m_afBandwidth);
|
||||
m_settingsMutex.unlock();
|
||||
}
|
||||
|
||||
if(m_config.m_squelch != m_running.m_squelch) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
#ifndef INCLUDE_WFMDEMOD_H
|
||||
#define INCLUDE_WFMDEMOD_H
|
||||
|
||||
#include <QMutex>
|
||||
#include <vector>
|
||||
#include "dsp/samplesink.h"
|
||||
#include "dsp/nco.h"
|
||||
@ -127,6 +128,7 @@ private:
|
||||
SampleSink* m_sampleSink;
|
||||
AudioFifo m_audioFifo;
|
||||
SampleVector m_sampleBuffer;
|
||||
QMutex m_settingsMutex;
|
||||
|
||||
void apply();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user