GLScope redesign: DoubleBufferSimple: replaced current iterator by current position

pull/916/head
f4exb 2021-05-31 18:36:04 +02:00
rodzic ef4a13f31d
commit 657d2d5996
3 zmienionych plików z 34 dodań i 42 usunięć

Wyświetl plik

@ -318,7 +318,7 @@ void ScopeVis::processTrace(const std::vector<SampleVector::const_iterator>& vbe
// memory storage
m_traceDiscreteMemory.current().write(begin, end);
m_traceDiscreteMemory.current().write(begin, length);
// Removed in 4.2.4 may cause trigger bug
// if (m_traceDiscreteMemory.current().absoluteFill() < m_traceSize)

Wyświetl plik

@ -36,6 +36,7 @@
#include "util/message.h"
#include "util/messagequeue.h"
#include "util/doublebuffer.h"
#include "util/doublebuffermultiple.h"
class GLScopeInterface;
@ -542,12 +543,8 @@ private:
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) {
m_traceBuffer.write(begin, begin + nbSamples);
m_traceBuffer.write(begin, nbSamples);
}
unsigned int absoluteFill() const {
@ -634,8 +631,10 @@ private:
{
uint32_t nextMemIndex = m_currentMemIndex < (m_memSize-1) ? m_currentMemIndex+1 : 0;
m_traceBackBuffers[nextMemIndex].reset();
m_traceBackBuffers[nextMemIndex].write(m_traceBackBuffers[m_currentMemIndex].m_endPoint - samplesToReport,
m_traceBackBuffers[m_currentMemIndex].m_endPoint);
m_traceBackBuffers[nextMemIndex].write(
m_traceBackBuffers[m_currentMemIndex].m_endPoint - samplesToReport,
samplesToReport
);
m_currentMemIndex = nextMemIndex;
return m_traceBackBuffers[m_currentMemIndex]; // new trace
}

Wyświetl plik

@ -32,7 +32,7 @@ public:
DoubleBufferSimple()
{
m_size = 0;
m_current = m_data.end();
m_currentPosition = 0;
}
~DoubleBufferSimple() {}
@ -41,7 +41,7 @@ public:
{
m_size = other.m_size;
m_data = other.m_data;
m_current = m_data.begin();
m_currentPosition = 0;
}
DoubleBufferSimple& operator=(const DoubleBufferSimple& other)
@ -52,7 +52,7 @@ public:
m_size = other.m_size;
m_data = other.m_data;
m_current = m_data.begin();
m_currentPosition = 0;
return *this;
}
@ -60,41 +60,34 @@ public:
{
m_size = 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)
{
typename std::vector<T>::const_iterator end = cend;
void write(const typename std::vector<T>::const_iterator& begin, int length)
{
int insize = length > m_size ? m_size : length;
if ((end - begin) > m_size)
{
end = begin + m_size;
}
std::copy(begin, begin + insize, m_data.begin() + m_currentPosition);
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);
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>::iterator getCurrent() { return m_data.begin() + m_currentPosition + m_size; }
typename std::vector<T>::const_iterator begin() const { return m_data.begin(); }
typename std::vector<T>::iterator begin() { return m_data.begin(); }
unsigned int absoluteFill() const { return m_current - m_data.begin(); }
void reset() { m_current = m_data.begin(); }
unsigned int absoluteFill() const { return m_currentPosition; }
void reset() { m_currentPosition = 0; }
QByteArray serialize() const
{
@ -102,7 +95,7 @@ public:
QByteArray buf(reinterpret_cast<const char*>(m_data.data()), m_data.size()*sizeof(T));
s.writeS32(1, m_size);
s.writeU32(2, m_current - m_data.begin());
s.writeU32(2, m_currentPosition);
s.writeBlob(3, buf);
return s.final();
@ -124,7 +117,7 @@ public:
d.readS32(1, &m_size, m_data.size()/2);
m_data.resize(2*m_size);
d.readU32(2, &tmpUInt, 0);
m_current = m_data.begin() + tmpUInt;
m_currentPosition = tmpUInt;
d.readBlob(3, &buf);
//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
@ -141,7 +134,7 @@ public:
private:
int m_size;
std::vector<T> m_data;
typename std::vector<T>::iterator m_current;
int m_currentPosition;
};
#endif /* SDRBASE_UTIL_DOUBLEBUFFER_H_ */