1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

FreeDV: removed useless set callback functions. Use mutex appropriately

This commit is contained in:
f4exb 2020-12-09 01:15:38 +01:00
parent 214686beca
commit 04dbb028aa
3 changed files with 15 additions and 16 deletions

View File

@ -141,16 +141,17 @@ FreeDVDemodSink::FreeDVDemodSink() :
m_agcActive(false),
m_squelchDelayLine(2*48000),
m_audioActive(false),
m_spectrumSink(0),
m_spectrumSink(nullptr),
m_audioFifo(24000),
m_freeDV(0),
m_freeDV(nullptr),
m_nSpeechSamples(0),
m_nMaxModemSamples(0),
m_iSpeech(0),
m_iModem(0),
m_speechOut(0),
m_modIn(0),
m_levelInNbSamples(480) // 10ms @ 48 kS/s
m_speechOut(nullptr),
m_modIn(nullptr),
m_levelInNbSamples(480), // 10ms @ 48 kS/s
m_mutex(QMutex::Recursive)
{
m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0;
@ -184,6 +185,7 @@ void FreeDVDemodSink::feed(const SampleVector::const_iterator& begin, const Samp
return;
}
QMutexLocker mlock(&m_mutex);
Complex ci;
for(SampleVector::const_iterator it = begin; it < end; ++it)
@ -393,6 +395,7 @@ void FreeDVDemodSink::applyFreeDVMode(FreeDVDemodSettings::FreeDVMode mode)
m_hiCutoff = FreeDVDemodSettings::getHiCutoff(mode);
m_lowCutoff = FreeDVDemodSettings::getLowCutoff(mode);
uint32_t modemSampleRate = FreeDVDemodSettings::getModSampleRate(mode);
QMutexLocker mlock(&m_mutex);
SSBFilter->create_filter(m_lowCutoff / (float) modemSampleRate, m_hiCutoff / (float) modemSampleRate);
@ -457,10 +460,6 @@ void FreeDVDemodSink::applyFreeDVMode(FreeDVDemodSettings::FreeDVMode mode)
freedv_set_ext_vco(m_freeDV, 0);
freedv_set_sync(m_freeDV, FREEDV_SYNC_MANUAL);
freedv_set_callback_txt(m_freeDV, nullptr, nullptr, nullptr);
freedv_set_callback_protocol(m_freeDV, nullptr, nullptr, nullptr);
freedv_set_callback_data(m_freeDV, nullptr, nullptr, nullptr);
int nSpeechSamples = freedv_get_n_speech_samples(m_freeDV);
int nMaxModemSamples = freedv_get_n_max_modem_samples(m_freeDV);
int Fs = freedv_get_modem_sample_rate(m_freeDV);
@ -563,5 +562,6 @@ void FreeDVDemodSink::getSNRLevels(double& avg, double& peak, int& nbSamples)
void FreeDVDemodSink::resyncFreeDV()
{
QMutexLocker mlock(&m_mutex);
freedv_set_sync(m_freeDV, FREEDV_SYNC_UNSYNC);
}

View File

@ -21,6 +21,7 @@
#include <vector>
#include <QTimer>
#include <QMutex>
#include "dsp/channelsamplesink.h"
#include "dsp/ncof.h"
@ -198,6 +199,7 @@ private:
int m_levelInNbSamples;
Real m_rmsLevel;
Real m_peakLevel;
QMutex m_mutex;
static const unsigned int m_ssbFftLen;
static const float m_agcTarget;

View File

@ -32,7 +32,7 @@ FreeDVModSource::FreeDVModSource() :
m_lowCutoff(0.0),
m_hiCutoff(6000.0),
m_SSBFilter(nullptr),
m_SSBFilterBuffer(0),
m_SSBFilterBuffer(nullptr),
m_SSBFilterBufferIndex(0),
m_audioSampleRate(48000),
m_audioFifo(12000),
@ -45,7 +45,7 @@ FreeDVModSource::FreeDVModSource() :
m_iSpeech(0),
m_iModem(0),
m_speechIn(nullptr),
m_modOut(0),
m_modOut(nullptr),
m_scaleFactor(SDR_TX_SCALEF),
m_mutex(QMutex::Recursive)
{
@ -82,6 +82,7 @@ FreeDVModSource::~FreeDVModSource()
void FreeDVModSource::pull(SampleVector::iterator begin, unsigned int nbSamples)
{
QMutexLocker mlock(&m_mutex);
std::for_each(
begin,
begin + nbSamples,
@ -427,6 +428,7 @@ void FreeDVModSource::applyFreeDVMode(FreeDVModSettings::FreeDVMode mode)
m_hiCutoff = FreeDVModSettings::getHiCutoff(mode);
m_lowCutoff = FreeDVModSettings::getLowCutoff(mode);
int modemSampleRate = FreeDVModSettings::getModSampleRate(mode);
QMutexLocker mlock(&m_mutex);
m_SSBFilter->create_filter(m_lowCutoff / modemSampleRate, m_hiCutoff / modemSampleRate);
@ -493,10 +495,6 @@ void FreeDVModSource::applyFreeDVMode(FreeDVModSettings::FreeDVMode mode)
freedv_set_tx_bpf(m_freeDV, 1);
freedv_set_ext_vco(m_freeDV, 0);
freedv_set_callback_txt(m_freeDV, nullptr, nullptr, nullptr);
freedv_set_callback_protocol(m_freeDV, nullptr, nullptr, nullptr);
freedv_set_callback_data(m_freeDV, nullptr, nullptr, nullptr);
int nSpeechSamples = freedv_get_n_speech_samples(m_freeDV);
int nNomModemSamples = freedv_get_n_nom_modem_samples(m_freeDV);
int Fs = freedv_get_modem_sample_rate(m_freeDV);
@ -557,7 +555,6 @@ void FreeDVModSource::applySettings(const FreeDVModSettings& settings, bool forc
void FreeDVModSource::handleAudio()
{
QMutexLocker mlock(&m_mutex);
unsigned int nbRead;
while ((nbRead = m_audioFifo.read(reinterpret_cast<quint8*>(&m_audioReadBuffer[m_audioReadBufferFill]), 4096)) != 0)