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

@ -385,7 +385,7 @@ void DemodulatorMgr::setOutputDevices(std::map<int,RtAudio::DeviceInfo> devs) {
void DemodulatorMgr::saveInstance(DataNode *node, DemodulatorInstance *inst) {
*node->newChild("bandwidth") = inst->getBandwidth();
*node->newChild("frequency") = inst->getFrequency();
*node->newChild("frequency") = inst->getFrequency();
*node->newChild("type") = inst->getDemodulatorType();
node->newChild("user_label")->element()->set(inst->getDemodulatorUserLabel());

View File

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

View File

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