FIX: Inactive demod bendwiths are restored to 0 from sessions, because they were erroneously saved as such.

The problem lies in DemodulatorPreThread:
- settings were actually get/set unprotected from concurrent access (bendwiths, frequencies, sample rates...etc) so make them atomic.
- If bandwith has changed, return the new value instead of the current one, just like frequencies.
This commit is contained in:
vsonnier 2017-02-18 10:48:56 +01:00
parent 4b48113936
commit 946a9801dc
3 changed files with 12 additions and 7 deletions

View File

@ -76,7 +76,7 @@ void DemodulatorPreThread::run() {
iqInputQueue->pop(inp); iqInputQueue->pop(inp);
if (frequencyChanged.load()) { if (frequencyChanged.load()) {
currentFrequency = newFrequency; currentFrequency.store(newFrequency);
frequencyChanged.store(false); frequencyChanged.store(false);
} }
@ -327,6 +327,10 @@ void DemodulatorPreThread::setBandwidth(int bandwidth) {
} }
int DemodulatorPreThread::getBandwidth() { int DemodulatorPreThread::getBandwidth() {
if (bandwidthChanged.load()) {
return newBandwidth;
}
return currentBandwidth; return currentBandwidth;
} }

View File

@ -5,6 +5,7 @@
#include <queue> #include <queue>
#include <vector> #include <vector>
#include <atomic>
#include "CubicSDRDefs.h" #include "CubicSDRDefs.h"
#include "DemodDefs.h" #include "DemodDefs.h"
@ -56,10 +57,10 @@ protected:
Modem *cModem; Modem *cModem;
ModemKit *cModemKit; ModemKit *cModemKit;
long long currentSampleRate, newSampleRate; std::atomic_llong currentSampleRate, newSampleRate;
long long currentFrequency, newFrequency; std::atomic_llong currentFrequency, newFrequency;
int currentBandwidth, newBandwidth; std::atomic_int currentBandwidth, newBandwidth;
int currentAudioSampleRate, newAudioSampleRate; std::atomic_int currentAudioSampleRate, newAudioSampleRate;
std::atomic_bool sampleRateChanged, frequencyChanged, bandwidthChanged, audioSampleRateChanged; std::atomic_bool sampleRateChanged, frequencyChanged, bandwidthChanged, audioSampleRateChanged;