summaryrefslogtreecommitdiff
path: root/libavcodec/v4l2_context.c
diff options
context:
space:
mode:
authorMing Qian <ming.qian@nxp.com>2020-04-01 10:38:45 +0800
committerAndriy Gelman <andriy.gelman@gmail.com>2020-04-14 23:42:05 -0400
commit8ac8e905e934aaae3f3ad3a0e2f2066b55b1c560 (patch)
tree7db7cdefff36d8b1e1ef30c9492e58fae44e8591 /libavcodec/v4l2_context.c
parent0607f1bcb0f6ed04b7bb3a5b3d951fd9b1554561 (diff)
avcodec/v4l2_m2m: handle v4l2 end of stream event
When flushing the capture buffers, the driver may send a V4L2_EVENT_EOS to notify that draining is completed. Currently, v4l2_m2m does not subscribe to this event, which can cause some devices (i.e. imx8qm) to hang at the end of encoding/decoding. Support for handling the event is added in this commit. Some devices may not signal V4L2_EVENT_EOS. This is logged as a warning message during initialization and not treated as a fatal error. Signed-off-by: Ming Qian <ming.qian@nxp.com> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Diffstat (limited to 'libavcodec/v4l2_context.c')
-rw-r--r--libavcodec/v4l2_context.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index 31af10d28e..6c2db5c849 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -154,6 +154,7 @@ static inline void v4l2_save_to_context(V4L2Context* ctx, struct v4l2_format_upd
}
/**
+ * handle resolution change event and end of stream event
* returns 1 if reinit was successful, negative if it failed
* returns 0 if reinit was not executed
*/
@@ -171,6 +172,11 @@ static int v4l2_handle_event(V4L2Context *ctx)
return 0;
}
+ if (evt.type == V4L2_EVENT_EOS) {
+ ctx->done = 1;
+ return 0;
+ }
+
if (evt.type != V4L2_EVENT_SOURCE_CHANGE)
return 0;