mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
uhd: Check for overflow after timeout buff read
Error processing has been moved to another thread, so it's possible that consecutive recv calls may miss the signalling that an overflow occurred. We have no guarantee that the flag had been set by the time the second recv call to find the errors occurs. This adds another check for an overflow after calling _get_aligned_buffs with a min 1ms timeout. Hopefully this is long enough for the error to propogate, but it's not guaranteed. Signed-off-by: Steven Koo <steven.koo@ni.com>
This commit is contained in:
parent
92cb632ce1
commit
a2f10eed67
@ -136,11 +136,6 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nsamps_per_buff == 0) {
|
||||
metadata.reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
const int32_t timeout_ms = static_cast<int32_t>(timeout * 1000);
|
||||
|
||||
detail::eov_data_wrapper eov_positions(metadata);
|
||||
|
||||
@ -213,21 +213,23 @@ public:
|
||||
auto result = _get_aligned_buffs(0);
|
||||
|
||||
if (result == get_aligned_buffs_t::TIMEOUT) {
|
||||
if (_stopped_due_to_overrun) {
|
||||
// An overrun occurred and the user has read all the packets
|
||||
// that were buffered prior to the overrun. Call the overrun
|
||||
// handler and return overrun error.
|
||||
_handle_overrun();
|
||||
std::tie(metadata.has_time_spec, metadata.time_spec) =
|
||||
_last_read_time_info.get_next_packet_time(_samp_rate);
|
||||
metadata.error_code = rx_metadata_t::ERROR_CODE_OVERFLOW;
|
||||
_stopped_due_to_overrun = false;
|
||||
return 0;
|
||||
} else {
|
||||
if (!_stopped_due_to_overrun) {
|
||||
// Packets were not available with zero timeout, wait for them
|
||||
// to arrive using the specified timeout.
|
||||
result = _get_aligned_buffs(timeout_ms);
|
||||
if (_stopped_due_to_late_cmd) {
|
||||
result = _get_aligned_buffs(std::max(1,timeout_ms));
|
||||
}
|
||||
if (result == get_aligned_buffs_t::TIMEOUT) {
|
||||
if (_stopped_due_to_overrun) {
|
||||
// An overrun occurred and the user has read all the packets
|
||||
// that were buffered prior to the overrun. Call the overrun
|
||||
// handler and return overrun error.
|
||||
_handle_overrun();
|
||||
std::tie(metadata.has_time_spec, metadata.time_spec) =
|
||||
_last_read_time_info.get_next_packet_time(_samp_rate);
|
||||
metadata.error_code = rx_metadata_t::ERROR_CODE_OVERFLOW;
|
||||
_stopped_due_to_overrun = false;
|
||||
return 0;
|
||||
} else if (_stopped_due_to_late_cmd) {
|
||||
metadata.has_time_spec = false;
|
||||
metadata.error_code = rx_metadata_t::ERROR_CODE_LATE_COMMAND;
|
||||
_stopped_due_to_late_cmd = false;
|
||||
|
||||
@ -238,12 +238,6 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Just return if no samples requested
|
||||
if (nsamps_per_buff == 0) {
|
||||
metadata.reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t accum_num_samps =
|
||||
recv_one_packet(buffs, nsamps_per_buff, metadata, timeout);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user