Safer calls to setGainMode

Will call hasGainMode first - this will prevent crashes when the underlying
device situationally doesn't support setGainMode calls.
This commit is contained in:
Jake Drahos 2019-01-13 21:53:37 -06:00
parent b0505b0659
commit 4ca6e8dba9

View File

@ -130,8 +130,10 @@ bool SDRThread::init() {
} else { } else {
hasHardwareDC.store(false); hasHardwareDC.store(false);
} }
device->setGainMode(SOAPY_SDR_RX,0,agc_mode.load()); if (device->hasGainMode(SOAPY_SDR_RX, 0)) {
device->setGainMode(SOAPY_SDR_RX, 0, agc_mode.load());
}
numChannels.store(getOptimalChannelCount(sampleRate.load())); numChannels.store(getOptimalChannelCount(sampleRate.load()));
numElems.store(getOptimalElementCount(sampleRate.load(), TARGET_DISPLAY_FPS)); numElems.store(getOptimalElementCount(sampleRate.load(), TARGET_DISPLAY_FPS));
@ -484,7 +486,9 @@ void SDRThread::updateSettings() {
// } // }
if (agc_mode_changed.load()) { if (agc_mode_changed.load()) {
device->setGainMode(SOAPY_SDR_RX, 0, agc_mode.load()); if (device->hasGainMode(SOAPY_SDR_RX, 0)) {
device->setGainMode(SOAPY_SDR_RX, 0, agc_mode.load());
}
agc_mode_changed.store(false); agc_mode_changed.store(false);
if (!agc_mode.load()) { if (!agc_mode.load()) {
updateGains(); updateGains();