Attempt to clean up any buffers that weren't used on terminate, still one hanging around..

This commit is contained in:
Charles J. Cliffe 2016-06-07 20:36:59 -04:00
parent 389ac4f537
commit 50bfb251f8
4 changed files with 26 additions and 1 deletions

View File

@ -421,6 +421,14 @@ 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

@ -271,6 +271,11 @@ void DemodulatorPreThread::run() {
} }
} }
while (!iqOutputQueue->empty()) {
DemodulatorThreadPostIQData *tmp;
iqOutputQueue->pop(tmp);
tmp->decRefCount();
}
buffers.purge(); buffers.purge();
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED); DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED);

View File

@ -277,6 +277,17 @@ void DemodulatorThread::run() {
} }
// end while !terminated // end while !terminated
// Purge any unused inputs
while (!iqInputQueue->empty()) {
DemodulatorThreadPostIQData *inp;
iqInputQueue->pop(inp);
inp->setRefCount(0);
}
while (!audioOutputQueue->empty()) {
AudioThreadInput *ati;
audioOutputQueue->pop(ati);
ati->setRefCount(0);
}
outputBuffers.purge(); outputBuffers.purge();
//Guard the cleanup of audioVisOutputQueue properly. //Guard the cleanup of audioVisOutputQueue properly.

View File

@ -231,8 +231,9 @@ public:
/** /**
* Remove any items in the queue. * Remove any items in the queue.
*/ */
void flush() const { void flush() {
std::lock_guard < std::mutex > lock(m_mutex); std::lock_guard < std::mutex > lock(m_mutex);
m_queue = std::queue<T, Container>();
std::queue<T, Container> emptyQueue; std::queue<T, Container> emptyQueue;
std::swap(m_queue, emptyQueue); std::swap(m_queue, emptyQueue);
} }