Static analysis related fixes

This commit is contained in:
Charles J. Cliffe 2016-03-30 19:34:36 -04:00
parent e0df7cb41d
commit f22ef685f5
6 changed files with 36 additions and 22 deletions

View File

@ -1610,7 +1610,7 @@ bool AppFrame::loadSession(std::string fileName) {
DataNode *demodTypeNode = demod->hasAnother("type")?demod->getNext("type"):nullptr;
if (demodTypeNode->element()->getDataType() == DATA_INT) {
if (demodTypeNode && demodTypeNode->element()->getDataType() == DATA_INT) {
int legacyType = *demodTypeNode;
int legacyStereo = demod->hasAnother("stereo") ? (int) *demod->getNext("stereo") : 0;
switch (legacyType) { // legacy demod ID
@ -1632,7 +1632,7 @@ bool AppFrame::loadSession(std::string fileName) {
case 16: type = "I/Q"; break;
default: type = "FM"; break;
}
} else if (demodTypeNode->element()->getDataType() == DATA_STRING) {
} else if (demodTypeNode && demodTypeNode->element()->getDataType() == DATA_STRING) {
demodTypeNode->element()->get(type);
}

View File

@ -20,11 +20,13 @@ AudioThread::AudioThread() : IOThread(),
outputDevice.store(-1);
gain.store(1.0);
boundThreads.store(new std::vector<AudioThread *>);
vBoundThreads = new std::vector<AudioThread *>;
boundThreads.store(vBoundThreads);
}
AudioThread::~AudioThread() {
delete boundThreads.load();
boundThreads.store(nullptr);
delete vBoundThreads;
}
void AudioThread::bindThread(AudioThread *other) {

View File

@ -100,5 +100,6 @@ public:
static void deviceCleanup();
static void setDeviceSampleRate(int deviceId, int sampleRate);
std::atomic<std::vector<AudioThread *> *> boundThreads;
std::vector<AudioThread *> *vBoundThreads;
};

View File

@ -137,17 +137,23 @@ bool DemodulatorInstance::isTerminated() {
switch (cmd.cmd) {
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED:
t_Audio->join();
audioTerminated = true;
delete t_Audio;
if (t_Audio) {
t_Audio->join();
audioTerminated = true;
delete t_Audio;
t_Audio = nullptr;
}
break;
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED:
#ifdef __APPLE__
pthread_join(t_Demod, NULL);
#else
t_Demod->join();
delete t_Demod;
#endif
if (t_Demod) {
#ifdef __APPLE__
pthread_join(t_Demod, nullptr);
#else
t_Demod->join();
delete t_Demod;
#endif
t_Demod = nullptr;
}
#if ENABLE_DIGITAL_LAB
if (activeOutput) {
closeOutput();
@ -156,13 +162,16 @@ bool DemodulatorInstance::isTerminated() {
demodTerminated = true;
break;
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED:
#ifdef __APPLE__
pthread_join(t_PreDemod, NULL);
#else
t_PreDemod->join();
delete t_PreDemod;
#endif
preDemodTerminated = true;
if (t_PreDemod) {
#ifdef __APPLE__
pthread_join(t_PreDemod, NULL);
#else
t_PreDemod->join();
delete t_PreDemod;
#endif
preDemodTerminated = true;
t_PreDemod = nullptr;
}
break;
default:
break;

View File

@ -84,7 +84,7 @@ void DemodulatorWorkerThread::run() {
float As = 60.0f; // stop-band attenuation [dB]
if (result.sampleRate && result.bandwidth) {
if (cModem && result.sampleRate && result.bandwidth) {
result.bandwidth = cModem->checkSampleRate(result.bandwidth, makeDemod?demodCommand.audioSampleRate:filterCommand.audioSampleRate);
result.iqResampleRatio = (double) (result.bandwidth) / (double) result.sampleRate;
result.iqResampler = msresamp_crcf_create(result.iqResampleRatio, As);

View File

@ -184,7 +184,9 @@ void SDRPostThread::run() {
}
}
data_in->decRefCount();
if (data_in) {
data_in->decRefCount();
}
bool doUpdate = false;
for (size_t j = 0; j < nRunDemods; j++) {