diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index cb6e63e..401e68e 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -257,14 +257,17 @@ bool DemodulatorInstance::isActive() { } void DemodulatorInstance::setActive(bool state) { + + //always nudge the adio thread + audioThread->setActive(state); + if (active && !state) { #if ENABLE_DIGITAL_LAB if (activeOutput) { activeOutput->Hide(); } #endif - audioThread->setActive(state); - + DemodulatorThread::releaseSquelchLock(this); } else if (!active && state) { @@ -273,7 +276,6 @@ void DemodulatorInstance::setActive(bool state) { activeOutput->Show(); } #endif - audioThread->setActive(state); } if (!state) { tracking = false; diff --git a/src/sdr/SDRPostThread.cpp b/src/sdr/SDRPostThread.cpp index 93b1bf5..2151821 100644 --- a/src/sdr/SDRPostThread.cpp +++ b/src/sdr/SDRPostThread.cpp @@ -66,9 +66,9 @@ void SDRPostThread::updateActiveDemodulators() { //retreive the current list of demodulators: auto demodulators = wxGetApp().getDemodMgr().getDemodulators(); - + for (auto demod : demodulators) { - + // not in range? if (demod->isDeltaLock()) { if (demod->getFrequency() != centerFreq + demod->getDeltaLockOfs()) { @@ -81,9 +81,14 @@ void SDRPostThread::updateActiveDemodulators() { if (abs(frequency - demod->getFrequency()) > (sampleRate / 2)) { // deactivate if active - if (demod->isActive() && !demod->isFollow() && !demod->isTracking()) { + + if (wxGetApp().getDemodMgr().getLastActiveDemodulator() == demod) { + demod->setActive(false); } + else if (demod->isActive() && !demod->isFollow() && !demod->isTracking()) { + demod->setActive(false); + } // follow if follow mode if (demod->isFollow() && centerFreq != demod->getFrequency()) { @@ -102,12 +107,27 @@ void SDRPostThread::updateActiveDemodulators() { continue; } - // Add to the current run + // Add active demods to the current run: + runDemods.push_back(demod); demodChannel.push_back(-1); } } +void SDRPostThread::resetAllDemodulators() { + + //retreive the current list of demodulators: + auto demodulators = wxGetApp().getDemodMgr().getDemodulators(); + + for (auto demod : demodulators) { + + demod->setActive(false); + demod->getIQInputDataPipe()->flush(); + } + + doRefresh = true; +} + void SDRPostThread::updateChannels() { // calculate channel center frequencies, todo: cache for (int i = 0; i < numChannels/2; i++) { @@ -273,9 +293,9 @@ void SDRPostThread::runSingleCH(SDRThreadIQData *data_in) { for (size_t i = 0; i < runDemods.size(); i++) { //VSO: timed-push - if (!runDemods[i]->getIQInputDataPipe()->push(demodDataOut, MAX_BLOCKING_DURATION_MICROS, "runSingleCH() runDemods[i]->getIQInputDataPipe()")) { + if (!runDemods[i]->getIQInputDataPipe()->push(demodDataOut , MAX_BLOCKING_DURATION_MICROS, "runSingleCH() runDemods[i]->getIQInputDataPipe()")) { //some runDemods are no longer there, bail out from runSingleCH() entirely. - doRefresh = true; + resetAllDemodulators(); return; } } @@ -421,9 +441,9 @@ void SDRPostThread::runPFBCH(SDRThreadIQData *data_in) { if (demodChannel[j] == i) { //VSO: timed- push - if (!runDemods[j]->getIQInputDataPipe()->push(demodDataOut, MAX_BLOCKING_DURATION_MICROS, "runPFBCH() runDemods[j]->getIQInputDataPipe()")) { + if (!runDemods[j]->getIQInputDataPipe()->push(demodDataOut , MAX_BLOCKING_DURATION_MICROS, "runPFBCH() runDemods[j]->getIQInputDataPipe()")) { //Some runDemods are no longer there, bail out from runPFBCH() entirely. - doRefresh = true; + resetAllDemodulators(); return; } } diff --git a/src/sdr/SDRPostThread.h b/src/sdr/SDRPostThread.h index ff27721..2725901 100644 --- a/src/sdr/SDRPostThread.h +++ b/src/sdr/SDRPostThread.h @@ -33,6 +33,8 @@ private: void updateChannels(); int getChannelAt(long long frequency); + void resetAllDemodulators(); + ReBuffer buffers; std::vector fpData; std::vector dataOut;