Trying.. still one stuck in the queue on delete..

This commit is contained in:
Charles J. Cliffe 2016-06-07 21:12:30 -04:00
parent 50bfb251f8
commit 2bdefca263
2 changed files with 19 additions and 20 deletions

View File

@ -409,6 +409,14 @@ void AudioThread::run() {
} }
} }
while (!inputQueue->empty()) { // flush queue
AudioThreadInput *dummy;
inputQueue->pop(dummy);
if (dummy) {
dummy->setRefCount(0);
}
}
if (threadQueueNotify != NULL) { if (threadQueueNotify != NULL) {
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED); DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED);
tCmd.context = this; tCmd.context = this;
@ -421,14 +429,6 @@ void AudioThread::terminate() {
terminated = true; terminated = true;
AudioThreadCommand endCond; // push an empty input to bump the queue AudioThreadCommand endCond; // push an empty input to bump the queue
cmdQueue.push(endCond); cmdQueue.push(endCond);
while (!inputQueue->empty()) { // flush queue
AudioThreadInput *dummy;
inputQueue->pop(dummy);
if (dummy) {
dummy->decRefCount();
}
}
} }
bool AudioThread::isActive() { bool AudioThread::isActive() {

View File

@ -173,7 +173,7 @@ void DemodulatorThread::run() {
} }
} }
} else if (ati) { } else if (ati) {
ati->decRefCount(); ati->setRefCount(0);
ati = nullptr; ati = nullptr;
} }
@ -279,25 +279,24 @@ void DemodulatorThread::run() {
// Purge any unused inputs // Purge any unused inputs
while (!iqInputQueue->empty()) { while (!iqInputQueue->empty()) {
DemodulatorThreadPostIQData *inp; DemodulatorThreadPostIQData *ref;
iqInputQueue->pop(inp); iqInputQueue->pop(ref);
inp->setRefCount(0); if (ref) {
ref->setRefCount(0);
}
} }
while (!audioOutputQueue->empty()) { while (!audioOutputQueue->empty()) {
AudioThreadInput *ati; AudioThreadInput *ref;
audioOutputQueue->pop(ati); audioOutputQueue->pop(ref);
ati->setRefCount(0); if (ref) {
ref->setRefCount(0);
}
} }
outputBuffers.purge(); outputBuffers.purge();
//Guard the cleanup of audioVisOutputQueue properly. //Guard the cleanup of audioVisOutputQueue properly.
std::lock_guard < std::mutex > lock(m_mutexAudioVisOutputQueue); std::lock_guard < std::mutex > lock(m_mutexAudioVisOutputQueue);
// if (audioVisOutputQueue != nullptr && !audioVisOutputQueue->empty()) {
// AudioThreadInput *dummy_vis;
// audioVisOutputQueue->pop(dummy_vis);
// }
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED); DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED);
tCmd.context = this; tCmd.context = this;
threadQueueNotify->push(tCmd); threadQueueNotify->push(tCmd);