Skip to content

Commit

Permalink
added the stopper for infinite loop by invalid framecount
Browse files Browse the repository at this point in the history
  • Loading branch information
Fixstars-momoko committed Nov 13, 2023
1 parent 14f9078 commit bdf816d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/bb/image-io/rt_u3v.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ class U3V {
: static_cast<uint64_t>(arv_buffer_get_timestamp(bufs[cameN_idx_]) & 0x00000000FFFFFFFF);
latest_cnt = devices_[cameN_idx_].frame_count_;

int internal_count = 0;
int max_internal_count = 1000;

while (frame_cnt_ >= latest_cnt) {
arv_stream_push_buffer(devices_[cameN_idx_].stream_, bufs[cameN_idx_]);
cameN_idx_ = (cameN_idx_+1) >= num_device ? 0 : cameN_idx_+1;
Expand All @@ -392,6 +395,10 @@ class U3V {
? static_cast<uint64_t>(get_frame_count_from_genDC_descriptor(bufs[cameN_idx_], devices_[cameN_idx_]))
: static_cast<uint64_t>(arv_buffer_get_timestamp(bufs[cameN_idx_]) & 0x00000000FFFFFFFF);
latest_cnt = devices_[cameN_idx_].frame_count_;
if (internal_count++ > max_internal_count){
log::error("pop_buffer(L9) The sequential invalid buffer is more than {}; Stop the pipeline.", max_internal_count);
throw ::std::runtime_error("Invalid framecount");
}
}

frame_cnt_ = latest_cnt;
Expand Down Expand Up @@ -507,6 +514,9 @@ class U3V {
: static_cast<uint64_t>(arv_buffer_get_timestamp(bufs[cameN_idx_]) & 0x00000000FFFFFFFF);
latest_cnt = devices_[cameN_idx_].frame_count_;

int internal_count = 0;
int max_internal_count = 1000;

while (frame_cnt_ >= latest_cnt) {
arv_stream_push_buffer(devices_[cameN_idx_].stream_, bufs[cameN_idx_]);
cameN_idx_ = (cameN_idx_+1) >= num_device ? 0 : cameN_idx_+1;
Expand All @@ -515,11 +525,15 @@ class U3V {
if (bufs[cameN_idx_] == nullptr){
log::error("pop_buffer(L8) failed due to timeout ({}s)", timeout2_us*1e-6f);
throw ::std::runtime_error("buffer is null");
}
}
devices_[cameN_idx_].frame_count_ = is_gendc_
? static_cast<uint64_t>(get_frame_count_from_genDC_descriptor(bufs[cameN_idx_], devices_[cameN_idx_]))
: static_cast<uint64_t>(arv_buffer_get_timestamp(bufs[cameN_idx_]) & 0x00000000FFFFFFFF);
latest_cnt = devices_[cameN_idx_].frame_count_;
if (internal_count++ > max_internal_count){
log::error("pop_buffer(L10) The sequential invalid buffer is more than {}; Stop the pipeline.", max_internal_count);
throw ::std::runtime_error("Invalid framecount");
}
}

frame_cnt_ = latest_cnt;
Expand Down

0 comments on commit bdf816d

Please sign in to comment.