From 13139c7dbf8fdfbeca0fd8cab79de01ac91a9309 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 20 Jul 2015 18:39:45 -0400 Subject: [PATCH 1/6] Add configuration name at command line via -c or --config sets up framework for more command line options as well. --- src/AppConfig.cpp | 35 ++++++++++++++++++++++++++--------- src/AppConfig.h | 3 +++ src/CubicSDR.cpp | 20 ++++++++++++++++++-- src/CubicSDR.h | 12 ++++++++++++ 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/AppConfig.cpp b/src/AppConfig.cpp index 9b057ee..9ef00b5 100644 --- a/src/AppConfig.cpp +++ b/src/AppConfig.cpp @@ -114,7 +114,7 @@ void DeviceConfig::load(DataNode *node) { busy_lock.unlock(); } -AppConfig::AppConfig() { +AppConfig::AppConfig() : configName("") { winX.store(0); winY.store(0); winW.store(0); @@ -195,6 +195,27 @@ long long AppConfig::getSnap() { return snap.load(); } +void AppConfig::setConfigName(std::string configName) { + this->configName = configName; +} + +std::string AppConfig::getConfigFileName() { + std::string cfgFileDir = getConfigDir(); + + wxFileName cfgFile; + if (configName.length()) { + std::string tempFn("config-"); + tempFn.append(configName); + tempFn.append(".xml"); + cfgFile = wxFileName(cfgFileDir, tempFn); + } else { + cfgFile = wxFileName(cfgFileDir, "config.xml"); + } + + std::string cfgFileName = cfgFile.GetFullPath(wxPATH_NATIVE).ToStdString(); + + return cfgFileName; +} bool AppConfig::save() { DataTree cfg; @@ -221,13 +242,9 @@ bool AppConfig::save() { DataNode *device_node = devices_node->newChild("device"); device_config_i->second->save(device_node); } - - std::string cfgFileDir = getConfigDir(); - - wxFileName cfgFile = wxFileName(cfgFileDir, "config.xml"); - std::string cfgFileName = cfgFile.GetFullPath(wxPATH_NATIVE).ToStdString(); - + std::string cfgFileName = getConfigFileName(); + if (!cfg.SaveToFileXML(cfgFileName)) { std::cout << "Error saving :: configuration file '" << cfgFileName << "' is not writable!" << std::endl; return false; @@ -240,8 +257,8 @@ bool AppConfig::load() { DataTree cfg; std::string cfgFileDir = getConfigDir(); - wxFileName cfgFile = wxFileName(cfgFileDir, "config.xml"); - std::string cfgFileName = cfgFile.GetFullPath(wxPATH_NATIVE).ToStdString(); + std::string cfgFileName = getConfigFileName(); + wxFileName cfgFile = wxFileName(cfgFileName); if (!cfgFile.Exists()) { return true; diff --git a/src/AppConfig.h b/src/AppConfig.h index 9d13f49..2b12f31 100644 --- a/src/AppConfig.h +++ b/src/AppConfig.h @@ -59,11 +59,14 @@ public: void setSnap(long long snapVal); long long getSnap(); + void setConfigName(std::string configName); + std::string getConfigFileName(); bool save(); bool load(); bool reset(); private: + std::string configName; std::map deviceConfig; std::atomic_int winX,winY,winW,winH; std::atomic_bool winMax; diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index 1fa1e54..1b88058 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -40,8 +40,6 @@ bool CubicSDR::OnInit() { wxApp::SetAppName("CubicSDR"); - config.load(); - frequency = DEFAULT_FREQ; offset = 0; ppm = 0; @@ -171,6 +169,24 @@ PrimaryGLContext& CubicSDR::GetContext(wxGLCanvas *canvas) { return *glContext; } +void CubicSDR::OnInitCmdLine(wxCmdLineParser& parser) { + parser.SetDesc (commandLineInfo); + parser.SetSwitchChars (wxT("-")); +} + +bool CubicSDR::OnCmdLineParsed(wxCmdLineParser& parser) { + wxString *confName = new wxString; + if (parser.Found("c",confName)) { + if (confName) { + config.setConfigName(confName->ToStdString()); + } + } + + config.load(); + + return true; +} + void CubicSDR::setFrequency(long long freq) { if (freq < sampleRate / 2) { freq = sampleRate / 2; diff --git a/src/CubicSDR.h b/src/CubicSDR.h index fb9027b..909c65b 100644 --- a/src/CubicSDR.h +++ b/src/CubicSDR.h @@ -17,6 +17,8 @@ #include "AppConfig.h" #include "AppFrame.h" +#include + #define NUM_DEMODULATORS 1 class CubicSDR: public wxApp { @@ -31,6 +33,9 @@ public: virtual bool OnInit(); virtual int OnExit(); + virtual void OnInitCmdLine(wxCmdLineParser& parser); + virtual bool OnCmdLineParsed(wxCmdLineParser& parser); + void setFrequency(long long freq); long long getFrequency(); @@ -94,4 +99,11 @@ private: std::thread *t_PostSDR; }; +static const wxCmdLineEntryDesc commandLineInfo [] = +{ + { wxCMD_LINE_SWITCH, "h", "help", "Command line parameter help", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, + { wxCMD_LINE_OPTION, "c", "config", "Specify a named configuration to use, i.e. '-c ham'" }, + { wxCMD_LINE_NONE } +}; + DECLARE_APP(CubicSDR) From ddedc984b0af743e5408fe242868775030851231 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 20 Jul 2015 22:09:36 -0400 Subject: [PATCH 2/6] Duplicate default config to new config files --- src/AppConfig.cpp | 22 +++++++++++++++++++--- src/AppConfig.h | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/AppConfig.cpp b/src/AppConfig.cpp index 9ef00b5..4571527 100644 --- a/src/AppConfig.cpp +++ b/src/AppConfig.cpp @@ -199,11 +199,11 @@ void AppConfig::setConfigName(std::string configName) { this->configName = configName; } -std::string AppConfig::getConfigFileName() { +std::string AppConfig::getConfigFileName(bool ignoreName) { std::string cfgFileDir = getConfigDir(); wxFileName cfgFile; - if (configName.length()) { + if (configName.length() && !ignoreName) { std::string tempFn("config-"); tempFn.append(configName); tempFn.append(".xml"); @@ -261,7 +261,23 @@ bool AppConfig::load() { wxFileName cfgFile = wxFileName(cfgFileName); if (!cfgFile.Exists()) { - return true; + if (configName.length()) { + wxFileName baseConfig = wxFileName(getConfigFileName(true)); + if (baseConfig.Exists()) { + std::string baseConfigFileName = baseConfig.GetFullPath(wxPATH_NATIVE).ToStdString(); + std::cout << "Creating new configuration file '" << cfgFileName << "' by copying '" << baseConfigFileName << "'.."; + wxCopyFile(baseConfigFileName, cfgFileName); + if (!cfgFile.Exists()) { + std::cout << "failed." << std::endl; + return true; + } + std::cout << "ok." << std::endl; + } else { + return true; + } + } else { + return true; + } } if (cfgFile.IsFileReadable()) { diff --git a/src/AppConfig.h b/src/AppConfig.h index 2b12f31..bcdfa01 100644 --- a/src/AppConfig.h +++ b/src/AppConfig.h @@ -60,7 +60,7 @@ public: long long getSnap(); void setConfigName(std::string configName); - std::string getConfigFileName(); + std::string getConfigFileName(bool ignoreName=false); bool save(); bool load(); bool reset(); From 9843f85086930b9d938622c39770dc7ebe1b7b93 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 20 Jul 2015 22:51:19 -0400 Subject: [PATCH 3/6] Save center frequency --- src/AppConfig.cpp | 18 +++++++++++++++++- src/AppConfig.h | 4 ++++ src/AppFrame.cpp | 2 ++ src/sdr/SDRThread.cpp | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/AppConfig.cpp b/src/AppConfig.cpp index 4571527..c50fe14 100644 --- a/src/AppConfig.cpp +++ b/src/AppConfig.cpp @@ -122,6 +122,7 @@ AppConfig::AppConfig() : configName("") { winMax.store(false); themeId.store(0); snap.store(1); + centerFreq.store(100000000); } @@ -195,6 +196,14 @@ long long AppConfig::getSnap() { return snap.load(); } +void AppConfig::setCenterFreq(long long freqVal) { + centerFreq.store(freqVal); +} + +long long AppConfig::getCenterFreq() { + return centerFreq.load(); +} + void AppConfig::setConfigName(std::string configName) { this->configName = configName; } @@ -233,6 +242,7 @@ bool AppConfig::save() { *window_node->newChild("max") = winMax.load(); *window_node->newChild("theme") = themeId.load(); *window_node->newChild("snap") = snap.load(); + *window_node->newChild("center_freq") = centerFreq.load(); } DataNode *devices_node = cfg.rootNode()->newChild("devices"); @@ -323,7 +333,13 @@ bool AppConfig::load() { win_node->getNext("snap")->element()->get(snapVal); snap.store(snapVal); } - } + + if (win_node->hasAnother("center_freq")) { + long long freqVal; + win_node->getNext("center_freq")->element()->get(freqVal); + centerFreq.store(freqVal); + } +} if (cfg.rootNode()->hasAnother("devices")) { DataNode *devices_node = cfg.rootNode()->getNext("devices"); diff --git a/src/AppConfig.h b/src/AppConfig.h index bcdfa01..10f1774 100644 --- a/src/AppConfig.h +++ b/src/AppConfig.h @@ -58,6 +58,9 @@ public: void setSnap(long long snapVal); long long getSnap(); + + void setCenterFreq(long long freqVal); + long long getCenterFreq(); void setConfigName(std::string configName); std::string getConfigFileName(bool ignoreName=false); @@ -72,4 +75,5 @@ private: std::atomic_bool winMax; std::atomic_int themeId; std::atomic_llong snap; + std::atomic_llong centerFreq; }; diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 10643f6..723837f 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -324,6 +324,8 @@ AppFrame::AppFrame() : wxGetApp().setFrequencySnap(freqSnap); ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme()); + + wxGetApp().setFrequency(wxGetApp().getConfig()->getCenterFreq()); Show(); diff --git a/src/sdr/SDRThread.cpp b/src/sdr/SDRThread.cpp index 0d8a1bd..ebfb0aa 100644 --- a/src/sdr/SDRThread.cpp +++ b/src/sdr/SDRThread.cpp @@ -141,7 +141,7 @@ void SDRThread::threadMain() { signed char buf[BUF_SIZE]; - long long frequency = DEFAULT_FREQ; + long long frequency = wxGetApp().getConfig()->getCenterFreq(); int ppm = devConfig->getPPM(); int direct_sampling_mode = devConfig->getDirectSampling();; int buf_size = BUF_SIZE; From 2b86176625ed2f21878a4576241bc76c3b1707e1 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 21 Jul 2015 00:04:04 -0400 Subject: [PATCH 4/6] fix for center freq. save/load --- src/AppFrame.cpp | 11 +++++------ src/CubicSDR.cpp | 2 +- src/CubicSDR.h | 2 +- src/CubicSDRDefs.h | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 723837f..698392a 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -66,14 +66,14 @@ AppFrame::AppFrame() : demodSpectrumCanvas = new SpectrumCanvas(this, attribList); demodSpectrumCanvas->setup(1024); - demodSpectrumCanvas->setView(DEFAULT_FREQ, 300000); + demodSpectrumCanvas->setView(wxGetApp().getConfig()->getCenterFreq(), 300000); demodVisuals->Add(demodSpectrumCanvas, 3, wxEXPAND | wxALL, 0); demodVisuals->AddSpacer(1); demodWaterfallCanvas = new WaterfallCanvas(this, attribList); demodWaterfallCanvas->setup(1024, 128); - demodWaterfallCanvas->setView(DEFAULT_FREQ, 300000); + demodWaterfallCanvas->setView(wxGetApp().getConfig()->getCenterFreq(), 300000); demodWaterfallCanvas->attachSpectrumCanvas(demodSpectrumCanvas); demodSpectrumCanvas->attachWaterfallCanvas(demodWaterfallCanvas); demodVisuals->Add(demodWaterfallCanvas, 6, wxEXPAND | wxALL, 0); @@ -324,15 +324,13 @@ AppFrame::AppFrame() : wxGetApp().setFrequencySnap(freqSnap); ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme()); - - wxGetApp().setFrequency(wxGetApp().getConfig()->getCenterFreq()); Show(); #ifdef _WIN32 SetIcon(wxICON(frame_icon)); #endif - GetStatusBar()->SetStatusText(wxString::Format(wxT("Set center frequency: %i"), DEFAULT_FREQ)); + GetStatusBar()->SetStatusText(wxString::Format(wxT("Set center frequency: %i"), wxGetApp().getConfig()->getCenterFreq())); wxAcceleratorEntry entries[3]; entries[0].Set(wxACCEL_CTRL, (int) 'O', wxID_OPEN); @@ -423,7 +421,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) { saveSession(saveFileDialog.GetPath().ToStdString()); } else if (event.GetId() == wxID_RESET) { wxGetApp().getDemodMgr().terminateAll(); - wxGetApp().setFrequency(DEFAULT_FREQ); + wxGetApp().setFrequency(100000000); wxGetApp().setOffset(0); SetTitle(CUBICSDR_TITLE); currentSessionFile = ""; @@ -539,6 +537,7 @@ void AppFrame::OnClose(wxCloseEvent& event) { wxGetApp().getConfig()->setWindowMaximized(this->IsMaximized()); wxGetApp().getConfig()->setTheme(ThemeMgr::mgr.getTheme()); wxGetApp().getConfig()->setSnap(wxGetApp().getFrequencySnap()); + wxGetApp().getConfig()->setCenterFreq(wxGetApp().getFrequency()); wxGetApp().getConfig()->save(); event.Skip(); } diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index 1b88058..2c8c2cb 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -40,7 +40,7 @@ bool CubicSDR::OnInit() { wxApp::SetAppName("CubicSDR"); - frequency = DEFAULT_FREQ; + frequency = wxGetApp().getConfig()->getCenterFreq(); offset = 0; ppm = 0; directSamplingMode = 0; diff --git a/src/CubicSDR.h b/src/CubicSDR.h index 909c65b..174318d 100644 --- a/src/CubicSDR.h +++ b/src/CubicSDR.h @@ -24,7 +24,7 @@ class CubicSDR: public wxApp { public: CubicSDR() : - appframe(NULL), m_glContext(NULL), frequency(DEFAULT_FREQ), sdrThread(NULL), sdrPostThread(NULL), threadCmdQueueSDR(NULL), iqVisualQueue(NULL), iqPostDataQueue(NULL), audioVisualQueue(NULL), t_SDR(NULL), t_PostSDR(NULL), sampleRate(DEFAULT_SAMPLE_RATE), offset(0), snap(1), directSamplingMode(0), ppm(0) { + appframe(NULL), m_glContext(NULL), frequency(0), sdrThread(NULL), sdrPostThread(NULL), threadCmdQueueSDR(NULL), iqVisualQueue(NULL), iqPostDataQueue(NULL), audioVisualQueue(NULL), t_SDR(NULL), t_PostSDR(NULL), sampleRate(DEFAULT_SAMPLE_RATE), offset(0), snap(1), directSamplingMode(0), ppm(0) { } diff --git a/src/CubicSDRDefs.h b/src/CubicSDRDefs.h index 2656f85..2b6de43 100644 --- a/src/CubicSDRDefs.h +++ b/src/CubicSDRDefs.h @@ -30,7 +30,6 @@ const char filePathSeparator = #define DEFAULT_SAMPLE_RATE 2400000 #define DEFAULT_FFT_SIZE 2048 -#define DEFAULT_FREQ 100000000 #define DEFAULT_DEMOD_TYPE 1 #define DEFAULT_DEMOD_BW 200000 From 6eee444e1db2d258b5020f740480c0cbe73b57fd Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 21 Jul 2015 00:16:08 -0400 Subject: [PATCH 5/6] Fix wxT format specifier --- src/AppFrame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 698392a..88f29a4 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -330,7 +330,7 @@ AppFrame::AppFrame() : #ifdef _WIN32 SetIcon(wxICON(frame_icon)); #endif - GetStatusBar()->SetStatusText(wxString::Format(wxT("Set center frequency: %i"), wxGetApp().getConfig()->getCenterFreq())); + GetStatusBar()->SetStatusText(wxString::Format(wxT("Set center frequency: %ll"), wxGetApp().getConfig()->getCenterFreq())); wxAcceleratorEntry entries[3]; entries[0].Set(wxACCEL_CTRL, (int) 'O', wxID_OPEN); From 19f9b7ab700627afe49d0f00edb441598cff8e49 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 21 Jul 2015 00:59:18 -0400 Subject: [PATCH 6/6] MSVC fixes --- src/AppFrame.cpp | 1 - src/audio/AudioThread.cpp | 9 ++++++++- src/demod/DemodulatorInstance.cpp | 18 ++++++++++++++++-- src/demod/DemodulatorPreThread.cpp | 4 +++- src/demod/DemodulatorThread.cpp | 8 ++++++-- src/demod/DemodulatorWorkerThread.cpp | 4 ++-- src/sdr/SDRPostThread.cpp | 5 ++++- src/sdr/SDRThread.cpp | 5 ++++- 8 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 88f29a4..f907b84 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -330,7 +330,6 @@ AppFrame::AppFrame() : #ifdef _WIN32 SetIcon(wxICON(frame_icon)); #endif - GetStatusBar()->SetStatusText(wxString::Format(wxT("Set center frequency: %ll"), wxGetApp().getConfig()->getCenterFreq())); wxAcceleratorEntry entries[3]; entries[0].Set(wxACCEL_CTRL, (int) 'O', wxID_OPEN); diff --git a/src/audio/AudioThread.cpp b/src/audio/AudioThread.cpp index b173123..384b28d 100644 --- a/src/audio/AudioThread.cpp +++ b/src/audio/AudioThread.cpp @@ -12,8 +12,15 @@ std::map AudioThread::deviceSampleRate; std::map AudioThread::deviceThread; AudioThread::AudioThread(AudioThreadInputQueue *inputQueue, DemodulatorThreadCommandQueue* threadQueueNotify) : - currentInput(NULL), inputQueue(inputQueue), audioQueuePtr(0), underflowCount(0), terminated(false), active(false), outputDevice(-1), gain( + currentInput(NULL), inputQueue(inputQueue), gain( 1.0), threadQueueNotify(threadQueueNotify), sampleRate(0), nBufferFrames(1024) { + + audioQueuePtr.store(0); + underflowCount.store(0); + terminated.store(false); + active.store(false); + outputDevice.store(-1); + boundThreads = new std::vector; } diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index ba58e7c..38f1bb4 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -1,8 +1,22 @@ #include "DemodulatorInstance.h" DemodulatorInstance::DemodulatorInstance() : - t_Demod(NULL), t_PreDemod(NULL), t_Audio(NULL), threadQueueDemod(NULL), demodulatorThread(NULL), terminated(true), audioTerminated(true), demodTerminated( - true), preDemodTerminated(true), active(false), squelch(false), stereo(false), tracking(false), follow(false), currentAudioSampleRate(0), currentFrequency(0), currentBandwidth(0), currentOutputDevice(-1), currentAudioGain(1.0) { + t_Demod(NULL), t_PreDemod(NULL), t_Audio(NULL), threadQueueDemod(NULL), demodulatorThread(NULL), currentAudioGain(1.0) { + + terminated.store(true); + audioTerminated.store(true); + demodTerminated.store(true); + preDemodTerminated.store(true); + active.store(false); + squelch.store(false); + stereo.store(false); + tracking.store(false); + follow.store(false); + currentAudioSampleRate.store(0); + currentFrequency.store(0); + currentBandwidth.store(0); + currentOutputDevice.store(-1); + label = new std::string("Unnamed"); threadQueueDemod = new DemodulatorThreadInputQueue; diff --git a/src/demod/DemodulatorPreThread.cpp b/src/demod/DemodulatorPreThread.cpp index 0283b86..03ea87d 100644 --- a/src/demod/DemodulatorPreThread.cpp +++ b/src/demod/DemodulatorPreThread.cpp @@ -10,9 +10,11 @@ DemodulatorPreThread::DemodulatorPreThread(DemodulatorThreadInputQueue* iqInputQueue, DemodulatorThreadPostInputQueue* iqOutputQueue, DemodulatorThreadControlCommandQueue *threadQueueControl, DemodulatorThreadCommandQueue* threadQueueNotify) : - iqInputQueue(iqInputQueue), iqOutputQueue(iqOutputQueue), terminated(false), initialized(false), audioResampler(NULL), stereoResampler(NULL), iqResampleRatio( + iqInputQueue(iqInputQueue), iqOutputQueue(iqOutputQueue), audioResampler(NULL), stereoResampler(NULL), iqResampleRatio( 1), audioResampleRatio(1), firStereoRight(NULL), firStereoLeft(NULL), iirStereoPilot(NULL), iqResampler(NULL), commandQueue(NULL), threadQueueNotify(threadQueueNotify), threadQueueControl( threadQueueControl) { + terminated.store(false); + initialized.store(false); freqShifter = nco_crcf_create(LIQUID_VCO); shiftFrequency = 0; diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index 00df8a7..86ce709 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -14,10 +14,14 @@ DemodulatorThread::DemodulatorThread(DemodulatorThreadPostInputQueue* iqInputQueue, DemodulatorThreadControlCommandQueue *threadQueueControl, DemodulatorThreadCommandQueue* threadQueueNotify) : iqInputQueue(iqInputQueue), audioVisOutputQueue(NULL), audioOutputQueue(NULL), iqAutoGain(NULL), amOutputCeil(1), amOutputCeilMA(1), amOutputCeilMAA( - 1), stereo(false), agcEnabled(true), terminated( - false), demodulatorType(DEMOD_TYPE_FM), threadQueueNotify(threadQueueNotify), threadQueueControl(threadQueueControl), squelchLevel(0), signalLevel( + 1), threadQueueNotify(threadQueueNotify), threadQueueControl(threadQueueControl), squelchLevel(0), signalLevel( 0), squelchEnabled(false), audioSampleRate(0) { + stereo.store(false); + agcEnabled.store(false); + terminated.store(false); + demodulatorType.store(DEMOD_TYPE_FM); + demodFM = freqdem_create(0.5); demodAM_USB = ampmodem_create(0.5, 0.0, LIQUID_AMPMODEM_USB, 1); demodAM_LSB = ampmodem_create(0.5, 0.0, LIQUID_AMPMODEM_LSB, 1); diff --git a/src/demod/DemodulatorWorkerThread.cpp b/src/demod/DemodulatorWorkerThread.cpp index 8725a94..a3d13cf 100644 --- a/src/demod/DemodulatorWorkerThread.cpp +++ b/src/demod/DemodulatorWorkerThread.cpp @@ -3,8 +3,8 @@ #include DemodulatorWorkerThread::DemodulatorWorkerThread(DemodulatorThreadWorkerCommandQueue* in, DemodulatorThreadWorkerResultQueue* out) : - terminated(false), commandQueue(in), resultQueue(out) { - + commandQueue(in), resultQueue(out) { + terminated.store(false); } DemodulatorWorkerThread::~DemodulatorWorkerThread() { diff --git a/src/sdr/SDRPostThread.cpp b/src/sdr/SDRPostThread.cpp index 6d94074..5a22aab 100644 --- a/src/sdr/SDRPostThread.cpp +++ b/src/sdr/SDRPostThread.cpp @@ -6,7 +6,10 @@ #include SDRPostThread::SDRPostThread() : - iqDataInQueue(NULL), iqDataOutQueue(NULL), iqVisualQueue(NULL), terminated(false), dcFilter(NULL), num_vis_samples(16384*2), swapIQ(false) { + iqDataInQueue(NULL), iqDataOutQueue(NULL), iqVisualQueue(NULL), dcFilter(NULL), num_vis_samples(16384*2) { + + terminated.store(false); + swapIQ.store(false); // create a lookup table for (unsigned int i = 0; i <= 0xffff; i++) { diff --git a/src/sdr/SDRThread.cpp b/src/sdr/SDRThread.cpp index ebfb0aa..6f1a66e 100644 --- a/src/sdr/SDRThread.cpp +++ b/src/sdr/SDRThread.cpp @@ -4,7 +4,10 @@ #include "CubicSDR.h" SDRThread::SDRThread(SDRThreadCommandQueue* pQueue) : - commandQueue(pQueue), iqDataOutQueue(NULL), terminated(false), offset(0), deviceId(-1) { + commandQueue(pQueue), iqDataOutQueue(NULL) { + terminated.store(false); + offset.store(0); + deviceId.store(-1); dev = NULL; sampleRate.store(DEFAULT_SAMPLE_RATE); }