From 86270b330082b74bea3f31d552da2983c2e01639 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Thu, 19 Nov 2015 00:11:34 -0500 Subject: [PATCH] race/init fix; skip audio output on digital --- src/demod/DemodulatorInstance.cpp | 5 +++-- src/demod/DemodulatorPreThread.cpp | 6 +++--- src/demod/DemodulatorThread.cpp | 12 +++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index 172e95a..cd1cd03 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -73,7 +73,6 @@ void DemodulatorInstance::run() { // } currentFrequency = demodulatorPreThread->getParams().frequency; - currentDemodType = demodulatorPreThread->getParams().demodType; currentAudioSampleRate = AudioThread::deviceSampleRate[getOutputDevice()]; demodulatorPreThread->getParams().audioSampleRate = currentAudioSampleRate; @@ -101,6 +100,8 @@ void DemodulatorInstance::run() { t_PreDemod = new std::thread(&DemodulatorPreThread::threadMain, demodulatorPreThread); t_Demod = new std::thread(&DemodulatorThread::threadMain, demodulatorThread); #endif + + setDemodulatorType(demodulatorPreThread->getParams().demodType); active = true; audioTerminated = demodTerminated = preDemodTerminated = terminated = false; @@ -285,9 +286,9 @@ void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) { } setGain(getGain()); + demodulatorPreThread->getParams().demodType = currentDemodType; if (!active) { checkBandwidth(); - demodulatorPreThread->getParams().demodType = currentDemodType; } else if (demodulatorThread && threadQueueControl) { demodulatorPreThread->setDemodType(currentDemodType); } diff --git a/src/demod/DemodulatorPreThread.cpp b/src/demod/DemodulatorPreThread.cpp index 1235134..a92d942 100644 --- a/src/demod/DemodulatorPreThread.cpp +++ b/src/demod/DemodulatorPreThread.cpp @@ -52,8 +52,6 @@ void DemodulatorPreThread::run() { std::cout << "Demodulator preprocessor thread started.." << std::endl; - t_Worker = new std::thread(&DemodulatorWorkerThread::threadMain, workerThread); - ReBuffer buffers; iqInputQueue = (DemodulatorThreadInputQueue*)getInputQueue("IQDataInput"); @@ -65,6 +63,7 @@ void DemodulatorPreThread::run() { std::vector out_buf_data; setDemodType(params.demodType); + t_Worker = new std::thread(&DemodulatorWorkerThread::threadMain, workerThread); while (!terminated) { DemodulatorThreadIQData *inp; @@ -262,10 +261,11 @@ void DemodulatorPreThread::setDemodType(std::string demodType) { command.bandwidth = params.bandwidth; command.audioSampleRate = params.audioSampleRate; workerQueue->push(command); + demodTypeChanged.store(true); } std::string DemodulatorPreThread::getDemodType() { - if (newDemodType != demodType) { + if (demodTypeChanged.load()) { return newDemodType; } return demodType; diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index fe73f50..6986e65 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -116,12 +116,14 @@ void DemodulatorThread::run() { modemData.setRefCount(1); AudioThreadInput *ati = NULL; - ati = outputBuffers.getBuffer(); - - ati->sampleRate = audioSampleRate; - ati->inputRate = inp->sampleRate; - ati->setRefCount(1); + if (cModem->getType() != "digital") { + ati = outputBuffers.getBuffer(); + + ati->sampleRate = audioSampleRate; + ati->inputRate = inp->sampleRate; + ati->setRefCount(1); + } cModem->demodulate(cModemKit, &modemData, ati); if (currentSignalLevel > signalLevel) {