Scope + Spectrum: fixed trigger point to avoid invalid iterator

pull/263/head
f4exb 2018-11-21 08:58:33 +01:00
rodzic 635a1bd34b
commit f1eeed38da
4 zmienionych plików z 25 dodań i 15 usunięć

Wyświetl plik

@ -229,19 +229,19 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
}
if (m_freeRun) {
m_triggerPoint = cbegin;
m_triggerLocation = end - cbegin;
}
else if (m_triggerState == TriggerTriggered) {
m_triggerPoint = cbegin;
m_triggerLocation = end - cbegin;
}
else if (m_triggerState == TriggerUntriggered) {
m_triggerPoint = end;
m_triggerLocation = 0;
}
else if (m_triggerWaitForReset) {
m_triggerPoint = end;
m_triggerLocation = 0;
}
else {
m_triggerPoint = cbegin;
m_triggerLocation = end - cbegin;
}
SampleVector::const_iterator begin(cbegin);
@ -254,7 +254,7 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
triggerPointToEnd = -1;
processTrace(begin, end, triggerPointToEnd); // use all buffer
if (triggerPointToEnd >= 0) {
m_triggerPoint = end - triggerPointToEnd;
m_triggerLocation = triggerPointToEnd;
}
begin = end; // effectively breaks out the loop
@ -264,7 +264,8 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
triggerPointToEnd = -1;
processTrace(begin, begin + m_traceSize, triggerPointToEnd); // use part of buffer to fit trace size
if (triggerPointToEnd >= 0) {
m_triggerPoint = begin + m_traceSize -triggerPointToEnd;
//m_triggerPoint = begin + m_traceSize - triggerPointToEnd;
m_triggerLocation = triggerPointToEnd - m_traceSize;
}
begin += m_traceSize;

Wyświetl plik

@ -243,7 +243,7 @@ public:
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& message);
SampleVector::const_iterator getTriggerPoint() const { return m_triggerPoint; }
int getTriggerLocation() const { return m_triggerLocation; }
private:
// === messages ===
@ -1132,7 +1132,7 @@ private:
uint32_t m_timeBase; //!< Trace display time divisor
uint32_t m_timeOfsProMill; //!< Start trace shift in 1/1000 trace size
bool m_traceStart; //!< Trace is at start point
SampleVector::const_iterator m_triggerPoint; //!< Trigger start location in the samples vector
int m_triggerLocation; //!< Trigger location from end point
int m_sampleRate; //!< Actual sample rate being used
int m_liveSampleRate; //!< Sample rate in live mode
int m_liveLog2Decim; //!< Sample rate decimation log2 in live mode

Wyświetl plik

@ -18,8 +18,14 @@ void SpectrumScopeComboVis::feed(const SampleVector::const_iterator& begin, cons
{
(void) positiveOnly;
m_scopeVis->feed(begin, end, false);
SampleVector::const_iterator triggerPoint = m_scopeVis->getTriggerPoint();
m_spectrumVis->feedTriggered(triggerPoint, end, positiveOnly);
//SampleVector::const_iterator triggerPoint = m_scopeVis->getTriggerPoint();
//m_spectrumVis->feedTriggered(triggerPoint, end, positiveOnly);
int triggerPointLocation = m_scopeVis->getTriggerLocation();
if ((triggerPointLocation >= 0) && (triggerPointLocation < end - begin)) {
m_spectrumVis->feedTriggered(end - triggerPointLocation, end, positiveOnly);
} else {
m_spectrumVis->feedTriggered(begin, end, positiveOnly);
}
}
void SpectrumScopeComboVis::start()

Wyświetl plik

@ -78,11 +78,14 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
{
// if no visualisation is set, send the samples to /dev/null
if(m_glSpectrum == 0)
{
if (m_glSpectrum == 0) {
return;
}
if (!m_mutex.tryLock(0)) { // prevent conflicts with configuration process
return;
}
SampleVector::const_iterator begin(cbegin);
while (begin < end)
@ -92,8 +95,6 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
if (todo >= samplesNeeded)
{
QMutexLocker mutexLocker(&m_mutex);
// fill up the buffer
std::vector<Complex>::iterator it = m_fftBuffer.begin() + m_fftBufferFill;
@ -296,6 +297,8 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
m_needMoreSamples = true;
}
}
m_mutex.unlock();
}
void SpectrumVis::start()