Demod worker lock-on-remove fix

This commit is contained in:
Charles J. Cliffe 2015-01-22 23:41:33 -05:00
parent d45d3842bf
commit b2e8cf0482
5 changed files with 17 additions and 4 deletions

View File

@ -185,6 +185,7 @@ void CubicSDR::removeDemodulator(DemodulatorInstance *demod) {
if (!demod) {
return;
}
demod->setActive(false);
sdrPostThread->removeDemodulator(demod);
}

View File

@ -126,14 +126,14 @@ bool DemodulatorInstance::isTerminated() {
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED:
t_Audio->join();
audioTerminated = true;
// delete t_Audio;
delete t_Audio;
break;
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED:
#ifdef __APPLE__
pthread_join(t_Demod, NULL);
#else
t_Demod->join();
// delete t_Demod;
delete t_Demod;
#endif
demodTerminated = true;
break;
@ -142,7 +142,7 @@ bool DemodulatorInstance::isTerminated() {
pthread_join(t_PreDemod, NULL);
#else
t_PreDemod->join();
// delete t_PreDemod;
delete t_PreDemod;
#endif
preDemodTerminated = true;
break;

View File

@ -409,6 +409,10 @@ void DemodulatorThread::threadMain() {
delete audioDataDel;
}
if (audioVisOutputQueue && !audioVisOutputQueue->empty()) {
AudioThreadInput *dummy_vis;
audioVisOutputQueue->pop(dummy_vis);
}
delete ati_vis;
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED);

View File

@ -24,6 +24,9 @@ void DemodulatorWorkerThread::threadMain() {
commandQueue->pop(command);
switch (command.cmd) {
case DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS:
if (!filterCommand.bandwidth || !filterCommand.audioSampleRate) {
break;
}
filterChanged = true;
filterCommand = command;
break;
@ -33,6 +36,7 @@ void DemodulatorWorkerThread::threadMain() {
done = commandQueue->empty();
}
if (filterChanged && !terminated) {
DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS);

View File

@ -208,6 +208,10 @@ void SDRPostThread::threadMain() {
// std::lock_guard < std::mutex > lock(demodDataDel->m_mutex);
// delete demodDataDel;
}
if (iqVisualQueue.load() && !iqVisualQueue.load()->empty()) {
DemodulatorThreadIQData *visualDataDummy;
iqVisualQueue.load()->pop(visualDataDummy);
}
delete visualDataOut;