Fix hang when the active demodulator goes out-of-bandwwidth by changing sample rate

This commit is contained in:
vsonnier 2017-08-29 21:59:30 +02:00
parent 3842cf087f
commit 9bbcb582e3
3 changed files with 35 additions and 11 deletions

View File

@ -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;

View File

@ -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;
}
}

View File

@ -33,6 +33,8 @@ private:
void updateChannels();
int getChannelAt(long long frequency);
void resetAllDemodulators();
ReBuffer<DemodulatorThreadIQData> buffers;
std::vector<liquid_float_complex> fpData;
std::vector<liquid_float_complex> dataOut;