mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
GLScope redesign: DoubleBufferSimple: replaced current iterator by current position
This commit is contained in:
parent
ef4a13f31d
commit
657d2d5996
@ -318,7 +318,7 @@ void ScopeVis::processTrace(const std::vector<SampleVector::const_iterator>& vbe
|
|||||||
|
|
||||||
// memory storage
|
// memory storage
|
||||||
|
|
||||||
m_traceDiscreteMemory.current().write(begin, end);
|
m_traceDiscreteMemory.current().write(begin, length);
|
||||||
|
|
||||||
// Removed in 4.2.4 may cause trigger bug
|
// Removed in 4.2.4 may cause trigger bug
|
||||||
// if (m_traceDiscreteMemory.current().absoluteFill() < m_traceSize)
|
// if (m_traceDiscreteMemory.current().absoluteFill() < m_traceSize)
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "util/message.h"
|
#include "util/message.h"
|
||||||
#include "util/messagequeue.h"
|
#include "util/messagequeue.h"
|
||||||
#include "util/doublebuffer.h"
|
#include "util/doublebuffer.h"
|
||||||
|
#include "util/doublebuffermultiple.h"
|
||||||
|
|
||||||
|
|
||||||
class GLScopeInterface;
|
class GLScopeInterface;
|
||||||
@ -542,12 +543,8 @@ private:
|
|||||||
m_traceBuffer.reset();
|
m_traceBuffer.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(const SampleVector::const_iterator begin, const SampleVector::const_iterator end) {
|
|
||||||
m_traceBuffer.write(begin, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
void write(const SampleVector::const_iterator begin, int nbSamples) {
|
void write(const SampleVector::const_iterator begin, int nbSamples) {
|
||||||
m_traceBuffer.write(begin, begin + nbSamples);
|
m_traceBuffer.write(begin, nbSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int absoluteFill() const {
|
unsigned int absoluteFill() const {
|
||||||
@ -634,8 +631,10 @@ private:
|
|||||||
{
|
{
|
||||||
uint32_t nextMemIndex = m_currentMemIndex < (m_memSize-1) ? m_currentMemIndex+1 : 0;
|
uint32_t nextMemIndex = m_currentMemIndex < (m_memSize-1) ? m_currentMemIndex+1 : 0;
|
||||||
m_traceBackBuffers[nextMemIndex].reset();
|
m_traceBackBuffers[nextMemIndex].reset();
|
||||||
m_traceBackBuffers[nextMemIndex].write(m_traceBackBuffers[m_currentMemIndex].m_endPoint - samplesToReport,
|
m_traceBackBuffers[nextMemIndex].write(
|
||||||
m_traceBackBuffers[m_currentMemIndex].m_endPoint);
|
m_traceBackBuffers[m_currentMemIndex].m_endPoint - samplesToReport,
|
||||||
|
samplesToReport
|
||||||
|
);
|
||||||
m_currentMemIndex = nextMemIndex;
|
m_currentMemIndex = nextMemIndex;
|
||||||
return m_traceBackBuffers[m_currentMemIndex]; // new trace
|
return m_traceBackBuffers[m_currentMemIndex]; // new trace
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
DoubleBufferSimple()
|
DoubleBufferSimple()
|
||||||
{
|
{
|
||||||
m_size = 0;
|
m_size = 0;
|
||||||
m_current = m_data.end();
|
m_currentPosition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~DoubleBufferSimple() {}
|
~DoubleBufferSimple() {}
|
||||||
@ -41,7 +41,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_size = other.m_size;
|
m_size = other.m_size;
|
||||||
m_data = other.m_data;
|
m_data = other.m_data;
|
||||||
m_current = m_data.begin();
|
m_currentPosition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoubleBufferSimple& operator=(const DoubleBufferSimple& other)
|
DoubleBufferSimple& operator=(const DoubleBufferSimple& other)
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
m_size = other.m_size;
|
m_size = other.m_size;
|
||||||
m_data = other.m_data;
|
m_data = other.m_data;
|
||||||
m_current = m_data.begin();
|
m_currentPosition = 0;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,41 +60,34 @@ public:
|
|||||||
{
|
{
|
||||||
m_size = size;
|
m_size = size;
|
||||||
m_data.resize(2*size);
|
m_data.resize(2*size);
|
||||||
m_current = m_data.begin();
|
m_currentPosition = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(const typename std::vector<T>::const_iterator& begin, const typename std::vector<T>::const_iterator& cend)
|
void write(const typename std::vector<T>::const_iterator& begin, int length)
|
||||||
{
|
{
|
||||||
typename std::vector<T>::const_iterator end = cend;
|
int insize = length > m_size ? m_size : length;
|
||||||
|
|
||||||
if ((end - begin) > m_size)
|
std::copy(begin, begin + insize, m_data.begin() + m_currentPosition);
|
||||||
{
|
|
||||||
end = begin + m_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
int insize = end - begin;
|
if ((m_currentPosition + insize) > m_size)
|
||||||
|
{
|
||||||
|
int sizeLeft = m_size - m_currentPosition;
|
||||||
|
std::copy(begin, begin + sizeLeft, m_data.begin() + m_currentPosition + m_size);
|
||||||
|
std::copy(begin + sizeLeft, begin + insize, m_data.begin());
|
||||||
|
m_currentPosition = insize - sizeLeft;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::copy(begin, begin + insize, m_data.begin() + m_currentPosition + m_size);
|
||||||
|
m_currentPosition += insize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::copy(begin, end, m_current);
|
typename std::vector<T>::iterator getCurrent() { return m_data.begin() + m_currentPosition + m_size; }
|
||||||
|
|
||||||
if (((m_current - m_data.begin()) + insize) > m_size)
|
|
||||||
{
|
|
||||||
int sizeLeft = m_size - (m_current - m_data.begin());
|
|
||||||
std::copy(begin, begin + sizeLeft, m_current + m_size);
|
|
||||||
std::copy(begin + sizeLeft, end, m_data.begin());
|
|
||||||
m_current = m_data.begin() + (insize - sizeLeft);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::copy(begin, end, m_current + m_size);
|
|
||||||
m_current += insize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typename std::vector<T>::iterator getCurrent() const { return m_current + m_size; }
|
|
||||||
typename std::vector<T>::const_iterator begin() const { return m_data.begin(); }
|
typename std::vector<T>::const_iterator begin() const { return m_data.begin(); }
|
||||||
typename std::vector<T>::iterator begin() { return m_data.begin(); }
|
typename std::vector<T>::iterator begin() { return m_data.begin(); }
|
||||||
unsigned int absoluteFill() const { return m_current - m_data.begin(); }
|
unsigned int absoluteFill() const { return m_currentPosition; }
|
||||||
void reset() { m_current = m_data.begin(); }
|
void reset() { m_currentPosition = 0; }
|
||||||
|
|
||||||
QByteArray serialize() const
|
QByteArray serialize() const
|
||||||
{
|
{
|
||||||
@ -102,7 +95,7 @@ public:
|
|||||||
|
|
||||||
QByteArray buf(reinterpret_cast<const char*>(m_data.data()), m_data.size()*sizeof(T));
|
QByteArray buf(reinterpret_cast<const char*>(m_data.data()), m_data.size()*sizeof(T));
|
||||||
s.writeS32(1, m_size);
|
s.writeS32(1, m_size);
|
||||||
s.writeU32(2, m_current - m_data.begin());
|
s.writeU32(2, m_currentPosition);
|
||||||
s.writeBlob(3, buf);
|
s.writeBlob(3, buf);
|
||||||
|
|
||||||
return s.final();
|
return s.final();
|
||||||
@ -124,7 +117,7 @@ public:
|
|||||||
d.readS32(1, &m_size, m_data.size()/2);
|
d.readS32(1, &m_size, m_data.size()/2);
|
||||||
m_data.resize(2*m_size);
|
m_data.resize(2*m_size);
|
||||||
d.readU32(2, &tmpUInt, 0);
|
d.readU32(2, &tmpUInt, 0);
|
||||||
m_current = m_data.begin() + tmpUInt;
|
m_currentPosition = tmpUInt;
|
||||||
d.readBlob(3, &buf);
|
d.readBlob(3, &buf);
|
||||||
//qDebug("DoubleBufferSimple::deserialize: m_data.size(): %u buf.size(): %d", m_data.size(), buf.size());
|
//qDebug("DoubleBufferSimple::deserialize: m_data.size(): %u buf.size(): %d", m_data.size(), buf.size());
|
||||||
//std::copy(reinterpret_cast<char *>(m_data.data()), buf.data(), buf.data() + buf.size()); // bug
|
//std::copy(reinterpret_cast<char *>(m_data.data()), buf.data(), buf.data() + buf.size()); // bug
|
||||||
@ -141,7 +134,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
int m_size;
|
int m_size;
|
||||||
std::vector<T> m_data;
|
std::vector<T> m_data;
|
||||||
typename std::vector<T>::iterator m_current;
|
int m_currentPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SDRBASE_UTIL_DOUBLEBUFFER_H_ */
|
#endif /* SDRBASE_UTIL_DOUBLEBUFFER_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user