mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-15 13:07:58 -04:00
Cleanup: demodulator mgr, instances, threads
This commit is contained in:
parent
0b97bd360a
commit
4605eaccf0
@ -18,15 +18,14 @@ class DemodulatorThread;
|
|||||||
class DemodulatorThreadControlCommand {
|
class DemodulatorThreadControlCommand {
|
||||||
public:
|
public:
|
||||||
enum DemodulatorThreadControlCommandEnum {
|
enum DemodulatorThreadControlCommandEnum {
|
||||||
DEMOD_THREAD_CMD_CTL_NULL, DEMOD_THREAD_CMD_CTL_SQUELCH_ON, DEMOD_THREAD_CMD_CTL_SQUELCH_OFF, DEMOD_THREAD_CMD_CTL_TYPE
|
DEMOD_THREAD_CMD_CTL_NULL, DEMOD_THREAD_CMD_CTL_SQUELCH_ON, DEMOD_THREAD_CMD_CTL_SQUELCH_OFF
|
||||||
};
|
};
|
||||||
|
|
||||||
DemodulatorThreadControlCommand() :
|
DemodulatorThreadControlCommand() :
|
||||||
cmd(DEMOD_THREAD_CMD_CTL_NULL), demodType("") {
|
cmd(DEMOD_THREAD_CMD_CTL_NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorThreadControlCommandEnum cmd;
|
DemodulatorThreadControlCommandEnum cmd;
|
||||||
std::string demodType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DemodulatorThreadIQData {
|
class DemodulatorThreadIQData {
|
||||||
@ -48,9 +47,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DemodulatorThreadIQData() {
|
virtual ~DemodulatorThreadIQData() = default;
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Modem;
|
class Modem;
|
||||||
@ -71,34 +68,9 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DemodulatorThreadPostIQData() {
|
virtual ~DemodulatorThreadPostIQData() = default;
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DemodulatorThreadAudioData {
|
|
||||||
public:
|
|
||||||
long long frequency;
|
|
||||||
unsigned int sampleRate;
|
|
||||||
unsigned char channels;
|
|
||||||
|
|
||||||
std::vector<float> *data;
|
|
||||||
|
|
||||||
DemodulatorThreadAudioData() :
|
|
||||||
frequency(0), sampleRate(0), channels(0), data(NULL) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DemodulatorThreadAudioData(long long frequency, unsigned int sampleRate, std::vector<float> *data) :
|
|
||||||
frequency(frequency), sampleRate(sampleRate), channels(1), data(data) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~DemodulatorThreadAudioData() {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
typedef std::shared_ptr<DemodulatorThreadIQData> DemodulatorThreadIQDataPtr;
|
typedef std::shared_ptr<DemodulatorThreadIQData> DemodulatorThreadIQDataPtr;
|
||||||
typedef std::shared_ptr<DemodulatorThreadPostIQData> DemodulatorThreadPostIQDataPtr;
|
typedef std::shared_ptr<DemodulatorThreadPostIQData> DemodulatorThreadPostIQDataPtr;
|
||||||
|
|
||||||
|
@ -20,9 +20,7 @@ DemodVisualCue::DemodVisualCue() {
|
|||||||
squelchBreak.store(false);
|
squelchBreak.store(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodVisualCue::~DemodVisualCue() {
|
DemodVisualCue::~DemodVisualCue() = default;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DemodVisualCue::triggerSquelchBreak(int counter) {
|
void DemodVisualCue::triggerSquelchBreak(int counter) {
|
||||||
squelchBreak.store(counter);
|
squelchBreak.store(counter);
|
||||||
@ -121,7 +119,7 @@ DemodulatorInstance::~DemodulatorInstance() {
|
|||||||
} //end while
|
} //end while
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::setVisualOutputQueue(DemodulatorThreadOutputQueuePtr tQueue) {
|
void DemodulatorInstance::setVisualOutputQueue(const DemodulatorThreadOutputQueuePtr& tQueue) {
|
||||||
demodulatorThread->setOutputQueue("AudioVisualOutput", tQueue);
|
demodulatorThread->setOutputQueue("AudioVisualOutput", tQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,11 +377,11 @@ int DemodulatorInstance::getOutputDevice() {
|
|||||||
return currentOutputDevice;
|
return currentOutputDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
|
void DemodulatorInstance::setDemodulatorType(const std::string& demod_type_in) {
|
||||||
setGain(getGain());
|
setGain(getGain());
|
||||||
if (demodulatorPreThread) {
|
if (demodulatorPreThread) {
|
||||||
std::string currentDemodType = demodulatorPreThread->getDemodType();
|
std::string currentDemodType = demodulatorPreThread->getDemodType();
|
||||||
if ((currentDemodType != "") && (currentDemodType != demod_type_in)) {
|
if ((!currentDemodType.empty()) && (currentDemodType != demod_type_in)) {
|
||||||
lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings();
|
lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings();
|
||||||
lastModemBandwidth[currentDemodType] = demodulatorPreThread->getBandwidth();
|
lastModemBandwidth[currentDemodType] = demodulatorPreThread->getBandwidth();
|
||||||
}
|
}
|
||||||
@ -395,7 +393,7 @@ void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
|
|||||||
|
|
||||||
demodulatorPreThread->setDemodType(demod_type_in);
|
demodulatorPreThread->setDemodType(demod_type_in);
|
||||||
int lastbw = 0;
|
int lastbw = 0;
|
||||||
if (currentDemodType != "" && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) {
|
if (!currentDemodType.empty() && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) {
|
||||||
lastbw = lastModemBandwidth[demod_type_in];
|
lastbw = lastModemBandwidth[demod_type_in];
|
||||||
}
|
}
|
||||||
if (!lastbw) {
|
if (!lastbw) {
|
||||||
@ -407,7 +405,7 @@ void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
|
|||||||
|
|
||||||
#if ENABLE_DIGITAL_LAB
|
#if ENABLE_DIGITAL_LAB
|
||||||
if (isModemInitialized() && getModemType() == "digital") {
|
if (isModemInitialized() && getModemType() == "digital") {
|
||||||
ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)getOutput();
|
auto *outp = (ModemDigitalOutputConsole *)getOutput();
|
||||||
outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency()));
|
outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -463,7 +461,7 @@ void DemodulatorInstance::setFrequency(long long freq) {
|
|||||||
#if ENABLE_DIGITAL_LAB
|
#if ENABLE_DIGITAL_LAB
|
||||||
if (activeOutput) {
|
if (activeOutput) {
|
||||||
if (isModemInitialized() && getModemType() == "digital") {
|
if (isModemInitialized() && getModemType() == "digital") {
|
||||||
ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)getOutput();
|
auto *outp = (ModemDigitalOutputConsole *)getOutput();
|
||||||
outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency()));
|
outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,7 +486,7 @@ void DemodulatorInstance::setAudioSampleRate(int sampleRate) {
|
|||||||
demodulatorPreThread->setAudioSampleRate(sampleRate);
|
demodulatorPreThread->setAudioSampleRate(sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DemodulatorInstance::getAudioSampleRate() {
|
int DemodulatorInstance::getAudioSampleRate() const {
|
||||||
if (!audioThread) {
|
if (!audioThread) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -509,16 +507,16 @@ bool DemodulatorInstance::isFollow() {
|
|||||||
return follow.load();
|
return follow.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::setFollow(bool follow) {
|
void DemodulatorInstance::setFollow(bool follow_in) {
|
||||||
this->follow.store(follow);
|
follow.store(follow_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemodulatorInstance::isTracking() {
|
bool DemodulatorInstance::isTracking() {
|
||||||
return tracking.load();
|
return tracking.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::setTracking(bool tracking) {
|
void DemodulatorInstance::setTracking(bool tracking_in) {
|
||||||
this->tracking.store(tracking);
|
tracking.store(tracking_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemodulatorInstance::isDeltaLock() {
|
bool DemodulatorInstance::isDeltaLock() {
|
||||||
@ -541,10 +539,10 @@ bool DemodulatorInstance::isMuted() {
|
|||||||
return demodulatorThread->isMuted();
|
return demodulatorThread->isMuted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::setMuted(bool muted) {
|
void DemodulatorInstance::setMuted(bool muted_in) {
|
||||||
this->muted = muted;
|
muted = muted_in;
|
||||||
demodulatorThread->setMuted(muted);
|
demodulatorThread->setMuted(muted_in);
|
||||||
wxGetApp().getDemodMgr().setLastMuted(muted);
|
wxGetApp().getDemodMgr().setLastMuted(muted_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemodulatorInstance::isRecording()
|
bool DemodulatorInstance::isRecording()
|
||||||
@ -580,11 +578,11 @@ ModemArgInfoList DemodulatorInstance::getModemArgs() {
|
|||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DemodulatorInstance::readModemSetting(std::string setting) {
|
std::string DemodulatorInstance::readModemSetting(const std::string& setting) {
|
||||||
return demodulatorPreThread->readModemSetting(setting);
|
return demodulatorPreThread->readModemSetting(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorInstance::writeModemSetting(std::string setting, std::string value) {
|
void DemodulatorInstance::writeModemSetting(const std::string& setting, std::string value) {
|
||||||
demodulatorPreThread->writeModemSetting(setting, value);
|
demodulatorPreThread->writeModemSetting(setting, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,7 +608,7 @@ std::string DemodulatorInstance::getModemType() {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
ModemSettings DemodulatorInstance::getLastModemSettings(std::string demodType) {
|
ModemSettings DemodulatorInstance::getLastModemSettings(const std::string& demodType) {
|
||||||
if (lastModemSettings.find(demodType) != lastModemSettings.end()) {
|
if (lastModemSettings.find(demodType) != lastModemSettings.end()) {
|
||||||
return lastModemSettings[demodType];
|
return lastModemSettings[demodType];
|
||||||
} else {
|
} else {
|
||||||
@ -625,8 +623,8 @@ void DemodulatorInstance::startRecording() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioSinkFileThread *newSinkThread = new AudioSinkFileThread();
|
auto *newSinkThread = new AudioSinkFileThread();
|
||||||
AudioFileWAV *afHandler = new AudioFileWAV();
|
auto *afHandler = new AudioFileWAV();
|
||||||
|
|
||||||
std::stringstream fileName;
|
std::stringstream fileName;
|
||||||
|
|
||||||
@ -701,7 +699,7 @@ void DemodulatorInstance::hideOutput() {
|
|||||||
void DemodulatorInstance::closeOutput() {
|
void DemodulatorInstance::closeOutput() {
|
||||||
if (isModemInitialized()) {
|
if (isModemInitialized()) {
|
||||||
if (getModemType() == "digital") {
|
if (getModemType() == "digital") {
|
||||||
ModemDigital *dModem = (ModemDigital *)demodulatorPreThread->getModem();
|
auto *dModem = (ModemDigital *)demodulatorPreThread->getModem();
|
||||||
dModem->setOutput(nullptr);
|
dModem->setOutput(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
DemodulatorInstance();
|
DemodulatorInstance();
|
||||||
~DemodulatorInstance();
|
~DemodulatorInstance();
|
||||||
|
|
||||||
void setVisualOutputQueue(DemodulatorThreadOutputQueuePtr tQueue);
|
void setVisualOutputQueue(const DemodulatorThreadOutputQueuePtr& tQueue);
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
void terminate();
|
void terminate();
|
||||||
@ -76,7 +76,7 @@ public:
|
|||||||
void setOutputDevice(int device_id);
|
void setOutputDevice(int device_id);
|
||||||
int getOutputDevice();
|
int getOutputDevice();
|
||||||
|
|
||||||
void setDemodulatorType(std::string demod_type_in);
|
void setDemodulatorType(const std::string& demod_type_in);
|
||||||
std::string getDemodulatorType();
|
std::string getDemodulatorType();
|
||||||
|
|
||||||
std::wstring getDemodulatorUserLabel();
|
std::wstring getDemodulatorUserLabel();
|
||||||
@ -95,13 +95,13 @@ public:
|
|||||||
long long getFrequency();
|
long long getFrequency();
|
||||||
|
|
||||||
void setAudioSampleRate(int sampleRate);
|
void setAudioSampleRate(int sampleRate);
|
||||||
int getAudioSampleRate();
|
int getAudioSampleRate() const;
|
||||||
|
|
||||||
bool isFollow();
|
bool isFollow();
|
||||||
void setFollow(bool follow);
|
void setFollow(bool follow_in);
|
||||||
|
|
||||||
bool isTracking();
|
bool isTracking();
|
||||||
void setTracking(bool tracking);
|
void setTracking(bool tracking_in);
|
||||||
|
|
||||||
bool isDeltaLock();
|
bool isDeltaLock();
|
||||||
void setDeltaLock(bool lock);
|
void setDeltaLock(bool lock);
|
||||||
@ -109,7 +109,7 @@ public:
|
|||||||
int getDeltaLockOfs();
|
int getDeltaLockOfs();
|
||||||
|
|
||||||
bool isMuted();
|
bool isMuted();
|
||||||
void setMuted(bool muted);
|
void setMuted(bool muted_in);
|
||||||
|
|
||||||
bool isRecording();
|
bool isRecording();
|
||||||
void setRecording(bool recording);
|
void setRecording(bool recording);
|
||||||
@ -119,14 +119,14 @@ public:
|
|||||||
DemodulatorThreadInputQueuePtr getIQInputDataPipe();
|
DemodulatorThreadInputQueuePtr getIQInputDataPipe();
|
||||||
|
|
||||||
ModemArgInfoList getModemArgs();
|
ModemArgInfoList getModemArgs();
|
||||||
std::string readModemSetting(std::string setting);
|
std::string readModemSetting(const std::string& setting);
|
||||||
ModemSettings readModemSettings();
|
ModemSettings readModemSettings();
|
||||||
void writeModemSetting(std::string setting, std::string value);
|
void writeModemSetting(const std::string& setting, std::string value);
|
||||||
void writeModemSettings(ModemSettings settings);
|
void writeModemSettings(ModemSettings settings);
|
||||||
|
|
||||||
bool isModemInitialized();
|
bool isModemInitialized();
|
||||||
std::string getModemType();
|
std::string getModemType();
|
||||||
ModemSettings getLastModemSettings(std::string demodType);
|
ModemSettings getLastModemSettings(const std::string& demodType);
|
||||||
|
|
||||||
#if ENABLE_DIGITAL_LAB
|
#if ENABLE_DIGITAL_LAB
|
||||||
ModemDigitalOutput *getOutput();
|
ModemDigitalOutput *getOutput();
|
||||||
|
@ -2,13 +2,9 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0+
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
#include <DemodulatorMgr.h>
|
#include <DemodulatorMgr.h>
|
||||||
#include <sstream>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "DemodulatorMgr.h"
|
|
||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
|
|
||||||
#if USE_HAMLIB
|
#if USE_HAMLIB
|
||||||
@ -18,8 +14,8 @@
|
|||||||
#include "DataTree.h"
|
#include "DataTree.h"
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
|
||||||
bool demodFreqCompare (DemodulatorInstancePtr i, DemodulatorInstancePtr j) { return (i->getFrequency() < j->getFrequency()); }
|
bool demodFreqCompare (const DemodulatorInstancePtr& i, const DemodulatorInstancePtr& j) { return (i->getFrequency() < j->getFrequency()); }
|
||||||
bool inactiveCompare (DemodulatorInstancePtr i, DemodulatorInstancePtr j) { return (i->isActive() < j->isActive()); }
|
bool inactiveCompare (const DemodulatorInstancePtr& i, const DemodulatorInstancePtr& j) { return (i->isActive() < j->isActive()); }
|
||||||
|
|
||||||
DemodulatorMgr::DemodulatorMgr() {
|
DemodulatorMgr::DemodulatorMgr() {
|
||||||
|
|
||||||
@ -55,7 +51,7 @@ void DemodulatorMgr::terminateAll() {
|
|||||||
|
|
||||||
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
||||||
|
|
||||||
while (demods.size()) {
|
while (!demods.empty()) {
|
||||||
|
|
||||||
DemodulatorInstancePtr d = demods.back();
|
DemodulatorInstancePtr d = demods.back();
|
||||||
demods.pop_back();
|
demods.pop_back();
|
||||||
@ -95,7 +91,7 @@ std::vector<DemodulatorInstancePtr> DemodulatorMgr::getOrderedDemodulators(bool
|
|||||||
return demods_ordered;
|
return demods_ordered;
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorInstancePtr DemodulatorMgr::getPreviousDemodulator(DemodulatorInstancePtr demod, bool actives) {
|
DemodulatorInstancePtr DemodulatorMgr::getPreviousDemodulator(const DemodulatorInstancePtr& demod, bool actives) {
|
||||||
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
||||||
if (!getCurrentModem()) {
|
if (!getCurrentModem()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -112,7 +108,7 @@ DemodulatorInstancePtr DemodulatorMgr::getPreviousDemodulator(DemodulatorInstanc
|
|||||||
return *(--p);
|
return *(--p);
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorInstancePtr DemodulatorMgr::getNextDemodulator(DemodulatorInstancePtr demod, bool actives) {
|
DemodulatorInstancePtr DemodulatorMgr::getNextDemodulator(const DemodulatorInstancePtr& demod, bool actives) {
|
||||||
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
||||||
if (!getCurrentModem()) {
|
if (!getCurrentModem()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -144,7 +140,7 @@ DemodulatorInstancePtr DemodulatorMgr::getFirstDemodulator() {
|
|||||||
return getOrderedDemodulators().front();
|
return getOrderedDemodulators().front();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorMgr::deleteThread(DemodulatorInstancePtr demod) {
|
void DemodulatorMgr::deleteThread(const DemodulatorInstancePtr& demod) {
|
||||||
|
|
||||||
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
||||||
|
|
||||||
@ -176,9 +172,7 @@ std::vector<DemodulatorInstancePtr> DemodulatorMgr::getDemodulatorsAt(long long
|
|||||||
|
|
||||||
std::vector<DemodulatorInstancePtr> foundDemods;
|
std::vector<DemodulatorInstancePtr> foundDemods;
|
||||||
|
|
||||||
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
for (auto testDemod : demods) {
|
||||||
DemodulatorInstancePtr testDemod = demods[i];
|
|
||||||
|
|
||||||
long long freqTest = testDemod->getFrequency();
|
long long freqTest = testDemod->getFrequency();
|
||||||
long long bandwidthTest = testDemod->getBandwidth();
|
long long bandwidthTest = testDemod->getBandwidth();
|
||||||
long long halfBandwidthTest = bandwidthTest / 2;
|
long long halfBandwidthTest = bandwidthTest / 2;
|
||||||
@ -195,9 +189,7 @@ std::vector<DemodulatorInstancePtr> DemodulatorMgr::getDemodulatorsAt(long long
|
|||||||
|
|
||||||
bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
|
bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
|
||||||
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
||||||
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
for (auto testDemod : demods) {
|
||||||
DemodulatorInstancePtr testDemod = demods[i];
|
|
||||||
|
|
||||||
long long freqTest = testDemod->getFrequency();
|
long long freqTest = testDemod->getFrequency();
|
||||||
long long bandwidthTest = testDemod->getBandwidth();
|
long long bandwidthTest = testDemod->getBandwidth();
|
||||||
long long halfBandwidthTest = bandwidthTest / 2;
|
long long halfBandwidthTest = bandwidthTest / 2;
|
||||||
@ -214,7 +206,7 @@ bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DemodulatorMgr::setActiveDemodulator(DemodulatorInstancePtr demod, bool temporary) {
|
void DemodulatorMgr::setActiveDemodulator(const DemodulatorInstancePtr& demod, bool temporary) {
|
||||||
|
|
||||||
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
||||||
|
|
||||||
@ -261,7 +253,7 @@ void DemodulatorMgr::setActiveDemodulator(DemodulatorInstancePtr demod, bool tem
|
|||||||
void DemodulatorMgr::setActiveDemodulatorByRawPointer(DemodulatorInstance* demod, bool temporary) {
|
void DemodulatorMgr::setActiveDemodulatorByRawPointer(DemodulatorInstance* demod, bool temporary) {
|
||||||
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
std::lock_guard < std::recursive_mutex > lock(demods_busy);
|
||||||
|
|
||||||
for (auto existing_demod : demods) {
|
for (const auto& existing_demod : demods) {
|
||||||
|
|
||||||
if (existing_demod.get() == demod) {
|
if (existing_demod.get() == demod) {
|
||||||
|
|
||||||
@ -335,7 +327,7 @@ void DemodulatorMgr::updateLastState() {
|
|||||||
if (currentModem) {
|
if (currentModem) {
|
||||||
lastBandwidth = currentModem->getBandwidth();
|
lastBandwidth = currentModem->getBandwidth();
|
||||||
lastDemodType = currentModem->getDemodulatorType();
|
lastDemodType = currentModem->getDemodulatorType();
|
||||||
lastDemodLock = currentModem->getDemodulatorLock()?true:false;
|
lastDemodLock = currentModem->getDemodulatorLock() != 0;
|
||||||
lastSquelchEnabled = currentModem->isSquelchEnabled();
|
lastSquelchEnabled = currentModem->isSquelchEnabled();
|
||||||
lastSquelch = currentModem->getSquelchLevel();
|
lastSquelch = currentModem->getSquelchLevel();
|
||||||
lastGain = currentModem->getGain();
|
lastGain = currentModem->getGain();
|
||||||
@ -348,29 +340,29 @@ int DemodulatorMgr::getLastBandwidth() const {
|
|||||||
return lastBandwidth;
|
return lastBandwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorMgr::setLastBandwidth(int lastBandwidth) {
|
void DemodulatorMgr::setLastBandwidth(int lastBandwidth_in) {
|
||||||
if (lastBandwidth < MIN_BANDWIDTH) {
|
if (lastBandwidth_in < MIN_BANDWIDTH) {
|
||||||
lastBandwidth = MIN_BANDWIDTH;
|
lastBandwidth_in = MIN_BANDWIDTH;
|
||||||
} else if (lastBandwidth > wxGetApp().getSampleRate()) {
|
} else if (lastBandwidth_in > wxGetApp().getSampleRate()) {
|
||||||
lastBandwidth = wxGetApp().getSampleRate();
|
lastBandwidth_in = wxGetApp().getSampleRate();
|
||||||
}
|
}
|
||||||
this->lastBandwidth = lastBandwidth;
|
lastBandwidth = lastBandwidth_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DemodulatorMgr::getLastDemodulatorType() const {
|
std::string DemodulatorMgr::getLastDemodulatorType() const {
|
||||||
return lastDemodType;
|
return lastDemodType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorMgr::setLastDemodulatorType(std::string lastDemodType) {
|
void DemodulatorMgr::setLastDemodulatorType(std::string lastDemodType_in) {
|
||||||
this->lastDemodType = lastDemodType;
|
lastDemodType = lastDemodType_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
float DemodulatorMgr::getLastGain() const {
|
float DemodulatorMgr::getLastGain() const {
|
||||||
return lastGain;
|
return lastGain;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorMgr::setLastGain(float lastGain) {
|
void DemodulatorMgr::setLastGain(float lastGain_in) {
|
||||||
this->lastGain = lastGain;
|
lastGain = lastGain_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -386,31 +378,31 @@ float DemodulatorMgr::getLastSquelchLevel() const {
|
|||||||
return lastSquelch;
|
return lastSquelch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorMgr::setLastSquelchLevel(float lastSquelch) {
|
void DemodulatorMgr::setLastSquelchLevel(float lastSquelch_in) {
|
||||||
this->lastSquelch = lastSquelch;
|
lastSquelch = lastSquelch_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemodulatorMgr::isLastSquelchEnabled() const {
|
bool DemodulatorMgr::isLastSquelchEnabled() const {
|
||||||
return lastSquelchEnabled;
|
return lastSquelchEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorMgr::setLastSquelchEnabled(bool lastSquelchEnabled) {
|
void DemodulatorMgr::setLastSquelchEnabled(bool lastSquelchEnabled_in) {
|
||||||
this->lastSquelchEnabled = lastSquelchEnabled;
|
lastSquelchEnabled = lastSquelchEnabled_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemodulatorMgr::isLastMuted() const {
|
bool DemodulatorMgr::isLastMuted() const {
|
||||||
return lastMuted;
|
return lastMuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorMgr::setLastMuted(bool lastMuted) {
|
void DemodulatorMgr::setLastMuted(bool lastMuted_in) {
|
||||||
this->lastMuted = lastMuted;
|
lastMuted = lastMuted_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModemSettings DemodulatorMgr::getLastModemSettings(std::string modemType) {
|
ModemSettings DemodulatorMgr::getLastModemSettings(const std::string& modemType) {
|
||||||
return lastModemSettings[modemType];
|
return lastModemSettings[modemType];
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorMgr::setLastModemSettings(std::string modemType, ModemSettings settings) {
|
void DemodulatorMgr::setLastModemSettings(const std::string& modemType, ModemSettings settings) {
|
||||||
lastModemSettings[modemType] = settings;
|
lastModemSettings[modemType] = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +414,7 @@ std::map<int, RtAudio::DeviceInfo> DemodulatorMgr::getOutputDevices() {
|
|||||||
return outputDevices;
|
return outputDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorMgr::saveInstance(DataNode *node, DemodulatorInstancePtr inst) {
|
void DemodulatorMgr::saveInstance(DataNode *node, const DemodulatorInstancePtr& inst) {
|
||||||
|
|
||||||
*node->newChild("bandwidth") = inst->getBandwidth();
|
*node->newChild("bandwidth") = inst->getBandwidth();
|
||||||
*node->newChild("frequency") = inst->getFrequency();
|
*node->newChild("frequency") = inst->getFrequency();
|
||||||
@ -444,7 +436,7 @@ void DemodulatorMgr::saveInstance(DataNode *node, DemodulatorInstancePtr inst) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ModemSettings saveSettings = inst->readModemSettings();
|
ModemSettings saveSettings = inst->readModemSettings();
|
||||||
if (saveSettings.size()) {
|
if (!saveSettings.empty()) {
|
||||||
DataNode *settingsNode = node->newChild("settings");
|
DataNode *settingsNode = node->newChild("settings");
|
||||||
for (ModemSettings::const_iterator msi = saveSettings.begin(); msi != saveSettings.end(); msi++) {
|
for (ModemSettings::const_iterator msi = saveSettings.begin(); msi != saveSettings.end(); msi++) {
|
||||||
*settingsNode->newChild(msi->first.c_str()) = msi->second;
|
*settingsNode->newChild(msi->first.c_str()) = msi->second;
|
||||||
@ -454,7 +446,7 @@ void DemodulatorMgr::saveInstance(DataNode *node, DemodulatorInstancePtr inst) {
|
|||||||
|
|
||||||
std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
|
std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
|
||||||
|
|
||||||
std::wstring decodedWString = L"";
|
std::wstring decodedWString;
|
||||||
|
|
||||||
if (node != nullptr) {
|
if (node != nullptr) {
|
||||||
|
|
||||||
@ -462,7 +454,7 @@ std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
|
|||||||
try {
|
try {
|
||||||
node->element()->get(decodedWString);
|
node->element()->get(decodedWString);
|
||||||
|
|
||||||
} catch (DataTypeMismatchException e) {
|
} catch (const DataTypeMismatchException &e) {
|
||||||
//2) wstring decode fail, try simple std::string
|
//2) wstring decode fail, try simple std::string
|
||||||
std::string decodedStdString;
|
std::string decodedStdString;
|
||||||
try {
|
try {
|
||||||
@ -472,7 +464,7 @@ std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
|
|||||||
//use wxString for a clean conversion to a wstring:
|
//use wxString for a clean conversion to a wstring:
|
||||||
decodedWString = wxString(decodedStdString).ToStdWstring();
|
decodedWString = wxString(decodedStdString).ToStdWstring();
|
||||||
|
|
||||||
} catch (DataTypeMismatchException e) {
|
} catch (const DataTypeMismatchException &e) {
|
||||||
//nothing works, return an empty string.
|
//nothing works, return an empty string.
|
||||||
decodedWString = L"";
|
decodedWString = L"";
|
||||||
}
|
}
|
||||||
@ -490,22 +482,22 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
|
|||||||
|
|
||||||
node->rewindAll();
|
node->rewindAll();
|
||||||
|
|
||||||
long bandwidth = *node->getNext("bandwidth");
|
long bandwidth = (long)*node->getNext("bandwidth");
|
||||||
long long freq = *node->getNext("frequency");
|
long long freq = (long long)*node->getNext("frequency");
|
||||||
float squelch_level = node->hasAnother("squelch_level") ? (float) *node->getNext("squelch_level") : 0;
|
float squelch_level = node->hasAnother("squelch_level") ? (float) *node->getNext("squelch_level") : 0;
|
||||||
int squelch_enabled = node->hasAnother("squelch_enabled") ? (int) *node->getNext("squelch_enabled") : 0;
|
int squelch_enabled = node->hasAnother("squelch_enabled") ? (int) *node->getNext("squelch_enabled") : 0;
|
||||||
int muted = node->hasAnother("muted") ? (int) *node->getNext("muted") : 0;
|
int muted = node->hasAnother("muted") ? (int) *node->getNext("muted") : 0;
|
||||||
int delta_locked = node->hasAnother("delta_lock") ? (int) *node->getNext("delta_lock") : 0;
|
int delta_locked = node->hasAnother("delta_lock") ? (int) *node->getNext("delta_lock") : 0;
|
||||||
int delta_ofs = node->hasAnother("delta_ofs") ? (int) *node->getNext("delta_ofs") : 0;
|
int delta_ofs = node->hasAnother("delta_ofs") ? (int) *node->getNext("delta_ofs") : 0;
|
||||||
std::string output_device = node->hasAnother("output_device") ? string(*(node->getNext("output_device"))) : "";
|
std::string output_device = node->hasAnother("output_device") ? ((string)*(node->getNext("output_device"))) : "";
|
||||||
float gain = node->hasAnother("gain") ? (float) *node->getNext("gain") : 1.0;
|
float gain = node->hasAnother("gain") ? (float) *node->getNext("gain") : 1.0f;
|
||||||
|
|
||||||
std::string type = "FM";
|
std::string type = "FM";
|
||||||
|
|
||||||
DataNode *demodTypeNode = node->hasAnother("type")?node->getNext("type"):nullptr;
|
DataNode *demodTypeNode = node->hasAnother("type")?node->getNext("type"):nullptr;
|
||||||
|
|
||||||
if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::DATA_INT) {
|
if (demodTypeNode && demodTypeNode->element()->getDataType() == DataElement::DATA_INT) {
|
||||||
int legacyType = *demodTypeNode;
|
int legacyType = (int)*demodTypeNode;
|
||||||
int legacyStereo = node->hasAnother("stereo") ? (int) *node->getNext("stereo") : 0;
|
int legacyStereo = node->hasAnother("stereo") ? (int) *node->getNext("stereo") : 0;
|
||||||
switch (legacyType) { // legacy demod ID
|
switch (legacyType) { // legacy demod ID
|
||||||
case 1: type = legacyStereo?"FMS":"FM"; break;
|
case 1: type = legacyStereo?"FMS":"FM"; break;
|
||||||
@ -531,7 +523,7 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//read the user label associated with the demodulator
|
//read the user label associated with the demodulator
|
||||||
std::wstring user_label = L"";
|
std::wstring user_label;
|
||||||
|
|
||||||
DataNode *demodUserLabel = node->hasAnother("user_label") ? node->getNext("user_label") : nullptr;
|
DataNode *demodUserLabel = node->hasAnother("user_label") ? node->getNext("user_label") : nullptr;
|
||||||
|
|
||||||
@ -549,7 +541,7 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
|
|||||||
std::string keyName = settingNode->getName();
|
std::string keyName = settingNode->getName();
|
||||||
std::string strSettingValue = settingNode->element()->toString();
|
std::string strSettingValue = settingNode->element()->toString();
|
||||||
|
|
||||||
if (keyName != "" && strSettingValue != "") {
|
if (!keyName.empty() && !strSettingValue.empty()) {
|
||||||
mSettings[keyName] = strSettingValue;
|
mSettings[keyName] = strSettingValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -564,7 +556,7 @@ DemodulatorInstancePtr DemodulatorMgr::loadInstance(DataNode *node) {
|
|||||||
newDemod->setFrequency(freq);
|
newDemod->setFrequency(freq);
|
||||||
newDemod->setGain(gain);
|
newDemod->setGain(gain);
|
||||||
newDemod->updateLabel(freq);
|
newDemod->updateLabel(freq);
|
||||||
newDemod->setMuted(muted?true:false);
|
newDemod->setMuted(muted != 0);
|
||||||
if (delta_locked) {
|
if (delta_locked) {
|
||||||
newDemod->setDeltaLock(true);
|
newDemod->setDeltaLock(true);
|
||||||
newDemod->setDeltaLockOfs(delta_ofs);
|
newDemod->setDeltaLockOfs(delta_ofs);
|
||||||
|
@ -24,16 +24,16 @@ public:
|
|||||||
std::vector<DemodulatorInstancePtr> getOrderedDemodulators(bool actives = true);
|
std::vector<DemodulatorInstancePtr> getOrderedDemodulators(bool actives = true);
|
||||||
std::vector<DemodulatorInstancePtr> getDemodulatorsAt(long long freq, int bandwidth);
|
std::vector<DemodulatorInstancePtr> getDemodulatorsAt(long long freq, int bandwidth);
|
||||||
|
|
||||||
DemodulatorInstancePtr getPreviousDemodulator(DemodulatorInstancePtr demod, bool actives = true);
|
DemodulatorInstancePtr getPreviousDemodulator(const DemodulatorInstancePtr& demod, bool actives = true);
|
||||||
DemodulatorInstancePtr getNextDemodulator(DemodulatorInstancePtr demod, bool actives = true);
|
DemodulatorInstancePtr getNextDemodulator(const DemodulatorInstancePtr& demod, bool actives = true);
|
||||||
DemodulatorInstancePtr getLastDemodulator();
|
DemodulatorInstancePtr getLastDemodulator();
|
||||||
DemodulatorInstancePtr getFirstDemodulator();
|
DemodulatorInstancePtr getFirstDemodulator();
|
||||||
bool anyDemodulatorsAt(long long freq, int bandwidth);
|
bool anyDemodulatorsAt(long long freq, int bandwidth);
|
||||||
void deleteThread(DemodulatorInstancePtr);
|
void deleteThread(const DemodulatorInstancePtr&);
|
||||||
|
|
||||||
void terminateAll();
|
void terminateAll();
|
||||||
|
|
||||||
void setActiveDemodulator(DemodulatorInstancePtr demod, bool temporary = true);
|
void setActiveDemodulator(const DemodulatorInstancePtr& demod, bool temporary = true);
|
||||||
|
|
||||||
//Dangerous: this is only intended by some internal classes,
|
//Dangerous: this is only intended by some internal classes,
|
||||||
// and only set a pre-existing demod
|
// and only set a pre-existing demod
|
||||||
@ -47,34 +47,34 @@ public:
|
|||||||
int bandwidth);
|
int bandwidth);
|
||||||
|
|
||||||
int getLastBandwidth() const;
|
int getLastBandwidth() const;
|
||||||
void setLastBandwidth(int lastBandwidth);
|
void setLastBandwidth(int lastBandwidth_in);
|
||||||
|
|
||||||
std::string getLastDemodulatorType() const;
|
std::string getLastDemodulatorType() const;
|
||||||
void setLastDemodulatorType(std::string lastDemodType);
|
void setLastDemodulatorType(std::string lastDemodType_in);
|
||||||
|
|
||||||
float getLastGain() const;
|
float getLastGain() const;
|
||||||
void setLastGain(float lastGain);
|
void setLastGain(float lastGain_in);
|
||||||
|
|
||||||
bool getLastDeltaLock() const;
|
bool getLastDeltaLock() const;
|
||||||
void setLastDeltaLock(bool lock);
|
void setLastDeltaLock(bool lock);
|
||||||
|
|
||||||
float getLastSquelchLevel() const;
|
float getLastSquelchLevel() const;
|
||||||
void setLastSquelchLevel(float lastSquelch);
|
void setLastSquelchLevel(float lastSquelch_in);
|
||||||
|
|
||||||
bool isLastSquelchEnabled() const;
|
bool isLastSquelchEnabled() const;
|
||||||
void setLastSquelchEnabled(bool lastSquelchEnabled);
|
void setLastSquelchEnabled(bool lastSquelchEnabled_in);
|
||||||
|
|
||||||
bool isLastMuted() const;
|
bool isLastMuted() const;
|
||||||
void setLastMuted(bool lastMuted);
|
void setLastMuted(bool lastMuted_in);
|
||||||
|
|
||||||
ModemSettings getLastModemSettings(std::string);
|
ModemSettings getLastModemSettings(const std::string&);
|
||||||
void setLastModemSettings(std::string, ModemSettings);
|
void setLastModemSettings(const std::string&, ModemSettings);
|
||||||
|
|
||||||
void updateLastState();
|
void updateLastState();
|
||||||
|
|
||||||
void setOutputDevices(std::map<int,RtAudio::DeviceInfo> devs);
|
void setOutputDevices(std::map<int,RtAudio::DeviceInfo> devs);
|
||||||
std::map<int, RtAudio::DeviceInfo> getOutputDevices();
|
std::map<int, RtAudio::DeviceInfo> getOutputDevices();
|
||||||
void saveInstance(DataNode *node, DemodulatorInstancePtr inst);
|
void saveInstance(DataNode *node, const DemodulatorInstancePtr& inst);
|
||||||
|
|
||||||
DemodulatorInstancePtr loadInstance(DataNode *node);
|
DemodulatorInstancePtr loadInstance(DataNode *node);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) Charles J. Cliffe
|
// Copyright (c) Charles J. Cliffe
|
||||||
// SPDX-License-Identifier: GPL-2.0+
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
#include "CubicSDRDefs.h"
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -15,7 +14,7 @@
|
|||||||
//50 ms
|
//50 ms
|
||||||
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
|
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
|
||||||
|
|
||||||
DemodulatorPreThread::DemodulatorPreThread(DemodulatorInstance* parent) : IOThread(), iqResampler(NULL), iqResampleRatio(1), cModem(nullptr), cModemKit(nullptr)
|
DemodulatorPreThread::DemodulatorPreThread(DemodulatorInstance* parent) : IOThread(), iqResampler(nullptr), iqResampleRatio(1), cModem(nullptr), cModemKit(nullptr)
|
||||||
{
|
{
|
||||||
initialized.store(false);
|
initialized.store(false);
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
@ -50,8 +49,7 @@ bool DemodulatorPreThread::isInitialized() {
|
|||||||
return initialized.load();
|
return initialized.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorPreThread::~DemodulatorPreThread() {
|
DemodulatorPreThread::~DemodulatorPreThread() = default;
|
||||||
}
|
|
||||||
|
|
||||||
void DemodulatorPreThread::run() {
|
void DemodulatorPreThread::run() {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -98,8 +96,7 @@ void DemodulatorPreThread::run() {
|
|||||||
audioSampleRateChanged.store(true);
|
audioSampleRateChanged.store(true);
|
||||||
}
|
}
|
||||||
} else if (parent->getAudioSampleRate() != newAudioSampleRate) {
|
} else if (parent->getAudioSampleRate() != newAudioSampleRate) {
|
||||||
int newRate;
|
if (parent->getAudioSampleRate()) {
|
||||||
if ((newRate = parent->getAudioSampleRate())) {
|
|
||||||
newAudioSampleRate = parent->getAudioSampleRate();
|
newAudioSampleRate = parent->getAudioSampleRate();
|
||||||
audioSampleRateChanged.store(true);
|
audioSampleRateChanged.store(true);
|
||||||
}
|
}
|
||||||
@ -116,9 +113,9 @@ void DemodulatorPreThread::run() {
|
|||||||
sampleRateChanged.store(false);
|
sampleRateChanged.store(false);
|
||||||
audioSampleRateChanged.store(false);
|
audioSampleRateChanged.store(false);
|
||||||
ModemSettings lastSettings = parent->getLastModemSettings(newDemodType);
|
ModemSettings lastSettings = parent->getLastModemSettings(newDemodType);
|
||||||
if (lastSettings.size() != 0) {
|
if (!lastSettings.empty()) {
|
||||||
command.settings = lastSettings;
|
command.settings = lastSettings;
|
||||||
if (modemSettingsBuffered.size()) {
|
if (!modemSettingsBuffered.empty()) {
|
||||||
for (ModemSettings::const_iterator msi = modemSettingsBuffered.begin(); msi != modemSettingsBuffered.end(); msi++) {
|
for (ModemSettings::const_iterator msi = modemSettingsBuffered.begin(); msi != modemSettingsBuffered.end(); msi++) {
|
||||||
command.settings[msi->first] = msi->second;
|
command.settings[msi->first] = msi->second;
|
||||||
}
|
}
|
||||||
@ -168,7 +165,7 @@ void DemodulatorPreThread::run() {
|
|||||||
|
|
||||||
// std::lock_guard < std::mutex > lock(inp->m_mutex);
|
// std::lock_guard < std::mutex > lock(inp->m_mutex);
|
||||||
std::vector<liquid_float_complex> *data = &inp->data;
|
std::vector<liquid_float_complex> *data = &inp->data;
|
||||||
if (data->size() && (inp->sampleRate == currentSampleRate) && cModem && cModemKit) {
|
if (!data->empty() && (inp->sampleRate == currentSampleRate) && cModem && cModemKit) {
|
||||||
size_t bufSize = data->size();
|
size_t bufSize = data->size();
|
||||||
|
|
||||||
if (in_buf_data.size() != bufSize) {
|
if (in_buf_data.size() != bufSize) {
|
||||||
@ -184,7 +181,7 @@ void DemodulatorPreThread::run() {
|
|||||||
|
|
||||||
liquid_float_complex *in_buf = &in_buf_data[0];
|
liquid_float_complex *in_buf = &in_buf_data[0];
|
||||||
liquid_float_complex *out_buf = &out_buf_data[0];
|
liquid_float_complex *out_buf = &out_buf_data[0];
|
||||||
liquid_float_complex *temp_buf = NULL;
|
liquid_float_complex *temp_buf;
|
||||||
|
|
||||||
if (shiftFrequency != 0) {
|
if (shiftFrequency != 0) {
|
||||||
if (shiftFrequency < 0) {
|
if (shiftFrequency < 0) {
|
||||||
@ -241,7 +238,7 @@ void DemodulatorPreThread::run() {
|
|||||||
cModem = result.modem;
|
cModem = result.modem;
|
||||||
#if ENABLE_DIGITAL_LAB
|
#if ENABLE_DIGITAL_LAB
|
||||||
if (cModem->getType() == "digital") {
|
if (cModem->getType() == "digital") {
|
||||||
ModemDigital *mDigi = (ModemDigital *)cModem;
|
auto *mDigi = (ModemDigital *)cModem;
|
||||||
mDigi->setOutput(parent->getOutput());
|
mDigi->setOutput(parent->getOutput());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -260,7 +257,7 @@ void DemodulatorPreThread::run() {
|
|||||||
currentSampleRate = result.sampleRate;
|
currentSampleRate = result.sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.modemName != "") {
|
if (!result.modemName.empty()) {
|
||||||
demodType = result.modemName;
|
demodType = result.modemName;
|
||||||
demodTypeChanged.store(false);
|
demodTypeChanged.store(false);
|
||||||
}
|
}
|
||||||
@ -285,8 +282,8 @@ void DemodulatorPreThread::run() {
|
|||||||
iqInputQueue->flush();
|
iqInputQueue->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorPreThread::setDemodType(std::string demodType) {
|
void DemodulatorPreThread::setDemodType(std::string demodType_in) {
|
||||||
newDemodType = demodType;
|
newDemodType = demodType_in;
|
||||||
demodTypeChanged.store(true);
|
demodTypeChanged.store(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +374,7 @@ ModemKit *DemodulatorPreThread::getModemKit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string DemodulatorPreThread::readModemSetting(std::string setting) {
|
std::string DemodulatorPreThread::readModemSetting(const std::string& setting) {
|
||||||
if (cModem) {
|
if (cModem) {
|
||||||
return cModem->readSetting(setting);
|
return cModem->readSetting(setting);
|
||||||
} else if (modemSettingsBuffered.find(setting) != modemSettingsBuffered.end()) {
|
} else if (modemSettingsBuffered.find(setting) != modemSettingsBuffered.end()) {
|
||||||
@ -386,7 +383,7 @@ std::string DemodulatorPreThread::readModemSetting(std::string setting) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorPreThread::writeModemSetting(std::string setting, std::string value) {
|
void DemodulatorPreThread::writeModemSetting(const std::string& setting, std::string value) {
|
||||||
modemSettingsBuffered[setting] = value;
|
modemSettingsBuffered[setting] = value;
|
||||||
modemSettingsChanged.store(true);
|
modemSettingsChanged.store(true);
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@ class DemodulatorInstance;
|
|||||||
class DemodulatorPreThread : public IOThread {
|
class DemodulatorPreThread : public IOThread {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DemodulatorPreThread(DemodulatorInstance* parent);
|
explicit DemodulatorPreThread(DemodulatorInstance* parent);
|
||||||
virtual ~DemodulatorPreThread();
|
~DemodulatorPreThread() override;
|
||||||
|
|
||||||
virtual void run();
|
void run() override;
|
||||||
|
|
||||||
void setDemodType(std::string demodType);
|
void setDemodType(std::string demodType_in);
|
||||||
std::string getDemodType();
|
std::string getDemodType();
|
||||||
|
|
||||||
void setFrequency(long long sampleRate);
|
void setFrequency(long long sampleRate);
|
||||||
@ -39,13 +39,13 @@ public:
|
|||||||
|
|
||||||
bool isInitialized();
|
bool isInitialized();
|
||||||
|
|
||||||
virtual void terminate();
|
void terminate() override;
|
||||||
|
|
||||||
Modem *getModem();
|
Modem *getModem();
|
||||||
ModemKit *getModemKit();
|
ModemKit *getModemKit();
|
||||||
|
|
||||||
std::string readModemSetting(std::string setting);
|
std::string readModemSetting(const std::string& setting);
|
||||||
void writeModemSetting(std::string setting, std::string value);
|
void writeModemSetting(const std::string& setting, std::string value);
|
||||||
ModemSettings readModemSettings();
|
ModemSettings readModemSettings();
|
||||||
void writeModemSettings(ModemSettings settings);
|
void writeModemSettings(ModemSettings settings);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) Charles J. Cliffe
|
// Copyright (c) Charles J. Cliffe
|
||||||
// SPDX-License-Identifier: GPL-2.0+
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
#include "CubicSDRDefs.h"
|
|
||||||
#include "DemodulatorThread.h"
|
#include "DemodulatorThread.h"
|
||||||
#include "DemodulatorInstance.h"
|
#include "DemodulatorInstance.h"
|
||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
@ -148,7 +147,7 @@ void DemodulatorThread::run() {
|
|||||||
double currentSignalLevel = 0;
|
double currentSignalLevel = 0;
|
||||||
double sampleTime = double(inp->data.size()) / double(inp->sampleRate);
|
double sampleTime = double(inp->data.size()) / double(inp->sampleRate);
|
||||||
|
|
||||||
if (audioOutputQueue != nullptr && ati && ati->data.size()) {
|
if (audioOutputQueue != nullptr && ati && !ati->data.empty()) {
|
||||||
double accum = 0;
|
double accum = 0;
|
||||||
|
|
||||||
if (cModem->useSignalOutput()) {
|
if (cModem->useSignalOutput()) {
|
||||||
@ -389,8 +388,8 @@ bool DemodulatorThread::isMuted() {
|
|||||||
return muted.load();
|
return muted.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemodulatorThread::setMuted(bool muted) {
|
void DemodulatorThread::setMuted(bool muted_in) {
|
||||||
this->muted.store(muted);
|
muted.store(muted_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
float DemodulatorThread::getSignalLevel() {
|
float DemodulatorThread::getSignalLevel() {
|
||||||
|
@ -21,15 +21,15 @@ class DemodulatorInstance;
|
|||||||
class DemodulatorThread : public IOThread {
|
class DemodulatorThread : public IOThread {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DemodulatorThread(DemodulatorInstance* parent);
|
explicit DemodulatorThread(DemodulatorInstance* parent);
|
||||||
virtual ~DemodulatorThread();
|
~DemodulatorThread() override;
|
||||||
|
|
||||||
void onBindOutput(std::string name, ThreadQueueBasePtr threadQueue);
|
void onBindOutput(std::string name, ThreadQueueBasePtr threadQueue) override;
|
||||||
|
|
||||||
virtual void run();
|
void run() override;
|
||||||
virtual void terminate();
|
void terminate() override;
|
||||||
|
|
||||||
void setMuted(bool state);
|
void setMuted(bool muted_in);
|
||||||
bool isMuted();
|
bool isMuted();
|
||||||
|
|
||||||
float getSignalLevel();
|
float getSignalLevel();
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0+
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
|
||||||
#include "DemodulatorWorkerThread.h"
|
#include "DemodulatorWorkerThread.h"
|
||||||
#include "CubicSDRDefs.h"
|
|
||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
//50 ms
|
//50 ms
|
||||||
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
|
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
|
||||||
@ -13,8 +11,7 @@ DemodulatorWorkerThread::DemodulatorWorkerThread() : IOThread(),
|
|||||||
cModem(nullptr), cModemKit(nullptr) {
|
cModem(nullptr), cModemKit(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorWorkerThread::~DemodulatorWorkerThread() {
|
DemodulatorWorkerThread::~DemodulatorWorkerThread() = default;
|
||||||
}
|
|
||||||
|
|
||||||
void DemodulatorWorkerThread::run() {
|
void DemodulatorWorkerThread::run() {
|
||||||
|
|
||||||
@ -66,7 +63,7 @@ void DemodulatorWorkerThread::run() {
|
|||||||
cModem = Modem::makeModem(demodCommand.demodType);
|
cModem = Modem::makeModem(demodCommand.demodType);
|
||||||
cModemName = cModem->getName();
|
cModemName = cModem->getName();
|
||||||
cModemType = cModem->getType();
|
cModemType = cModem->getType();
|
||||||
if (demodCommand.settings.size()) {
|
if (!demodCommand.settings.empty()) {
|
||||||
cModem->writeSettings(demodCommand.settings);
|
cModem->writeSettings(demodCommand.settings);
|
||||||
}
|
}
|
||||||
result.sampleRate = demodCommand.sampleRate;
|
result.sampleRate = demodCommand.sampleRate;
|
||||||
|
@ -19,11 +19,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
DemodulatorWorkerThreadResult() :
|
DemodulatorWorkerThreadResult() :
|
||||||
cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr), modemType("") {
|
cmd(DEMOD_WORKER_THREAD_RESULT_NULL), iqResampler(nullptr), iqResampleRatio(0), sampleRate(0), bandwidth(0), modemKit(nullptr) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorWorkerThreadResult(DemodulatorThreadResultEnum cmd) :
|
explicit DemodulatorWorkerThreadResult(DemodulatorThreadResultEnum cmd) :
|
||||||
DemodulatorWorkerThreadResult() {
|
DemodulatorWorkerThreadResult() {
|
||||||
this->cmd = cmd;
|
this->cmd = cmd;
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ public:
|
|||||||
|
|
||||||
long long sampleRate;
|
long long sampleRate;
|
||||||
unsigned int bandwidth;
|
unsigned int bandwidth;
|
||||||
Modem *modem;
|
Modem *modem{};
|
||||||
ModemKit *modemKit;
|
ModemKit *modemKit;
|
||||||
std::string modemType;
|
std::string modemType;
|
||||||
std::string modemName;
|
std::string modemName;
|
||||||
@ -48,12 +48,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
DemodulatorWorkerThreadCommand() :
|
DemodulatorWorkerThreadCommand() :
|
||||||
cmd(DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0), demodType("") {
|
cmd(DEMOD_WORKER_THREAD_CMD_NULL), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorWorkerThreadCommand(DemodulatorThreadCommandEnum cmd) :
|
explicit DemodulatorWorkerThreadCommand(DemodulatorThreadCommandEnum cmd) :
|
||||||
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0), demodType("") {
|
cmd(cmd), frequency(0), sampleRate(0), bandwidth(0), audioSampleRate(0) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +77,9 @@ class DemodulatorWorkerThread : public IOThread {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
DemodulatorWorkerThread();
|
DemodulatorWorkerThread();
|
||||||
virtual ~DemodulatorWorkerThread();
|
~DemodulatorWorkerThread() override;
|
||||||
|
|
||||||
virtual void run();
|
void run() override;
|
||||||
|
|
||||||
void setCommandQueue(DemodulatorThreadWorkerCommandQueuePtr tQueue) {
|
void setCommandQueue(DemodulatorThreadWorkerCommandQueuePtr tQueue) {
|
||||||
commandQueue = tQueue;
|
commandQueue = tQueue;
|
||||||
@ -89,7 +89,7 @@ public:
|
|||||||
resultQueue = tQueue;
|
resultQueue = tQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void terminate();
|
void terminate() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user