Merge pull request #358 from cjcliffe/bugfix_sessions_crashes

Session and Crash fixes
This commit is contained in:
Charles J. Cliffe 2016-06-02 23:50:49 -04:00
commit ad94fe6de3
11 changed files with 171 additions and 188 deletions

View File

@ -1598,15 +1598,22 @@ bool AppFrame::loadSession(std::string fileName) {
wxGetApp().getDemodMgr().terminateAll(); wxGetApp().getDemodMgr().terminateAll();
try { try {
if (!l.rootNode()->hasAnother("header")) {
return false;
}
DataNode *header = l.rootNode()->getNext("header"); DataNode *header = l.rootNode()->getNext("header");
if (header->hasAnother("version")) {
std::string version(*header->getNext("version")); std::string version(*header->getNext("version"));
std::cout << "Loading " << version << " session file" << std::endl; // std::cout << "Loading " << version << " session file" << std::endl;
}
if (header->hasAnother("center_freq")) {
long long center_freq = *header->getNext("center_freq"); long long center_freq = *header->getNext("center_freq");
std::cout << "\tCenter Frequency: " << center_freq << std::endl; // std::cout << "\tCenter Frequency: " << center_freq << std::endl;
wxGetApp().setFrequency(center_freq); wxGetApp().setFrequency(center_freq);
}
if (header->hasAnother("sample_rate")) { if (header->hasAnother("sample_rate")) {
int sample_rate = *header->getNext("sample_rate"); int sample_rate = *header->getNext("sample_rate");
@ -1623,6 +1630,7 @@ bool AppFrame::loadSession(std::string fileName) {
} }
if (l.rootNode()->hasAnother("demodulators")) {
DataNode *demodulators = l.rootNode()->getNext("demodulators"); DataNode *demodulators = l.rootNode()->getNext("demodulators");
int numDemodulators = 0; int numDemodulators = 0;
@ -1724,20 +1732,20 @@ bool AppFrame::loadSession(std::string fileName) {
} }
} }
if (!found_device) { // if (!found_device) {
std::cout << "\tWarning: named output device '" << output_device << "' was not found. Using default output."; // std::cout << "\tWarning: named output device '" << output_device << "' was not found. Using default output.";
} // }
newDemod->run(); newDemod->run();
newDemod->setActive(true); newDemod->setActive(true);
demodsLoaded.push_back(newDemod); demodsLoaded.push_back(newDemod);
// wxGetApp().bindDemodulator(newDemod); // wxGetApp().bindDemodulator(newDemod);
std::cout << "\tAdded demodulator at frequency " << freq << " type " << type << std::endl; std::cout << "\tAdded demodulator at frequency " << newDemod->getFrequency() << " type " << type << std::endl;
std::cout << "\t\tBandwidth: " << bandwidth << std::endl; // std::cout << "\t\tBandwidth: " << bandwidth << std::endl;
std::cout << "\t\tSquelch Level: " << squelch_level << std::endl; // std::cout << "\t\tSquelch Level: " << squelch_level << std::endl;
std::cout << "\t\tSquelch Enabled: " << (squelch_enabled ? "true" : "false") << std::endl; // std::cout << "\t\tSquelch Enabled: " << (squelch_enabled ? "true" : "false") << std::endl;
std::cout << "\t\tOutput Device: " << output_device << std::endl; // std::cout << "\t\tOutput Device: " << output_device << std::endl;
} }
DemodulatorInstance *focusDemod = loadedDemod?loadedDemod:newDemod; DemodulatorInstance *focusDemod = loadedDemod?loadedDemod:newDemod;
@ -1746,9 +1754,7 @@ bool AppFrame::loadSession(std::string fileName) {
wxGetApp().bindDemodulators(&demodsLoaded); wxGetApp().bindDemodulators(&demodsLoaded);
wxGetApp().getDemodMgr().setActiveDemodulator(focusDemod, false); wxGetApp().getDemodMgr().setActiveDemodulator(focusDemod, false);
} }
} catch (DataInvalidChildException &e) { }
std::cout << e.what() << std::endl;
return false;
} catch (DataTypeMismatchException &e) { } catch (DataTypeMismatchException &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
return false; return false;

View File

@ -368,7 +368,7 @@ void AudioThread::run() {
pthread_setschedparam(tID, SCHED_RR, &prio); pthread_setschedparam(tID, SCHED_RR, &prio);
#endif #endif
std::cout << "Audio thread initializing.." << std::endl; // std::cout << "Audio thread initializing.." << std::endl;
if (dac.getDeviceCount() < 1) { if (dac.getDeviceCount() < 1) {
std::cout << "No audio devices found!" << std::endl; std::cout << "No audio devices found!" << std::endl;
@ -377,7 +377,7 @@ void AudioThread::run() {
setupDevice((outputDevice.load() == -1) ? (dac.getDefaultOutputDevice()) : outputDevice.load()); setupDevice((outputDevice.load() == -1) ? (dac.getDefaultOutputDevice()) : outputDevice.load());
std::cout << "Audio thread started." << std::endl; // std::cout << "Audio thread started." << std::endl;
inputQueue = static_cast<AudioThreadInputQueue *>(getInputQueue("AudioDataInput")); inputQueue = static_cast<AudioThreadInputQueue *>(getInputQueue("AudioDataInput"));
threadQueueNotify = static_cast<DemodulatorThreadCommandQueue*>(getOutputQueue("NotifyQueue")); threadQueueNotify = static_cast<DemodulatorThreadCommandQueue*>(getOutputQueue("NotifyQueue"));
@ -414,7 +414,7 @@ void AudioThread::run() {
tCmd.context = this; tCmd.context = this;
threadQueueNotify->push(tCmd); threadQueueNotify->push(tCmd);
} }
std::cout << "Audio thread done." << std::endl; // std::cout << "Audio thread done." << std::endl;
} }
void AudioThread::terminate() { void AudioThread::terminate() {

View File

@ -12,16 +12,18 @@ DemodulatorInstance::DemodulatorInstance() :
activeOutput = nullptr; activeOutput = nullptr;
#endif #endif
terminated.store(true); terminated.store(true);
audioTerminated.store(true);
demodTerminated.store(true); demodTerminated.store(true);
audioTerminated.store(true);
preDemodTerminated.store(true); preDemodTerminated.store(true);
active.store(false); active.store(false);
squelch.store(false); squelch.store(false);
muted.store(false); muted.store(false);
tracking.store(false); deltaLock.store(false);
follow.store(false); deltaLockOfs.store(0);
currentOutputDevice.store(-1); currentOutputDevice.store(-1);
currentAudioGain.store(1.0); currentAudioGain.store(1.0);
follow.store(false);
tracking.store(false);
label = new std::string("Unnamed"); label = new std::string("Unnamed");
pipeIQInputData = new DemodulatorThreadInputQueue; pipeIQInputData = new DemodulatorThreadInputQueue;
@ -89,7 +91,7 @@ void DemodulatorInstance::run() {
pthread_create(&t_Demod, &attr, &DemodulatorThread::pthread_helper, demodulatorThread); pthread_create(&t_Demod, &attr, &DemodulatorThread::pthread_helper, demodulatorThread);
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
std::cout << "Initialized demodulator stack size of " << size << std::endl; // std::cout << "Initialized demodulator stack size of " << size << std::endl;
#else #else
t_PreDemod = new std::thread(&DemodulatorPreThread::threadMain, demodulatorPreThread); t_PreDemod = new std::thread(&DemodulatorPreThread::threadMain, demodulatorPreThread);
@ -109,11 +111,11 @@ void DemodulatorInstance::updateLabel(long long freq) {
} }
void DemodulatorInstance::terminate() { void DemodulatorInstance::terminate() {
std::cout << "Terminating demodulator audio thread.." << std::endl; // std::cout << "Terminating demodulator audio thread.." << std::endl;
audioThread->terminate(); audioThread->terminate();
std::cout << "Terminating demodulator thread.." << std::endl; // std::cout << "Terminating demodulator thread.." << std::endl;
demodulatorThread->terminate(); demodulatorThread->terminate();
std::cout << "Terminating demodulator preprocessor thread.." << std::endl; // std::cout << "Terminating demodulator preprocessor thread.." << std::endl;
demodulatorPreThread->terminate(); demodulatorPreThread->terminate();
} }

View File

@ -31,9 +31,7 @@ DemodulatorMgr::~DemodulatorMgr() {
} }
DemodulatorInstance *DemodulatorMgr::newThread() { DemodulatorInstance *DemodulatorMgr::newThread() {
garbageCollect(); std::lock_guard < std::mutex > lock(demods_busy);
demods_busy.lock();
DemodulatorInstance *newDemod = new DemodulatorInstance; DemodulatorInstance *newDemod = new DemodulatorInstance;
std::stringstream label; std::stringstream label;
@ -41,25 +39,22 @@ DemodulatorInstance *DemodulatorMgr::newThread() {
newDemod->setLabel(label.str()); newDemod->setLabel(label.str());
demods.push_back(newDemod); demods.push_back(newDemod);
demods_busy.unlock();
return newDemod; return newDemod;
} }
void DemodulatorMgr::terminateAll() { void DemodulatorMgr::terminateAll() {
std::lock_guard < std::mutex > lock(demods_busy);
while (demods.size()) { while (demods.size()) {
demods_busy.lock();
DemodulatorInstance *d = demods.back(); DemodulatorInstance *d = demods.back();
demods.pop_back(); demods.pop_back();
demods_busy.unlock();
wxGetApp().removeDemodulator(d); wxGetApp().removeDemodulator(d);
deleteThread(d); deleteThread(d);
} }
} }
std::vector<DemodulatorInstance *> &DemodulatorMgr::getDemodulators() { std::vector<DemodulatorInstance *> &DemodulatorMgr::getDemodulators() {
demods_busy.lock(); std::lock_guard < std::mutex > lock(demods_busy);
demods_busy.unlock();
return demods; return demods;
} }
@ -127,8 +122,6 @@ DemodulatorInstance *DemodulatorMgr::getFirstDemodulator() {
} }
void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) { void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) {
demods_busy.lock();
std::vector<DemodulatorInstance *>::iterator i; std::vector<DemodulatorInstance *>::iterator i;
i = std::find(demods.begin(), demods.end(), demod); i = std::find(demods.begin(), demods.end(), demod);
@ -149,14 +142,10 @@ void DemodulatorMgr::deleteThread(DemodulatorInstance *demod) {
demod->terminate(); demod->terminate();
demods_deleted.push_back(demod); demods_deleted.push_back(demod);
demods_busy.unlock();
garbageCollect();
} }
std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(long long freq, int bandwidth) { std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(long long freq, int bandwidth) {
demods_busy.lock(); std::lock_guard < std::mutex > lock(demods_busy);
std::vector<DemodulatorInstance *> *foundDemods = new std::vector<DemodulatorInstance *>(); std::vector<DemodulatorInstance *> *foundDemods = new std::vector<DemodulatorInstance *>();
for (int i = 0, iMax = demods.size(); i < iMax; i++) { for (int i = 0, iMax = demods.size(); i < iMax; i++) {
@ -172,13 +161,12 @@ std::vector<DemodulatorInstance *> *DemodulatorMgr::getDemodulatorsAt(long long
foundDemods->push_back(testDemod); foundDemods->push_back(testDemod);
} }
} }
demods_busy.unlock();
return foundDemods; return foundDemods;
} }
bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) { bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
demods_busy.lock(); std::lock_guard < std::mutex > lock(demods_busy);
for (int i = 0, iMax = demods.size(); i < iMax; i++) { for (int i = 0, iMax = demods.size(); i < iMax; i++) {
DemodulatorInstance *testDemod = demods[i]; DemodulatorInstance *testDemod = demods[i];
@ -189,12 +177,10 @@ bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
long long halfBuffer = bandwidth / 2; long long halfBuffer = bandwidth / 2;
if ((freq <= (freqTest + ((testDemod->getDemodulatorType() != "LSB")?halfBandwidthTest:0) + halfBuffer)) && (freq >= (freqTest - ((testDemod->getDemodulatorType() != "USB")?halfBandwidthTest:0) - halfBuffer))) { if ((freq <= (freqTest + ((testDemod->getDemodulatorType() != "LSB")?halfBandwidthTest:0) + halfBuffer)) && (freq >= (freqTest - ((testDemod->getDemodulatorType() != "USB")?halfBandwidthTest:0) - halfBuffer))) {
demods_busy.unlock();
return true; return true;
} }
} }
demods_busy.unlock();
return false; return false;
} }
@ -213,6 +199,8 @@ void DemodulatorMgr::setActiveDemodulator(DemodulatorInstance *demod, bool tempo
wxGetApp().getRigThread()->setFrequency(lastActiveDemodulator->getFrequency(),true); wxGetApp().getRigThread()->setFrequency(lastActiveDemodulator->getFrequency(),true);
} }
#endif #endif
} else {
garbageCollect();
} }
if (activeVisualDemodulator) { if (activeVisualDemodulator) {
@ -230,8 +218,6 @@ void DemodulatorMgr::setActiveDemodulator(DemodulatorInstance *demod, bool tempo
} }
activeDemodulator = demod; activeDemodulator = demod;
// garbageCollect();
} }
DemodulatorInstance *DemodulatorMgr::getActiveDemodulator() { DemodulatorInstance *DemodulatorMgr::getActiveDemodulator() {
@ -246,8 +232,8 @@ DemodulatorInstance *DemodulatorMgr::getLastActiveDemodulator() {
} }
void DemodulatorMgr::garbageCollect() { void DemodulatorMgr::garbageCollect() {
std::lock_guard < std::mutex > lock(demods_busy);
if (demods_deleted.size()) { if (demods_deleted.size()) {
demods_busy.lock();
std::vector<DemodulatorInstance *>::iterator i; std::vector<DemodulatorInstance *>::iterator i;
for (i = demods_deleted.begin(); i != demods_deleted.end(); i++) { for (i = demods_deleted.begin(); i != demods_deleted.end(); i++) {
@ -259,11 +245,9 @@ void DemodulatorMgr::garbageCollect() {
delete deleted; delete deleted;
demods_busy.unlock();
return; return;
} }
} }
demods_busy.unlock();
} }
} }

