diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-04-11 16:33:13 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-05-03 10:05:48 -0700 |
commit | 3a4073799db9cf314b57eb20bb8f8fc085a76631 (patch) | |
tree | 7e3499be0bd967c93285941c237d84c091f8b785 | |
parent | fe4a53df93fa02403b4ebdbda10b6a18d86efd07 (diff) | |
download | uhd-3a4073799db9cf314b57eb20bb8f8fc085a76631.tar.gz uhd-3a4073799db9cf314b57eb20bb8f8fc085a76631.tar.bz2 uhd-3a4073799db9cf314b57eb20bb8f8fc085a76631.zip |
examples: Avoid calculating dropped samples for negative offsets
There are cases when the first sample after an overrun has an earlier
timestamp than the timestamp of the error package. In this case,
benchmark_rate would incorrectly determine the number of dropped
samples, causing it to display a very large number.
This is not a fix of the negative offset issue, but will avoid
displaying overly pessimistic numbers dropped samples.
An error message is still displayed when this happens, which aids in
debugging this situation.
-rw-r--r-- | host/examples/benchmark_rate.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 3b5439510..88be83a7b 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -118,7 +118,16 @@ void benchmark_rx_rate( case uhd::rx_metadata_t::ERROR_CODE_NONE: if (had_an_overflow) { had_an_overflow = false; - num_dropped_samps += (md.time_spec - last_time).to_ticks(rate); + const long dropped_samps = + (md.time_spec - last_time).to_ticks(rate); + if (dropped_samps < 0) { + std::cerr + << "[" << NOW() << "] Timestamp after overrun recovery " + "ahead of error timestamp! Unable to calculate " + "number of dropped samples." + "(Delta: " << dropped_samps << " ticks)\n"; + } + num_dropped_samps += std::max<long>(1, dropped_samps); } if ((burst_timer_elapsed or stop_called) and md.end_of_burst) { return; |