mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 13:48:38 -05:00
SDRPostThread is better using try_push, restore previous audio-related code in DemodulatorInstance
This commit is contained in:
parent
87077a89c1
commit
030628c5ed
@ -256,17 +256,14 @@ bool DemodulatorInstance::isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
void DemodulatorInstance::setActive(bool state) {
|
||||
|
||||
//always nudge the adio thread
|
||||
audioThread->setActive(state);
|
||||
|
||||
void DemodulatorInstance::setActive(bool state) {
|
||||
if (active && !state) {
|
||||
#if ENABLE_DIGITAL_LAB
|
||||
if (activeOutput) {
|
||||
activeOutput->Hide();
|
||||
}
|
||||
#endif
|
||||
audioThread->setActive(state);
|
||||
|
||||
DemodulatorThread::releaseSquelchLock(this);
|
||||
|
||||
@ -276,6 +273,7 @@ void DemodulatorInstance::setActive(bool state) {
|
||||
activeOutput->Show();
|
||||
}
|
||||
#endif
|
||||
audioThread->setActive(state);
|
||||
}
|
||||
if (!state) {
|
||||
tracking = false;
|
||||
|
@ -12,9 +12,6 @@
|
||||
//50 ms
|
||||
#define HEARTBEAT_CHECK_PERIOD_MICROS (50 * 1000)
|
||||
|
||||
//1s
|
||||
#define MAX_BLOCKING_DURATION_MICROS (1000 * 1000)
|
||||
|
||||
SDRPostThread::SDRPostThread() : IOThread(), buffers("SDRPostThreadBuffers"), visualDataBuffers("SDRPostThreadVisualDataBuffers"), frequency(0) {
|
||||
iqDataInQueue = nullptr;
|
||||
iqDataOutQueue = nullptr;
|
||||
@ -292,11 +289,13 @@ 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()")) {
|
||||
//some runDemods are no longer there, bail out from runSingleCH() entirely.
|
||||
resetAllDemodulators();
|
||||
return;
|
||||
// try-push() : we do our best to only stimulate active demods, but some could happen to be dead, full, or indeed non-active.
|
||||
//so in short never block here no matter what.
|
||||
if (!runDemods[i]->getIQInputDataPipe()->try_push(demodDataOut)) {
|
||||
|
||||
std::cout << "SDRPostThread::runSingleCH() attempt to push into demod '" << runDemods[i]->getLabel()
|
||||
<< "' (" << runDemods[i]->getFrequency() << " Hz) failed, demod is either too busy, not-active, or dead..." << std::endl << std::flush;
|
||||
std::this_thread::yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -440,11 +439,12 @@ void SDRPostThread::runPFBCH(SDRThreadIQData *data_in) {
|
||||
for (size_t j = 0; j < runDemods.size(); j++) {
|
||||
if (demodChannel[j] == i) {
|
||||
|
||||
//VSO: timed- push
|
||||
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.
|
||||
resetAllDemodulators();
|
||||
return;
|
||||
// try-push() : we do our best to only stimulate active demods, but some could happen to be dead, full, or indeed non-active.
|
||||
//so in short never block here no matter what.
|
||||
if (!runDemods[j]->getIQInputDataPipe()->try_push(demodDataOut)) {
|
||||
std::cout << "SDRPostThread::runPFBCH() attempt to push into demod '" << runDemods[i]->getLabel()
|
||||
<< "' (" << runDemods[i]->getFrequency() << " Hz) failed, demod is either too busy, not-active, or dead..." << std::endl << std::flush;
|
||||
std::this_thread::yield();
|
||||
}
|
||||
}
|
||||
} //end for
|
||||
|
@ -65,7 +65,7 @@ bool TuningCanvas::changed() {
|
||||
auto activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||
|
||||
long long current_freq = 0;
|
||||
if (activeDemod != NULL) {
|
||||
if (activeDemod != nullptr) {
|
||||
freq = activeDemod->getFrequency();
|
||||
}
|
||||
long long current_bw = wxGetApp().getDemodMgr().getLastBandwidth();
|
||||
@ -96,7 +96,7 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
auto activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||
|
||||
freq = 0;
|
||||
if (activeDemod != NULL) {
|
||||
if (activeDemod != nullptr) {
|
||||
freq = activeDemod->getFrequency();
|
||||
}
|
||||
bw = wxGetApp().getDemodMgr().getLastBandwidth();
|
||||
|
Loading…
Reference in New Issue
Block a user