Blocking issue with encoder

I send the EOS signal to encoder with the following code:

while (-1 == m_VideoEncoder->capture_plane.waitForDQThread(10))
        struct v4l2_buffer v4l2_buf = {};
        struct v4l2_plane planes[MAX_PLANES];

        memset(&v4l2_buf, 0, sizeof(v4l2_buf));
        memset(planes, 0, MAX_PLANES * sizeof(struct v4l2_plane));
        v4l2_buf.m.planes = planes;
        m_VideoEncoder->output_plane.dqBuffer(v4l2_buf, NULL, NULL, 10);

        for (s32 j = 0; j < MAX_PLANES; j++)
            v4l2_buf.m.planes[j].bytesused = 0;

        m_VideoEncoder->output_plane.qBuffer(v4l2_buf, NULL);

I don’t know why there’s still a small probability blocking problem

Please refer to 01_video_encode. It is a sample well verified. It should work well if you follow the code in terminating NvVideoEncoder.

Thanks for your advice
I will refer to 01_video_encode in terminating NvVideoEncoder.