    if (this->is_open) {
      if (this->dirty) {
        // drain output only if there could be frames in the encoder
  
        OMX_BUFFERHEADERTYPE* in_buf = (OMX_BUFFERHEADERTYPE *)queue_pop(&this->free_in);
        in_buf->nFilledLen = 0;
        in_buf->nOffset = 0;
        in_buf->nFlags = OMX_BUFFERFLAG_EOS;
        in_buf->nTimeStamp = this->last_t + 1000000LL/this->fps;
  
 
</s> remove   OMX_BUFFERHEADERTYPE* in_buf = (OMX_BUFFERHEADERTYPE *)queue_pop(&this->free_in);
 </s> add   OMX_BUFFERHEADERTYPE* in_buf = nullptr;
  while (!this->free_in.try_pop(in_buf, 20)) {
    if (do_exit) {
      pthread_mutex_unlock(&this->lock);
      return -1;
    }
  }
 </s> remove       {
 </s> add       for (int i = 0; i < encoders.size(); ++i) { </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         OMX_BUFFERHEADERTYPE *out_buf = (OMX_BUFFERHEADERTYPE *)queue_pop(&this->done_out);
 </s> add         OMX_BUFFERHEADERTYPE *out_buf = this->done_out.pop(); </s> remove         int out_id = encoders[0]->encode_frame(buf->y, buf->u, buf->v,
 </s> add         int out_id = encoders[i]->encode_frame(buf->y, buf->u, buf->v,
      OMX_BUFFERHEADERTYPE* in_buf = this->free_in.pop();
    if (this->is_open) {
      if (this->dirty) {
        // drain output only if there could be frames in the encoder
  
      OMX_BUFFERHEADERTYPE* in_buf = this->free_in.pop();
        in_buf->nFilledLen = 0;
        in_buf->nOffset = 0;
        in_buf->nFlags = OMX_BUFFERFLAG_EOS;
        in_buf->nTimeStamp = this->last_t + 1000000LL/this->fps;
  
keep keep keep keep 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/loggerd/omx_encoder.cc