aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/OfdmGenerator.cpp11
-rw-r--r--src/OfdmGenerator.h2
-rw-r--r--src/PAPRStats.cpp6
-rw-r--r--src/PAPRStats.h2
4 files changed, 21 insertions, 0 deletions
diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp
index 1a819ee..b00d66b 100644
--- a/src/OfdmGenerator.cpp
+++ b/src/OfdmGenerator.cpp
@@ -187,6 +187,14 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
// For performance reasons, do not calculate MER for every symbol.
myMERCalcIndex = (myMERCalcIndex + 1) % myNbSymbols;
+ // The PAPRStats' clear() is not threadsafe, do not access it
+ // from the RC functions.
+ if (myPaprClearRequest.load()) {
+ myPaprBeforeCFR.clear();
+ myPaprAfterCFR.clear();
+ myPaprClearRequest.store(false);
+ }
+
for (size_t i = 0; i < myNbSymbols; ++i) {
myFftIn[0][0] = 0;
myFftIn[0][1] = 0;
@@ -358,12 +366,15 @@ void OfdmGenerator::set_parameter(const std::string& parameter,
if (parameter == "cfr") {
ss >> myCfr;
+ myPaprClearRequest.store(true);
}
else if (parameter == "clip") {
ss >> myCfrClip;
+ myPaprClearRequest.store(true);
}
else if (parameter == "errorclip") {
ss >> myCfrErrorClip;
+ myPaprClearRequest.store(true);
}
else if (parameter == "clip_stats" or parameter == "papr") {
throw ParameterError("Parameter '" + parameter + "' is read-only");
diff --git a/src/OfdmGenerator.h b/src/OfdmGenerator.h
index 8374cf9..cccccf5 100644
--- a/src/OfdmGenerator.h
+++ b/src/OfdmGenerator.h
@@ -37,6 +37,7 @@
#include <cstddef>
#include <vector>
#include <complex>
+#include <atomic>
typedef std::complex<float> complexf;
@@ -105,6 +106,7 @@ class OfdmGenerator : public ModCodec, public RemoteControllable
// Measure PAPR before and after CFR
PAPRStats myPaprBeforeCFR;
PAPRStats myPaprAfterCFR;
+ std::atomic<bool> myPaprClearRequest;
size_t myMERCalcIndex = 0;
std::deque<double> myMERs;
diff --git a/src/PAPRStats.cpp b/src/PAPRStats.cpp
index 2e8bca9..1a72238 100644
--- a/src/PAPRStats.cpp
+++ b/src/PAPRStats.cpp
@@ -100,6 +100,12 @@ double PAPRStats::calculate_papr() const
return 10.0 * std::log10(peak / rms2);
}
+void PAPRStats::clear()
+{
+ m_squared_peaks.clear();
+ m_squared_mean.clear();
+}
+
#if defined(TEST)
/* Test python code:
import numpy as np
diff --git a/src/PAPRStats.h b/src/PAPRStats.h
index 92e5231..86ad8b0 100644
--- a/src/PAPRStats.h
+++ b/src/PAPRStats.h
@@ -66,6 +66,8 @@ class PAPRStats
*/
double calculate_papr(void) const;
+ void clear(void);
+
private:
size_t m_num_blocks_to_accumulate;
std::deque<double> m_squared_peaks;