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,13 +257,16 @@ bool DemodulatorInstance::isActive() {
} }
void DemodulatorInstance::setActive(bool state) { void DemodulatorInstance::setActive(bool state) {
//always nudge the adio thread
audioThread->setActive(state);
if (active && !state) { if (active && !state) {
#if ENABLE_DIGITAL_LAB #if ENABLE_DIGITAL_LAB
if (activeOutput) { if (activeOutput) {
activeOutput->Hide(); activeOutput->Hide();
} }
#endif #endif
audioThread->setActive(state);
DemodulatorThread::releaseSquelchLock(this); DemodulatorThread::releaseSquelchLock(this);
@ -273,7 +276,6 @@ void DemodulatorInstance::setActive(bool state) {
activeOutput->Show(); activeOutput->Show();
} }
#endif #endif
audioThread->setActive(state);
} }
if (!state) { if (!state) {
tracking = false; tracking = false;

View File

@ -81,7 +81,12 @@ void SDRPostThread::updateActiveDemodulators() {
if (abs(frequency - demod->getFrequency()) > (sampleRate / 2)) { if (abs(frequency - demod->getFrequency()) > (sampleRate / 2)) {
// deactivate if active // 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); demod->setActive(false);
} }
@ -102,12 +107,27 @@ void SDRPostThread::updateActiveDemodulators() {
continue; continue;
} }
// Add to the current run // Add active demods to the current run:
runDemods.push_back(demod); runDemods.push_back(demod);
demodChannel.push_back(-1); 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() { void SDRPostThread::updateChannels() {
// calculate channel center frequencies, todo: cache // calculate channel center frequencies, todo: cache
for (int i = 0; i < numChannels/2; i++) { for (int i = 0; i < numChannels/2; i++) {
@ -275,7 +295,7 @@ void SDRPostThread::runSingleCH(SDRThreadIQData *data_in) {
//VSO: timed-push //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. //some runDemods are no longer there, bail out from runSingleCH() entirely.
doRefresh = true; resetAllDemodulators();
return; return;
} }
} }
@ -423,7 +443,7 @@ void SDRPostThread::runPFBCH(SDRThreadIQData *data_in) {
//VSO: timed- push //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. //Some runDemods are no longer there, bail out from runPFBCH() entirely.
doRefresh = true; resetAllDemodulators();
return; return;
} }
} }

View File

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