From 2bdefca2635112c2794ae0299a130b58887c8d09 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 7 Jun 2016 21:12:30 -0400 Subject: [PATCH] Trying.. still one stuck in the queue on delete.. --- src/audio/AudioThread.cpp | 16 ++++++++-------- src/demod/DemodulatorThread.cpp | 23 +++++++++++------------ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/audio/AudioThread.cpp b/src/audio/AudioThread.cpp index c4152de..5db31d8 100644 --- a/src/audio/AudioThread.cpp +++ b/src/audio/AudioThread.cpp @@ -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) { DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED); tCmd.context = this; @@ -421,14 +429,6 @@ void AudioThread::terminate() { terminated = true; AudioThreadCommand endCond; // push an empty input to bump the queue cmdQueue.push(endCond); - - while (!inputQueue->empty()) { // flush queue - AudioThreadInput *dummy; - inputQueue->pop(dummy); - if (dummy) { - dummy->decRefCount(); - } - } } bool AudioThread::isActive() { diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index 0ef3bb1..bab8239 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -173,7 +173,7 @@ void DemodulatorThread::run() { } } } else if (ati) { - ati->decRefCount(); + ati->setRefCount(0); ati = nullptr; } @@ -279,24 +279,23 @@ void DemodulatorThread::run() { // Purge any unused inputs while (!iqInputQueue->empty()) { - DemodulatorThreadPostIQData *inp; - iqInputQueue->pop(inp); - inp->setRefCount(0); + DemodulatorThreadPostIQData *ref; + iqInputQueue->pop(ref); + if (ref) { + ref->setRefCount(0); + } } while (!audioOutputQueue->empty()) { - AudioThreadInput *ati; - audioOutputQueue->pop(ati); - ati->setRefCount(0); + AudioThreadInput *ref; + audioOutputQueue->pop(ref); + if (ref) { + ref->setRefCount(0); + } } outputBuffers.purge(); //Guard the cleanup of audioVisOutputQueue properly. 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); tCmd.context = this;