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) { if (!demod) {
return; return;
} }
demod->setActive(false);
sdrPostThread->removeDemodulator(demod); sdrPostThread->removeDemodulator(demod);
} }

View File

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

View File

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

View File

@ -24,6 +24,9 @@ void DemodulatorWorkerThread::threadMain() {
commandQueue->pop(command); commandQueue->pop(command);
switch (command.cmd) { switch (command.cmd) {
case DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS: case DemodulatorWorkerThreadCommand::DEMOD_WORKER_THREAD_CMD_BUILD_FILTERS:
if (!filterCommand.bandwidth || !filterCommand.audioSampleRate) {
break;
}
filterChanged = true; filterChanged = true;
filterCommand = command; filterCommand = command;
break; break;
@ -32,13 +35,14 @@ void DemodulatorWorkerThread::threadMain() {
} }
done = commandQueue->empty(); done = commandQueue->empty();
} }
if (filterChanged && !terminated) { if (filterChanged && !terminated) {
DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS); DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS);
result.iqResampleRatio = (double) (filterCommand.bandwidth) / (double) filterCommand.sampleRate; result.iqResampleRatio = (double) (filterCommand.bandwidth) / (double) filterCommand.sampleRate;
result.audioResamplerRatio = (double) (filterCommand.audioSampleRate) / (double) filterCommand.bandwidth; result.audioResamplerRatio = (double) (filterCommand.audioSampleRate) / (double) filterCommand.bandwidth;
float As = 60.0f; // stop-band attenuation [dB] float As = 60.0f; // stop-band attenuation [dB]
result.iqResampler = msresamp_crcf_create(result.iqResampleRatio, As); result.iqResampler = msresamp_crcf_create(result.iqResampleRatio, As);

View File

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