diff --git a/src/bb/image-io/rt_u3v.h b/src/bb/image-io/rt_u3v.h index 6319e24..aeacdd8 100644 --- a/src/bb/image-io/rt_u3v.h +++ b/src/bb/image-io/rt_u3v.h @@ -25,6 +25,9 @@ namespace ion { namespace bb { namespace image_io { +#define TIMEOUT_IN_US_SHORTER 3 * 1000 * 1000 +#define TIMEOUT_IN_US_LONGER 30 * 1000 * 1000 + class U3V { protected: struct GError @@ -630,7 +633,7 @@ class U3VFakeCam : public U3V{ return *instances_[id].get(); } void get(std::vector>& outs) override { - auto timeout_us = 30 * 1000 * 1000; + auto timeout_us = TIMEOUT_IN_US_LONGER; std::vector bufs(num_sensor_); for (int i = 0;i< num_sensor_;i++){ auto size = devices_[i].u3v_payload_size_; @@ -729,7 +732,7 @@ class U3VRealCam: public U3V{ } void get(std::vector>& outs) override{ - auto timeout_us = 30 * 1000 * 1000; + auto timeout_us = TIMEOUT_IN_US_LONGER; int32_t num_device = devices_.size(); if (sim_mode_){ std::vector bufs(num_device); @@ -796,7 +799,7 @@ class U3VRealCam: public U3V{ //first buffer device_idx_ = (device_idx_ + 1) >= num_device ? 0 : device_idx_ + 1; - bufs[device_idx_] = arv_stream_timeout_pop_buffer(devices_[device_idx_].stream_, 30 * 1000 * 1000); + bufs[device_idx_] = arv_stream_timeout_pop_buffer(devices_[device_idx_].stream_, timeout_us); if (bufs[device_idx_] == nullptr) { log::error("pop_buffer(L4) failed due to timeout ({}s)", timeout_us * 1e-6f); throw ::std::runtime_error("buffer is null"); @@ -820,7 +823,7 @@ class U3VRealCam: public U3V{ while (frame_cnt_ >= latest_cnt) { arv_stream_push_buffer(devices_[device_idx_].stream_, bufs[device_idx_]); - bufs[device_idx_] = arv_stream_timeout_pop_buffer (devices_[device_idx_].stream_, 30 * 1000 * 1000); + bufs[device_idx_] = arv_stream_timeout_pop_buffer (devices_[device_idx_].stream_, timeout_us); if (bufs[device_idx_] == nullptr){ log::error("pop_buffer(L4) failed due to timeout ({}s)", timeout_us*1e-6f); throw ::std::runtime_error("buffer is null"); @@ -1186,7 +1189,7 @@ class U3VRealCam: public U3V{ } } - void consume_old_buffer(std::vector &bufs, int timeout_us = 3 * 1000 * 1000){ + void consume_old_buffer(std::vector &bufs, int timeout_us = TIMEOUT_IN_US_SHORTER){ std::vector N_output_buffers(num_sensor_); for (auto i = 0; i < num_sensor_; ++i) { int32_t num_input_buffer; @@ -1240,7 +1243,7 @@ class U3VGenDC: public U3V{ void get(std::vector& outs) override{ // TODO: Is 3 second fine? - auto timeout_us = 3 * 1000 * 1000; + auto timeout_us = TIMEOUT_IN_US_LONGER; int32_t num_device = devices_.size(); std::vector bufs(num_device); @@ -1302,7 +1305,7 @@ class U3VGenDC: public U3V{ //first buffer device_idx_ = (device_idx_+1) >= num_device ? 0 : device_idx_+1; - bufs[device_idx_] = arv_stream_timeout_pop_buffer (devices_[device_idx_].stream_, 30 * 1000 * 1000); + bufs[device_idx_] = arv_stream_timeout_pop_buffer (devices_[device_idx_].stream_, timeout_us); if (bufs[device_idx_] == nullptr){ log::error("pop_buffer(L4) failed due to timeout ({}s)", timeout_us*1e-6f); throw ::std::runtime_error("buffer is null"); @@ -1326,10 +1329,9 @@ class U3VGenDC: public U3V{ while (frame_cnt_ >= latest_cnt) { arv_stream_push_buffer(devices_[device_idx_].stream_, bufs[device_idx_]); - auto timeout2_us = 30 * 1000 * 1000; - bufs[device_idx_] = arv_stream_timeout_pop_buffer (devices_[device_idx_].stream_, timeout2_us); + bufs[device_idx_] = arv_stream_timeout_pop_buffer (devices_[device_idx_].stream_, timeout_us); if (bufs[device_idx_] == nullptr){ - log::error("pop_buffer(L8) failed due to timeout ({}s)", timeout2_us*1e-6f); + log::error("pop_buffer(L8) failed due to timeout ({}s)", timeout_us*1e-6f); throw ::std::runtime_error("buffer is null"); } devices_[device_idx_].frame_count_ = frame_count_method_ == FrameCountMethod::TYPESPECIFIC3 @@ -1643,7 +1645,7 @@ class U3VGenDC: public U3V{ } }; - void consume_old_buffer(std::vector &bufs, int timeout_us = 3 * 1000 * 1000){ + void consume_old_buffer(std::vector &bufs, int timeout_us = TIMEOUT_IN_US_SHORTER){ std::vector N_output_buffers(num_sensor_); for (auto i = 0; i < num_sensor_; ++i) { int32_t num_input_buffer;