Remember settings when toggling modem types

- Some additional race condition fixes for showing/hiding the modem
property grid
This commit is contained in:
Charles J. Cliffe 2015-11-26 22:06:29 -05:00
parent 4fa0cb7c67
commit e68ab1e82f
4 changed files with 28 additions and 3 deletions

View File

@ -950,6 +950,8 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
demodGainMeter->setLevel(demodGainMeter->getInputValue());
}
activeDemodulator = demod;
} else if (demod) {
// Wait state for current demodulator modem to activate..
} else {
DemodulatorMgr *mgr = &wxGetApp().getDemodMgr();

View File

@ -240,6 +240,10 @@ int DemodulatorInstance::getOutputDevice() {
void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) {
setGain(getGain());
if (demodulatorPreThread) {
std::string currentDemodType = demodulatorPreThread->getDemodType();
if ((currentDemodType != "") && (currentDemodType != demod_type_in)) {
lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings();
}
demodulatorPreThread->setDemodType(demod_type_in);
}
}
@ -366,4 +370,13 @@ void DemodulatorInstance::writeModemSettings(ModemSettings settings) {
bool DemodulatorInstance::isModemInitialized() {
return demodulatorPreThread->isInitialized();
}
}
ModemSettings DemodulatorInstance::getLastModemSettings(std::string demodType) {
if (lastModemSettings.find(demodType) != lastModemSettings.end()) {
return lastModemSettings[demodType];
} else {
ModemSettings mods;
return mods;
}
}

View File

@ -89,7 +89,8 @@ public:
void writeModemSettings(ModemSettings settings);
bool isModemInitialized();
ModemSettings getLastModemSettings(std::string demodType);
protected:
DemodulatorThreadInputQueue* pipeIQInputData;
DemodulatorThreadPostInputQueue* pipeIQDemodData;
@ -113,4 +114,5 @@ private:
std::atomic_int currentOutputDevice;
std::atomic<float> currentAudioGain;
std::atomic_bool follow, tracking;
std::map<std::string, ModemSettings> lastModemSettings;
};

View File

@ -103,7 +103,15 @@ void DemodulatorPreThread::run() {
demodType = newDemodType;
sampleRateChanged.store(false);
audioSampleRateChanged.store(false);
if (modemSettingsBuffered.size()) {
ModemSettings lastSettings = parent->getLastModemSettings(newDemodType);
if (lastSettings.size() != 0) {
command.settings = lastSettings;
if (modemSettingsBuffered.size()) {
for (ModemSettings::const_iterator msi = modemSettingsBuffered.begin(); msi != modemSettingsBuffered.end(); msi++) {
command.settings[msi->first] = msi->second;
}
}
} else {
command.settings = modemSettingsBuffered;
}
modemSettingsBuffered.clear();