[FFmpeg-devel] [PATCH 01/25] avcodec/v4l2_context: ensure v4l2_dequeue does not hang in poll() when no buffers are pending
Aman Gupta
ffmpeg at tmm1.net
Tue Sep 3 04:02:06 EEST 2019
From: Aman Gupta <aman at tmm1.net>
Signed-off-by: Aman Gupta <aman at tmm1.net>
---
libavcodec/v4l2_context.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index 6924760840..070988b4c3 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -264,8 +264,8 @@ static V4L2Buffer* v4l2_dequeue_v4l2buf(V4L2Context *ctx, int timeout)
};
int i, ret;
- /* if we are draining and there are no more capture buffers queued in the driver we are done */
- if (!V4L2_TYPE_IS_OUTPUT(ctx->type) && ctx_to_m2mctx(ctx)->draining) {
+ /* if there are no more capture buffers queued in the driver, skip polling */
+ if (!V4L2_TYPE_IS_OUTPUT(ctx->type)) {
for (i = 0; i < ctx->num_buffers; i++) {
/* capture buffer initialization happens during decode hence
* detection happens at runtime
@@ -276,7 +276,9 @@ static V4L2Buffer* v4l2_dequeue_v4l2buf(V4L2Context *ctx, int timeout)
if (ctx->buffers[i].status == V4L2BUF_IN_DRIVER)
goto start;
}
- ctx->done = 1;
+ /* if we were waiting to drain, all done! */
+ if (ctx_to_m2mctx(ctx)->draining)
+ ctx->done = 1;
return NULL;
}
--
2.20.1
More information about the ffmpeg-devel
mailing list