View File

@ -52,7 +52,7 @@ void DemodulatorPreThread::run() {
pthread_setschedparam(tID, SCHED_FIFO, &prio); pthread_setschedparam(tID, SCHED_FIFO, &prio);
#endif #endif
std::cout << "Demodulator preprocessor thread started.." << std::endl; // std::cout << "Demodulator preprocessor thread started.." << std::endl;
ReBuffer<DemodulatorThreadPostIQData> buffers("DemodulatorPreThreadBuffers"); ReBuffer<DemodulatorThreadPostIQData> buffers("DemodulatorPreThreadBuffers");
@ -276,7 +276,7 @@ void DemodulatorPreThread::run() {
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED); DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED);
tCmd.context = this; tCmd.context = this;
threadQueueNotify->push(tCmd); threadQueueNotify->push(tCmd);
std::cout << "Demodulator preprocessor thread done." << std::endl; // std::cout << "Demodulator preprocessor thread done." << std::endl;
} }
void DemodulatorPreThread::setDemodType(std::string demodType) { void DemodulatorPreThread::setDemodType(std::string demodType) {

View File

@ -23,7 +23,6 @@ DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent)
} }
DemodulatorThread::~DemodulatorThread() { DemodulatorThread::~DemodulatorThread() {
} }
void DemodulatorThread::onBindOutput(std::string name, ThreadQueueBase *threadQueue) { void DemodulatorThread::onBindOutput(std::string name, ThreadQueueBase *threadQueue) {
@ -65,9 +64,7 @@ void DemodulatorThread::run() {
pthread_setschedparam(tID, SCHED_FIFO, &prio); pthread_setschedparam(tID, SCHED_FIFO, &prio);
#endif #endif
ReBuffer<AudioThreadInput> audioVisBuffers("DemodulatorThreadAudioBuffers"); // std::cout << "Demodulator thread started.." << std::endl;
std::cout << "Demodulator thread started.." << std::endl;
iqInputQueue = static_cast<DemodulatorThreadPostInputQueue*>(getInputQueue("IQDataInput")); iqInputQueue = static_cast<DemodulatorThreadPostInputQueue*>(getInputQueue("IQDataInput"));
audioOutputQueue = static_cast<AudioThreadInputQueue*>(getOutputQueue("AudioDataOutput")); audioOutputQueue = static_cast<AudioThreadInputQueue*>(getOutputQueue("AudioDataOutput"));
@ -188,7 +185,7 @@ void DemodulatorThread::run() {
} }
if (ati && localAudioVisOutputQueue != nullptr && localAudioVisOutputQueue->empty()) { if (ati && localAudioVisOutputQueue != nullptr && localAudioVisOutputQueue->empty()) {
AudioThreadInput *ati_vis = audioVisBuffers.getBuffer(); AudioThreadInput *ati_vis = new AudioThreadInput;
ati_vis->setRefCount(1); ati_vis->setRefCount(1);
ati_vis->sampleRate = inp->sampleRate; ati_vis->sampleRate = inp->sampleRate;
@ -284,17 +281,16 @@ void DemodulatorThread::run() {
//Guard the cleanup of audioVisOutputQueue properly. //Guard the cleanup of audioVisOutputQueue properly.
std::lock_guard < std::mutex > lock(m_mutexAudioVisOutputQueue); std::lock_guard < std::mutex > lock(m_mutexAudioVisOutputQueue);
if (audioVisOutputQueue != nullptr && !audioVisOutputQueue->empty()) { // if (audioVisOutputQueue != nullptr && !audioVisOutputQueue->empty()) {
AudioThreadInput *dummy_vis; // AudioThreadInput *dummy_vis;
audioVisOutputQueue->pop(dummy_vis); // audioVisOutputQueue->pop(dummy_vis);
} // }
audioVisBuffers.purge();
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED); DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED);
tCmd.context = this; tCmd.context = this;
threadQueueNotify->push(tCmd); threadQueueNotify->push(tCmd);
std::cout << "Demodulator thread done." << std::endl; // std::cout << "Demodulator thread done." << std::endl;
} }
void DemodulatorThread::terminate() { void DemodulatorThread::terminate() {

View File

@ -12,7 +12,7 @@ DemodulatorWorkerThread::~DemodulatorWorkerThread() {
void DemodulatorWorkerThread::run() { void DemodulatorWorkerThread::run() {
std::cout << "Demodulator worker thread started.." << std::endl; // std::cout << "Demodulator worker thread started.." << std::endl;
commandQueue = static_cast<DemodulatorThreadWorkerCommandQueue *>(getInputQueue("WorkerCommandQueue")); commandQueue = static_cast<DemodulatorThreadWorkerCommandQueue *>(getInputQueue("WorkerCommandQueue"));
resultQueue = static_cast<DemodulatorThreadWorkerResultQueue *>(getOutputQueue("WorkerResultQueue")); resultQueue = static_cast<DemodulatorThreadWorkerResultQueue *>(getOutputQueue("WorkerResultQueue"));
@ -99,7 +99,7 @@ void DemodulatorWorkerThread::run() {
} }
std::cout << "Demodulator worker thread done." << std::endl; // std::cout << "Demodulator worker thread done." << std::endl;
} }
void DemodulatorWorkerThread::terminate() { void DemodulatorWorkerThread::terminate() {

View File

@ -35,7 +35,7 @@ void FFTVisualDataThread::run() {
wproc.attachOutput(pipeFFTDataOut); wproc.attachOutput(pipeFFTDataOut);
wproc.setup(DEFAULT_FFT_SIZE); wproc.setup(DEFAULT_FFT_SIZE);
std::cout << "FFT visual data thread started." << std::endl; // std::cout << "FFT visual data thread started." << std::endl;
while(!terminated) { while(!terminated) {
@ -63,6 +63,6 @@ void FFTVisualDataThread::run() {
} }
} }
std::cout << "FFT visual data thread done." << std::endl; // std::cout << "FFT visual data thread done." << std::endl;
} }

View File

@ -99,7 +99,7 @@ void ScopeVisualProcessor::process() {
} }
size_t i, iMax = audioInputData->data.size(); size_t i, iMax = audioInputData->data.size();
if (!iMax) { if (!iMax) {
audioInputData->decRefCount(); delete audioInputData; //->decRefCount();
return; return;
} }
@ -213,7 +213,7 @@ void ScopeVisualProcessor::process() {
renderData->inputRate = audioInputData->inputRate; renderData->inputRate = audioInputData->inputRate;
renderData->sampleRate = audioInputData->sampleRate; renderData->sampleRate = audioInputData->sampleRate;
audioInputData->decRefCount(); delete audioInputData; //->decRefCount();
float fft_ceil = 0, fft_floor = 1; float fft_ceil = 0, fft_floor = 1;
@ -280,7 +280,7 @@ void ScopeVisualProcessor::process() {
renderData->spectrum = true; renderData->spectrum = true;
distribute(renderData); distribute(renderData);
} else { } else {
audioInputData->decRefCount(); delete audioInputData; //->decRefCount();
} }
} }
} }

