From c6a1b8ebcc1099832f3713348280d9e7c03ac368 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 25 Oct 2014 17:31:59 +0200 Subject: tv: reduce waiting loop from 10ms to 1ms I can't believe how shitty this (MPlayer-derived) code is. Maybe it should be fixed or be replaced with using libavdevice, but that doesn't seem worth the effort. Anyway, for now reduce the time it's blocking to wait for new frames from 10ms to 1ms, because 10ms might be a bit too tight: it could deliver the frame up to 10ms late - now it's only up to 1ms. (And yes, it does that instead of using condition variables. It also abuses volatile variables as atomics. It's hilarious.) --- stream/tvi_v4l2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c index 49b680d112..8738088a0a 100644 --- a/stream/tvi_v4l2.c +++ b/stream/tvi_v4l2.c @@ -1590,7 +1590,7 @@ static void *video_grabber(void *data) return NULL; } -#define MAX_LOOP 50 +#define MAX_LOOP 500 static double grab_video_frame(priv_t *priv, char *buffer, int len) { int loop_cnt = 0; @@ -1601,7 +1601,7 @@ static double grab_video_frame(priv_t *priv, char *buffer, int len) } while (priv->video_cnt == 0) { - usleep(10000); + usleep(1000); if (loop_cnt++ > MAX_LOOP) return 0; } -- cgit v1.2.3