@@ -1746,9 +1746,19 @@ int testUserPtr(struct node *node, struct node *node_m2m_cap, unsigned frame_cou
if (node->is_m2m) {
if (node->codec_mask & STATEFUL_DECODER) {
+ int fd_flags = fcntl(node->g_fd(), F_GETFL);
+ struct timeval tv = { 1, 0 };
+ fd_set efds;
v4l2_event ev;
+ fcntl(node->g_fd(), F_SETFL, fd_flags | O_NONBLOCK);
+ FD_ZERO(&efds);
+ FD_SET(node->g_fd(), &efds);
+ ret = select(node->g_fd() + 1, nullptr, nullptr, &efds, &tv);
+ fail_on_test_val(ret < 0, ret);
+ fail_on_test(ret == 0);
fail_on_test(node->dqevent(ev));
+ fcntl(node->g_fd(), F_SETFL, fd_flags);
fail_on_test(ev.type != V4L2_EVENT_SOURCE_CHANGE);
fail_on_test(!(ev.u.src_change.changes & V4L2_EVENT_SRC_CH_RESOLUTION));
}
@@ -1949,9 +1959,19 @@ int testDmaBuf(struct node *expbuf_node, struct node *node, struct node *node_m2
if (node->is_m2m) {
if (node->codec_mask & STATEFUL_DECODER) {
+ int fd_flags = fcntl(node->g_fd(), F_GETFL);
+ struct timeval tv = { 1, 0 };
+ fd_set efds;
v4l2_event ev;
+ fcntl(node->g_fd(), F_SETFL, fd_flags | O_NONBLOCK);
+ FD_ZERO(&efds);
+ FD_SET(node->g_fd(), &efds);
+ ret = select(node->g_fd() + 1, nullptr, nullptr, &efds, &tv);
+ fail_on_test_val(ret < 0, ret);
+ fail_on_test(ret == 0);
fail_on_test(node->dqevent(ev));
+ fcntl(node->g_fd(), F_SETFL, fd_flags);
fail_on_test(ev.type != V4L2_EVENT_SOURCE_CHANGE);
fail_on_test(!(ev.u.src_change.changes & V4L2_EVENT_SRC_CH_RESOLUTION));
}
When the streaming option is called with a stateful decoder, testUserPtr() and testDmaBuf() will hang indefinitely when attempting to dequeue a source change event. To prevent this call select() with a timeout. Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com> --- Changes since v1: Restore the file descriptor flags to remove non-blocking mode. utils/v4l2-compliance/v4l2-test-buffers.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)