diff --git a/sdrgui/dsp/scopevis.cpp b/sdrgui/dsp/scopevis.cpp index f5abef980..c64165386 100644 --- a/sdrgui/dsp/scopevis.cpp +++ b/sdrgui/dsp/scopevis.cpp @@ -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; diff --git a/sdrgui/dsp/scopevis.h b/sdrgui/dsp/scopevis.h index 34ff6a387..489fc27ac 100644 --- a/sdrgui/dsp/scopevis.h +++ b/sdrgui/dsp/scopevis.h @@ -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 diff --git a/sdrgui/dsp/spectrumscopecombovis.cpp b/sdrgui/dsp/spectrumscopecombovis.cpp index 627be45a5..e7b6e2feb 100644 --- a/sdrgui/dsp/spectrumscopecombovis.cpp +++ b/sdrgui/dsp/spectrumscopecombovis.cpp @@ -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() diff --git a/sdrgui/dsp/spectrumvis.cpp b/sdrgui/dsp/spectrumvis.cpp index 0fbeb0384..9f52ce9b3 100644 --- a/sdrgui/dsp/spectrumvis.cpp +++ b/sdrgui/dsp/spectrumvis.cpp @@ -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::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()