Fix demodulator termination / thread lock

This commit is contained in:
Charles J. Cliffe 2015-01-11 20:26:51 -05:00
parent e7b22bd186
commit 2b6da304ef
5 changed files with 9 additions and 5 deletions

View File

@ -421,13 +421,12 @@ void AudioThread::threadMain() {
}
#endif
std::cout << "Audio thread done." << std::endl;
if (threadQueueNotify != NULL) {
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED);
tCmd.context = this;
threadQueueNotify->push(tCmd);
}
std::cout << "Audio thread done." << std::endl;
}
void AudioThread::terminate() {

View File

@ -126,12 +126,14 @@ bool DemodulatorInstance::isTerminated() {
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED:
t_Audio->join();
audioTerminated = true;
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;
#endif
demodTerminated = true;
break;
@ -140,6 +142,7 @@ bool DemodulatorInstance::isTerminated() {
pthread_join(t_PreDemod, NULL);
#else
t_PreDemod->join();
delete t_PreDemod;
#endif
preDemodTerminated = true;
break;

View File

@ -239,10 +239,10 @@ void DemodulatorPreThread::threadMain() {
delete iqDataDel;
}
std::cout << "Demodulator preprocessor thread done." << std::endl;
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED);
tCmd.context = this;
threadQueueNotify->push(tCmd);
std::cout << "Demodulator preprocessor thread done." << std::endl;
}
void DemodulatorPreThread::terminate() {
@ -250,4 +250,6 @@ void DemodulatorPreThread::terminate() {
DemodulatorThreadIQData *inp = new DemodulatorThreadIQData; // push dummy to nudge queue
iqInputQueue->push(inp);
workerThread->terminate();
t_Worker->detach();
delete t_Worker;
}

View File

@ -406,10 +406,10 @@ void DemodulatorThread::threadMain() {
delete audioDataDel;
}
std::cout << "Demodulator thread done." << std::endl;
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED);
tCmd.context = this;
threadQueueNotify->push(tCmd);
std::cout << "Demodulator thread done." << std::endl;
}
void DemodulatorThread::setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue) {

View File

@ -31,7 +31,7 @@ void DemodulatorWorkerThread::threadMain() {
done = commandQueue->empty();
}
if (filterChanged) {
if (filterChanged && !terminated) {
DemodulatorWorkerThreadResult result(DemodulatorWorkerThreadResult::DEMOD_WORKER_THREAD_RESULT_FILTERS);
result.iqResampleRatio = (double) (filterCommand.bandwidth) / (double) filterCommand.sampleRate;