mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-02-03 09:44:26 -05:00
visual process template tweaks, full() logic error fix
This commit is contained in:
parent
61add8ae09
commit
6f3d9a6c82
@ -11,7 +11,7 @@ public:
|
|||||||
|
|
||||||
typedef ThreadQueue<ScopeRenderData *> ScopeRenderDataQueue;
|
typedef ThreadQueue<ScopeRenderData *> ScopeRenderDataQueue;
|
||||||
|
|
||||||
class ScopeVisualProcessor : public VisualProcessor<AudioThreadInputQueue, ScopeRenderDataQueue, ScopeRenderData> {
|
class ScopeVisualProcessor : public VisualProcessor<AudioThreadInput, ScopeRenderData> {
|
||||||
protected:
|
protected:
|
||||||
virtual void process() {
|
virtual void process() {
|
||||||
if (isOutputEmpty()) {
|
if (isOutputEmpty()) {
|
||||||
|
@ -5,30 +5,30 @@
|
|||||||
#include "IOThread.h"
|
#include "IOThread.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
template<class InputQueueType = ThreadQueueBase, class OutputQueueType = ThreadQueueBase, class OutputDataType = ReferenceCounter>
|
template<class InputDataType = ReferenceCounter, class OutputDataType = ReferenceCounter>
|
||||||
class VisualProcessor {
|
class VisualProcessor {
|
||||||
public:
|
public:
|
||||||
virtual ~VisualProcessor() {
|
virtual ~VisualProcessor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setInput(InputQueueType *vis_in) {
|
void setInput(ThreadQueue<InputDataType *> *vis_in) {
|
||||||
busy_update.lock();
|
busy_update.lock();
|
||||||
input = vis_in;
|
input = vis_in;
|
||||||
busy_update.unlock();
|
busy_update.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void attachOutput(OutputQueueType *vis_out) {
|
void attachOutput(ThreadQueue<OutputDataType *> *vis_out) {
|
||||||
// attach an output queue
|
// attach an output queue
|
||||||
busy_update.lock();
|
busy_update.lock();
|
||||||
outputs.push_back(vis_out);
|
outputs.push_back(vis_out);
|
||||||
busy_update.unlock();
|
busy_update.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeOutput(OutputQueueType *vis_out) {
|
void removeOutput(ThreadQueue<OutputDataType *> *vis_out) {
|
||||||
// remove an output queue
|
// remove an output queue
|
||||||
busy_update.lock();
|
busy_update.lock();
|
||||||
typename std::vector<OutputQueueType *>::iterator i = std::find(outputs.begin(), outputs.end(), vis_out);
|
typename std::vector<ThreadQueue<OutputDataType *> *>::iterator i = std::find(outputs.begin(), outputs.end(), vis_out);
|
||||||
if (i != outputs.end()) {
|
if (i != outputs.end()) {
|
||||||
outputs.erase(i);
|
outputs.erase(i);
|
||||||
}
|
}
|
||||||
@ -79,23 +79,23 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputQueueType *input;
|
ThreadQueue<InputDataType *> *input;
|
||||||
std::vector<OutputQueueType *> outputs;
|
std::vector<ThreadQueue<OutputDataType *> *> outputs;
|
||||||
typename std::vector<OutputQueueType *>::iterator outputs_i;
|
typename std::vector<ThreadQueue<OutputDataType *> *>::iterator outputs_i;
|
||||||
std::mutex busy_update;
|
std::mutex busy_update;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<class QueueType = ThreadQueueBase, class OutputDataType = ReferenceCounter>
|
template<class InputDataType = ReferenceCounter, class OutputDataType = ReferenceCounter>
|
||||||
class VisualDataDistributor : public VisualProcessor<QueueType, QueueType, OutputDataType> {
|
class VisualDataDistributor : public VisualProcessor<InputDataType, OutputDataType> {
|
||||||
protected:
|
protected:
|
||||||
void process() {
|
void process() {
|
||||||
|
|
||||||
while (!VisualProcessor<QueueType, QueueType, OutputDataType>::input->empty()) {
|
while (!VisualProcessor<InputDataType, OutputDataType>::input->empty()) {
|
||||||
ReferenceCounter *inp;
|
ReferenceCounter *inp;
|
||||||
VisualProcessor<QueueType, QueueType, OutputDataType>::input->pop(inp);
|
VisualProcessor<InputDataType, OutputDataType>::input->pop(inp);
|
||||||
if (inp) {
|
if (inp) {
|
||||||
VisualProcessor<QueueType, QueueType, OutputDataType>::distribute(inp);
|
VisualProcessor<InputDataType, OutputDataType>::distribute(inp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,12 +212,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the queue is empty.
|
* Check if the queue is full.
|
||||||
* \return true if queue is empty.
|
* \return true if queue is full.
|
||||||
*/
|
*/
|
||||||
bool full() const {
|
bool full() const {
|
||||||
std::lock_guard < std::mutex > lock(m_mutex);
|
std::lock_guard < std::mutex > lock(m_mutex);
|
||||||
return m_queue.size() >= m_max_num_items;
|
return (m_max_num_items != 0) && (m_queue.size() >= m_max_num_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user