diff --git a/plugins/channelrx/demodadsb/adsbdemodsink.cpp b/plugins/channelrx/demodadsb/adsbdemodsink.cpp index fa599f1e0..024643769 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsink.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodsink.cpp @@ -121,10 +121,14 @@ void ADSBDemodSink::feed(const SampleVector::const_iterator& begin, const Sample void ADSBDemodSink::processOneSample(Real magsq) { - m_magsqSum += magsq; - if (magsq > m_magsqPeak) - m_magsqPeak = magsq; - m_magsqCount++; + { + QMutexLocker locker(&m_magsqMutex); + + m_magsqSum += magsq; + if (magsq > m_magsqPeak) + m_magsqPeak = magsq; + m_magsqCount++; + } m_sampleBuffer[m_writeBuffer][m_writeIdx] = magsq; m_writeIdx++; if (!m_bufferDateTimeValid[m_writeBuffer]) diff --git a/plugins/channelrx/demodadsb/adsbdemodsink.h b/plugins/channelrx/demodadsb/adsbdemodsink.h index c57e312d5..fc458bf25 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsink.h +++ b/plugins/channelrx/demodadsb/adsbdemodsink.h @@ -35,6 +35,8 @@ public: void getMagSqLevels(double& avg, double& peak, int& nbSamples) { + QMutexLocker locker(&m_magsqMutex); + if (m_magsqCount > 0) { m_magsq = m_magsqSum / m_magsqCount; @@ -107,6 +109,8 @@ private: int m_magsqCount; MagSqLevelsStore m_magSqLevelStore; + QMutex m_magsqMutex; + MessageQueue *m_messageQueueToGUI; MessageQueue *m_messageQueueToWorker;