CameraBuf::acquire : using a scoped lock (#19764)

* Using a scoped lock

* Trigger Build
old-commit-hash: 2072699719
commatwo_master
Dean Lee 4 years ago committed by GitHub
parent fbca888d7e
commit 4eebd421a5
  1. 14
      selfdrive/camerad/cameras/camera_common.cc

@ -121,14 +121,14 @@ CameraBuf::~CameraBuf() {
}
bool CameraBuf::acquire() {
std::unique_lock<std::mutex> lk(frame_queue_mutex);
bool got_frame = frame_queue_cv.wait_for(lk, std::chrono::milliseconds(1), [this]{ return !frame_queue.empty(); });
if (!got_frame) return false;
{
std::unique_lock<std::mutex> lk(frame_queue_mutex);
bool got_frame = frame_queue_cv.wait_for(lk, std::chrono::milliseconds(1), [this]{ return !frame_queue.empty(); });
if (!got_frame) return false;
cur_buf_idx = frame_queue.front();
frame_queue.pop();
lk.unlock();
cur_buf_idx = frame_queue.front();
frame_queue.pop();
}
const FrameMetadata &frame_data = camera_bufs_metadata[cur_buf_idx];
if (frame_data.frame_id == -1) {

Loading…
Cancel
Save