View File

@ -13,7 +13,7 @@ SpectrumVisualProcessor *SpectrumVisualDataThread::getProcessor() {
} }
void SpectrumVisualDataThread::run() { void SpectrumVisualDataThread::run() {
std::cout << "Spectrum visual data thread started." << std::endl; // std::cout << "Spectrum visual data thread started." << std::endl;
while(!terminated) { while(!terminated) {
std::this_thread::sleep_for(std::chrono::milliseconds(10)); std::this_thread::sleep_for(std::chrono::milliseconds(10));
@ -21,6 +21,6 @@ void SpectrumVisualDataThread::run() {
sproc.run(); sproc.run();
} }
std::cout << "Spectrum visual data thread done." << std::endl; // std::cout << "Spectrum visual data thread done." << std::endl;
} }

View File

@ -27,22 +27,20 @@ SDRPostThread::~SDRPostThread() {
} }
void SDRPostThread::bindDemodulator(DemodulatorInstance *demod) { void SDRPostThread::bindDemodulator(DemodulatorInstance *demod) {
busy_demod.lock(); std::lock_guard < std::mutex > lock(busy_demod);
demodulators.push_back(demod); demodulators.push_back(demod);
doRefresh.store(true); doRefresh.store(true);
busy_demod.unlock();
} }
void SDRPostThread::bindDemodulators(std::vector<DemodulatorInstance *> *demods) { void SDRPostThread::bindDemodulators(std::vector<DemodulatorInstance *> *demods) {
if (!demods) { if (!demods) {
return; return;
} }
busy_demod.lock(); std::lock_guard < std::mutex > lock(busy_demod);
for (std::vector<DemodulatorInstance *>::iterator di = demods->begin(); di != demods->end(); di++) { for (std::vector<DemodulatorInstance *>::iterator di = demods->begin(); di != demods->end(); di++) {
demodulators.push_back(*di); demodulators.push_back(*di);
doRefresh.store(true); doRefresh.store(true);
} }
busy_demod.unlock();
} }
void SDRPostThread::removeDemodulator(DemodulatorInstance *demod) { void SDRPostThread::removeDemodulator(DemodulatorInstance *demod) {
@ -50,14 +48,13 @@ void SDRPostThread::removeDemodulator(DemodulatorInstance *demod) {
return; return;
} }
busy_demod.lock(); std::lock_guard < std::mutex > lock(busy_demod);
std::vector<DemodulatorInstance *>::iterator i = std::find(demodulators.begin(), demodulators.end(), demod); std::vector<DemodulatorInstance *>::iterator i = std::find(demodulators.begin(), demodulators.end(), demod);
if (i != demodulators.end()) { if (i != demodulators.end()) {
demodulators.erase(i); demodulators.erase(i);
doRefresh.store(true); doRefresh.store(true);
} }
busy_demod.unlock();
} }
void SDRPostThread::initPFBChannelizer() { void SDRPostThread::initPFBChannelizer() {
@ -171,7 +168,7 @@ void SDRPostThread::run() {
pthread_setschedparam(tID, SCHED_FIFO, &prio); pthread_setschedparam(tID, SCHED_FIFO, &prio);
#endif #endif
std::cout << "SDR post-processing thread started.." << std::endl; // std::cout << "SDR post-processing thread started.." << std::endl;
iqDataInQueue = static_cast<SDRThreadIQDataQueue*>(getInputQueue("IQDataInput")); iqDataInQueue = static_cast<SDRThreadIQDataQueue*>(getInputQueue("IQDataInput"));
iqDataOutQueue = static_cast<DemodulatorThreadInputQueue*>(getOutputQueue("IQDataOutput")); iqDataOutQueue = static_cast<DemodulatorThreadInputQueue*>(getOutputQueue("IQDataOutput"));
@ -186,7 +183,7 @@ void SDRPostThread::run() {
iqDataInQueue->pop(data_in); iqDataInQueue->pop(data_in);
// std::lock_guard < std::mutex > lock(data_in->m_mutex); // std::lock_guard < std::mutex > lock(data_in->m_mutex);
busy_demod.lock(); std::lock_guard < std::mutex > lock(busy_demod);
if (data_in && data_in->data.size()) { if (data_in && data_in->data.size()) {
if(data_in->numChannels > 1) { if(data_in->numChannels > 1) {
@ -211,8 +208,6 @@ void SDRPostThread::run() {
if (doUpdate) { if (doUpdate) {
updateActiveDemodulators(); updateActiveDemodulators();
} }
busy_demod.unlock();
} }
if (iqVisualQueue && !iqVisualQueue->empty()) { if (iqVisualQueue && !iqVisualQueue->empty()) {
@ -223,7 +218,7 @@ void SDRPostThread::run() {
// buffers.purge(); // buffers.purge();
// visualDataBuffers.purge(); // visualDataBuffers.purge();
std::cout << "SDR post-processing thread done." << std::endl; // std::cout << "SDR post-processing thread done." << std::endl;
} }
void SDRPostThread::terminate() { void SDRPostThread::terminate() {