tex update lock, VisualData"Re"Distributor

This commit is contained in:
Charles J. Cliffe 2015-09-10 21:48:18 -04:00
parent 4301d0d434
commit 0a6d409065
5 changed files with 31 additions and 4 deletions

View File

@ -298,7 +298,7 @@ SpectrumVisualProcessor *CubicSDR::getDemodSpectrumProcessor() {
return demodVisualThread->getProcessor(); return demodVisualThread->getProcessor();
} }
VisualDataDistributor<DemodulatorThreadIQData> *CubicSDR::getSpectrumDistributor() { VisualDataReDistributor<DemodulatorThreadIQData> *CubicSDR::getSpectrumDistributor() {
return &spectrumDistributor; return &spectrumDistributor;
} }

View File

@ -60,7 +60,7 @@ public:
ScopeVisualProcessor *getScopeProcessor(); ScopeVisualProcessor *getScopeProcessor();
SpectrumVisualProcessor *getSpectrumProcessor(); SpectrumVisualProcessor *getSpectrumProcessor();
SpectrumVisualProcessor *getDemodSpectrumProcessor(); SpectrumVisualProcessor *getDemodSpectrumProcessor();
VisualDataDistributor<DemodulatorThreadIQData> *getSpectrumDistributor(); VisualDataReDistributor<DemodulatorThreadIQData> *getSpectrumDistributor();
DemodulatorThreadOutputQueue* getAudioVisualQueue(); DemodulatorThreadOutputQueue* getAudioVisualQueue();
DemodulatorThreadInputQueue* getIQVisualQueue(); DemodulatorThreadInputQueue* getIQVisualQueue();
@ -111,7 +111,7 @@ private:
ScopeVisualProcessor scopeProcessor; ScopeVisualProcessor scopeProcessor;
VisualDataDistributor<DemodulatorThreadIQData> spectrumDistributor; VisualDataReDistributor<DemodulatorThreadIQData> spectrumDistributor;
std::thread *t_SDR; std::thread *t_SDR;
std::thread *t_PostSDR; std::thread *t_PostSDR;

View File

@ -107,3 +107,25 @@ protected:
} }
}; };
template<class OutputDataType = ReferenceCounter>
class VisualDataReDistributor : public VisualProcessor<OutputDataType, OutputDataType> {
protected:
void process() {
while (!VisualProcessor<OutputDataType, OutputDataType>::input->empty()) {
if (!VisualProcessor<OutputDataType, OutputDataType>::isAnyOutputEmpty()) {
return;
}
OutputDataType *inp;
VisualProcessor<OutputDataType, OutputDataType>::input->pop(inp);
if (inp) {
OutputDataType *outp = buffers.getBuffer();
(*outp) = (*inp);
inp->decRefCount();
VisualProcessor<OutputDataType, OutputDataType>::distribute(outp);
}
}
}
ReBuffer<OutputDataType> buffers;
};

View File

@ -99,6 +99,7 @@ void WaterfallCanvas::processInputQueue() {
if (linesPerSecond) { if (linesPerSecond) {
if (lpsIndex >= targetVis) { if (lpsIndex >= targetVis) {
tex_update.lock();
while (lpsIndex >= targetVis) { while (lpsIndex >= targetVis) {
SpectrumVisualData *vData; SpectrumVisualData *vData;
if (!visualDataQueue.empty()) { if (!visualDataQueue.empty()) {
@ -115,6 +116,7 @@ void WaterfallCanvas::processInputQueue() {
break; break;
} }
} }
tex_update.unlock();
} }
} }
if (processed) { if (processed) {
@ -235,7 +237,9 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->BeginDraw(0,0,0); glContext->BeginDraw(0,0,0);
waterfallPanel.calcTransform(CubicVR::mat4::identity()); waterfallPanel.calcTransform(CubicVR::mat4::identity());
tex_update.lock();
waterfallPanel.draw(); waterfallPanel.draw();
tex_update.unlock();
std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators(); std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators();
@ -314,7 +318,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->EndDraw(); glContext->EndDraw();
glFlush(); // glFlush();
SwapBuffers(); SwapBuffers();
} }

View File

@ -72,6 +72,7 @@ private:
Timer gTimer, testTimer; Timer gTimer, testTimer;
double lpsIndex; double lpsIndex;
bool preBuf; bool preBuf;
std::mutex tex_update;
// event table // event table
wxDECLARE_EVENT_TABLE(); wxDECLARE_EVENT_TABLE();
}; };