Make sure squelch lock is released on de-activate too

This commit is contained in:
Charles J. Cliffe 2016-08-13 14:18:41 -04:00
parent 1fd23b6d33
commit 9f5c674646
3 changed files with 16 additions and 8 deletions

View File

@ -214,6 +214,7 @@ void DemodulatorInstance::setActive(bool state) {
}
#endif
audioThread->setActive(state);
DemodulatorThread::releaseSquelchLock(this);
} else if (!active && state) {
#if ENABLE_DIGITAL_LAB
if (activeOutput && getModemType() == "digital") {

View File

@ -26,10 +26,7 @@ DemodulatorThread::DemodulatorThread(DemodulatorInstance *parent)
}
DemodulatorThread::~DemodulatorThread() {
std::lock_guard < std::mutex > lock(squelchLockMutex);
if (squelchLock.load() == demodInstance) {
squelchLock.store(nullptr);
}
releaseSquelchLock(demodInstance);
}
void DemodulatorThread::onBindOutput(std::string name, ThreadQueueBase *threadQueue) {
@ -208,10 +205,7 @@ void DemodulatorThread::run() {
}
} else if (squelched && squelchBreak) {
std::lock_guard < std::mutex > lock(squelchLockMutex);
if (squelchLock.load() == demodInstance) {
squelchLock.store(nullptr);
}
releaseSquelchLock(demodInstance);
squelchBreak = false;
}
}
@ -403,3 +397,14 @@ void DemodulatorThread::setSquelchLevel(float signal_level_in) {
float DemodulatorThread::getSquelchLevel() {
return squelchLevel;
}
bool DemodulatorThread::getSquelchBreak() {
return squelchBreak;
}
void DemodulatorThread::releaseSquelchLock(DemodulatorInstance *inst) {
std::lock_guard < std::mutex > lock(squelchLockMutex);
if (squelchLock.load() == inst) {
squelchLock.store(nullptr);
}
}

View File

@ -36,6 +36,8 @@ public:
float getSquelchLevel();
bool getSquelchBreak();
static void releaseSquelchLock(DemodulatorInstance *inst);
protected: