aboutsummaryrefslogtreecommitdiffstats
path: root/src/v4l.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-07-24 09:18:39 -0300
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2018-07-24 09:45:56 -0300
commit3bbc07f94c3bf49e2828902dfeb3f6f2e6953336 (patch)
treeeabf27fc04fd80cb27275e5573b339b78ff89cf8 /src/v4l.c
parent00dca626855904e955ec4c164505a0bc34db671d (diff)
Prevent activating an already active size
Changing resolution is costly, as we need first to wait for pending buffers and stop streaming. So, optimize resolution switch by not trying to activate the already activated resolution.
Diffstat (limited to 'src/v4l.c')
-rw-r--r--src/v4l.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/v4l.c b/src/v4l.c
index 47c0fe6..f2eff32 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -258,6 +258,22 @@ void get_win_info(cam * cam)
}
}
+void try_set_win_info(cam * cam, int *x, int *y)
+{
+ gchar *msg;
+ struct v4l2_format fmt;
+
+ memset(&fmt, 0, sizeof(fmt));
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmt.fmt.pix.pixelformat = cam->pixformat;
+ fmt.fmt.pix.width = *x;
+ fmt.fmt.pix.height = *y;
+ if (!v4l2_ioctl(cam->dev, VIDIOC_TRY_FMT, &fmt)) {
+ *x = fmt.fmt.pix.width;
+ *y = fmt.fmt.pix.height;
+ }
+}
+
void set_win_info(cam * cam)
{
gchar *msg;

Privacy Policy