summaryrefslogtreecommitdiff
path: root/libavcodec/v4l2_m2m_dec.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_m2m_dec.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_m2m_dec.c')
-rw-r--r--libavcodec/v4l2_m2m_dec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
index c5ee86b993..3e17e0fcac 100644
--- a/libavcodec/v4l2_m2m_dec.c
+++ b/libavcodec/v4l2_m2m_dec.c
@@ -123,6 +123,13 @@ static int v4l2_prepare_decoder(V4L2m2mContext *s)
}
}
+ memset(&sub, 0, sizeof(sub));
+ sub.type = V4L2_EVENT_EOS;
+ ret = ioctl(s->fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
+ if (ret < 0)
+ av_log(s->avctx, AV_LOG_WARNING,
+ "the v4l2 driver does not support end of stream VIDIOC_SUBSCRIBE_EVENT\n");
+
return 0;
}