mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-04 08:21:16 -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;
|
||||
|
||||
class ScopeVisualProcessor : public VisualProcessor<AudioThreadInputQueue, ScopeRenderDataQueue, ScopeRenderData> {
|
||||
class ScopeVisualProcessor : public VisualProcessor<AudioThreadInput, ScopeRenderData> {
|
||||
protected:
|
||||
virtual void process() {
|
||||
if (isOutputEmpty()) {
|
||||
|
@ -5,30 +5,30 @@
|
||||
#include "IOThread.h"
|
||||
#include <algorithm>
|
||||
|
||||
template<class InputQueueType = ThreadQueueBase, class OutputQueueType = ThreadQueueBase, class OutputDataType = ReferenceCounter>
|
||||
template<class InputDataType = ReferenceCounter, class OutputDataType = ReferenceCounter>
|
||||
class VisualProcessor {
|
||||
public:
|
||||
virtual ~VisualProcessor() {
|
||||
|
||||
}
|
||||
|
||||
void setInput(InputQueueType *vis_in) {
|
||||
void setInput(ThreadQueue<InputDataType *> *vis_in) {
|
||||
busy_update.lock();
|
||||
input = vis_in;
|
||||
busy_update.unlock();
|
||||
}
|
||||
|
||||
void attachOutput(OutputQueueType *vis_out) {
|
||||
void attachOutput(ThreadQueue<OutputDataType *> *vis_out) {
|
||||
// attach an output queue
|
||||
busy_update.lock();
|
||||
outputs.push_back(vis_out);
|
||||
busy_update.unlock();
|
||||
}
|
||||
|
||||
void removeOutput(OutputQueueType *vis_out) {
|
||||
void removeOutput(ThreadQueue<OutputDataType *> *vis_out) {
|
||||
// remove an output queue
|
||||
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()) {
|
||||
outputs.erase(i);
|
||||
}
|
||||
@ -79,23 +79,23 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
InputQueueType *input;
|
||||
std::vector<OutputQueueType *> outputs;
|
||||
typename std::vector<OutputQueueType *>::iterator outputs_i;
|
||||
ThreadQueue<InputDataType *> *input;
|
||||
std::vector<ThreadQueue<OutputDataType *> *> outputs;
|
||||
typename std::vector<ThreadQueue<OutputDataType *> *>::iterator outputs_i;
|
||||
std::mutex busy_update;
|
||||
};
|
||||
|
||||
|
||||
template<class QueueType = ThreadQueueBase, class OutputDataType = ReferenceCounter>
|
||||
class VisualDataDistributor : public VisualProcessor<QueueType, QueueType, OutputDataType> {
|
||||
template<class InputDataType = ReferenceCounter, class OutputDataType = ReferenceCounter>
|
||||
class VisualDataDistributor : public VisualProcessor<InputDataType, OutputDataType> {
|
||||
protected:
|
||||
void process() {
|
||||
|
||||
while (!VisualProcessor<QueueType, QueueType, OutputDataType>::input->empty()) {
|
||||
while (!VisualProcessor<InputDataType, OutputDataType>::input->empty()) {
|
||||
ReferenceCounter *inp;
|
||||
VisualProcessor<QueueType, QueueType, OutputDataType>::input->pop(inp);
|
||||
VisualProcessor<InputDataType, OutputDataType>::input->pop(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.
|
||||
* \return true if queue is empty.
|
||||
* Check if the queue is full.
|
||||
* \return true if queue is full.
|
||||
*/
|
||||
bool full() const {
|
||||
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