1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04:00

glScope: use atomic variable for the data changed indicator

This commit is contained in:
f4exb
2018-11-20 08:00:19 +01:00
parent af9c693412
commit 02a6cee99f
2 changed files with 17 additions and 15 deletions
+16 -14
View File
@@ -33,7 +33,7 @@ GLScope::GLScope(QWidget* parent) :
m_processingTraceIndex(-1),
m_bufferIndex(0),
m_displayMode(DisplayX),
m_dataChanged(false),
m_dataChanged(0),
m_configChanged(false),
m_sampleRate(0),
m_timeOfsProMill(0),
@@ -103,11 +103,13 @@ void GLScope::newTraces(std::vector<float *>* traces)
{
if (traces->size() > 0)
{
if(!m_mutex.tryLock(2))
if (!m_mutex.tryLock(2)) {
return;
}
m_traces = traces;
m_dataChanged = true;
if (m_dataChanged.testAndSetOrdered(0, 1)) {
m_traces = traces;
}
m_mutex.unlock();
}
@@ -117,12 +119,15 @@ void GLScope::newTraces(std::vector<float *>* traces, int traceIndex)
{
if (traces->size() > 0)
{
if(!m_mutex.tryLock(2))
if(!m_mutex.tryLock(2)) {
return;
}
m_processingTraceIndex.store(traceIndex);
m_traces = &traces[traceIndex];
m_dataChanged = true;
if (m_dataChanged.testAndSetOrdered(0, 1))
{
m_processingTraceIndex.store(traceIndex);
m_traces = &traces[traceIndex];
}
m_mutex.unlock();
}
@@ -192,9 +197,7 @@ void GLScope::resizeGL(int width, int height)
void GLScope::paintGL()
{
if (!m_mutex.tryLock(2))
{
m_processingTraceIndex.store(-1);
if (!m_mutex.tryLock(2)) {
return;
}
@@ -205,8 +208,6 @@ void GLScope::paintGL()
// qDebug("GLScope::paintGL: m_traceCounter: %d", m_traceCounter);
// m_traceCounter = 0;
m_dataChanged = false;
QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions();
glFunctions->glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glFunctions->glClear(GL_COLOR_BUFFER_BIT);
@@ -940,6 +941,7 @@ void GLScope::paintGL()
} // trace length > 0
} // XY mixed + polar display
m_dataChanged.store(0);
m_processingTraceIndex.store(-1);
m_mutex.unlock();
}
@@ -1995,7 +1997,7 @@ void GLScope::drawChannelOverlay(
void GLScope::tick()
{
if(m_dataChanged) {
if (m_dataChanged.load()) {
update();
}
}