      release_callback((void*)camera_state, cur_buf_idx);
    }
  }
  
  void CameraBuf::queue(size_t buf_idx){
    {
      std::lock_guard<std::mutex> lk(frame_queue_mutex);
      frame_queue.push(buf_idx);
    }
    frame_queue_cv.notify_one();
  }
  
  // common functions
  
  void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data) {
 
</s> remove   {
    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();
  }
 </s> add   if (!safe_queue.try_pop(cur_buf_idx, 1)) return false; </s> remove     queue_push(&this->free_in, (void*)buf);
 </s> add     this->free_in.push(buf); </s> remove     OMX_BUFFERHEADERTYPE *out_buf = (OMX_BUFFERHEADERTYPE *)queue_try_pop(&this->done_out);
    if (!out_buf) {
 </s> add     OMX_BUFFERHEADERTYPE *out_buf;
    if (!this->done_out.try_pop(out_buf)) { </s> remove   queue_push(&e->free_in, (void*)buffer);
 </s> add   e->free_in.push(buffer);
void CameraBuf::queue(size_t buf_idx) {
  safe_queue.push(buf_idx);
      release_callback((void*)camera_state, cur_buf_idx);
    }
  }
  
void CameraBuf::queue(size_t buf_idx) {
  safe_queue.push(buf_idx);
void CameraBuf::queue(size_t buf_idx) {
  safe_queue.push(buf_idx);
void CameraBuf::queue(size_t buf_idx) {
  safe_queue.push(buf_idx);
void CameraBuf::queue(size_t buf_idx) {
  safe_queue.push(buf_idx);
void CameraBuf::queue(size_t buf_idx) {
  safe_queue.push(buf_idx);
void CameraBuf::queue(size_t buf_idx) {
  safe_queue.push(buf_idx);
  }
  
  // common functions
  
  void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data) {
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
 remove cqueue, use class SafeQueue (#19774)

* class SafeQueue

* cleanup includes

* space

* add timeout

use try_poll

* add function empty() & size()

* class SafeQueue

* add timeout

use try_poll

* add function empty() & size()

* rebase master

* rebase master

* for loop

* fix bug 
selfdrive/camerad/cameras/camera_common.cc