Fix concurrent issues in dummy radio used in nr_phy_test

This commit is contained in:
Xavier Arteaga 2022-01-19 13:12:36 +01:00 committed by Xavier Arteaga
parent 8a7a4a588d
commit 66f6c11561
1 changed files with 7 additions and 4 deletions

View File

@ -45,7 +45,7 @@ private:
std::vector<srsran_ringbuffer_t> rx_ring_buffers;
std::vector<srsran_ringbuffer_t> tx_ring_buffers;
std::mutex tx_mutex;
double srate_hz = 0.0f;
std::atomic<double> srate_hz = {0.0f};
std::atomic<float> rx_gain = {1.0f};
std::atomic<float> tx_gain = {1.0f};
cf_t* temp_buffer = nullptr;
@ -211,9 +211,12 @@ public:
uint64_t tx_time_n = srsran_timestamp_uint64(&tx_time.get(0), srate_hz);
// Check if the transmission is in the past
if (tx_time_n < tx_timestamp) {
logger.error("Error transmission in the past for %d samples", (int)(tx_timestamp - tx_time_n));
return false;
{
std::lock_guard<std::mutex> lock(tx_mutex);
if (tx_time_n < tx_timestamp) {
logger.error("Error transmission in the past for %d samples", (int)(tx_timestamp - tx_time_n));
return false;
}
}
// Advance TX to timestamp