Solo squelch break focus lock/tweak

This commit is contained in:
Charles J. Cliffe 2016-08-12 22:58:33 -04:00
parent 6ea2b5b8e8
commit 2bbae7209f
3 changed files with 32 additions and 8 deletions

View File

@ -13,6 +13,9 @@
#include <pthread.h> #include <pthread.h>
#endif #endif
std::atomic<DemodulatorInstance *> DemodulatorThread::squelchLock(nullptr);
std::mutex DemodulatorThread::squelchLockMutex;
DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent) DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent)
: IOThread(), outputBuffers("DemodulatorThreadBuffers"), squelchLevel(-100), : IOThread(), outputBuffers("DemodulatorThreadBuffers"), squelchLevel(-100),
signalLevel(-100), signalFloor(-30), signalCeil(30), squelchEnabled(false) { signalLevel(-100), signalFloor(-30), signalCeil(30), squelchEnabled(false) {
@ -23,6 +26,10 @@ DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent)
} }
DemodulatorThread::~DemodulatorThread() { DemodulatorThread::~DemodulatorThread() {
std::lock_guard < std::mutex > lock(squelchLockMutex);
if (squelchLock.load() == demodInstance) {
squelchLock.store(nullptr);
}
} }
void DemodulatorThread::onBindOutput(std::string name, ThreadQueueBase *threadQueue) { void DemodulatorThread::onBindOutput(std::string name, ThreadQueueBase *threadQueue) {
@ -182,16 +189,29 @@ void DemodulatorThread::run() {
signalLevel = signalLevel + (currentSignalLevel - signalLevel) * 0.05 * sampleTime * 30.0; signalLevel = signalLevel + (currentSignalLevel - signalLevel) * 0.05 * sampleTime * 30.0;
} }
bool squelched = (squelchEnabled && (signalLevel < squelchLevel)); bool squelched = (muted.load() || (squelchEnabled && (signalLevel < squelchLevel)));
if (squelchEnabled) { if (squelchEnabled) {
if (!squelched && !squelchBreak) { if (!squelched && !squelchBreak) {
if (wxGetApp().getSoloMode() && !muted.load()) { if (wxGetApp().getSoloMode()) {
std::lock_guard < std::mutex > lock(squelchLockMutex);
if (squelchLock.load() == nullptr) {
squelchLock.store(demodInstance);
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr);
wxGetApp().getDemodMgr().setActiveDemodulator(demodInstance, false); wxGetApp().getDemodMgr().setActiveDemodulator(demodInstance, false);
}
squelchBreak = true; squelchBreak = true;
demodInstance->getVisualCue()->triggerSquelchBreak(120); demodInstance->getVisualCue()->triggerSquelchBreak(120);
}
} else {
squelchBreak = true;
demodInstance->getVisualCue()->triggerSquelchBreak(120);
}
} else if (squelched && squelchBreak) { } else if (squelched && squelchBreak) {
std::lock_guard < std::mutex > lock(squelchLockMutex);
if (squelchLock.load() == demodInstance) {
squelchLock.store(nullptr);
}
squelchBreak = false; squelchBreak = false;
} }
} }

View File

@ -51,6 +51,10 @@ protected:
std::atomic<float> signalLevel, signalFloor, signalCeil; std::atomic<float> signalLevel, signalFloor, signalCeil;
bool squelchEnabled, squelchBreak; bool squelchEnabled, squelchBreak;
static std::atomic<DemodulatorInstance *> squelchLock;
static std::mutex squelchLockMutex;
Modem *cModem = nullptr; Modem *cModem = nullptr;
ModemKit *cModemKit = nullptr; ModemKit *cModemKit = nullptr;

View File

@ -313,7 +313,7 @@ void SpectrumVisualProcessor::process() {
} }
if (!resampler || resampleBw != lastBandwidth || lastInputBandwidth != iqData->sampleRate) { if (!resampler || resampleBw != lastBandwidth || lastInputBandwidth != iqData->sampleRate) {
float As = 120.0f; float As = 480.0;
if (resampler) { if (resampler) {
msresamp_crcf_destroy(resampler); msresamp_crcf_destroy(resampler);