summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-08 20:16:53 +0200
committerwm4 <wm4@nowhere>2014-04-08 20:16:53 +0200
commit708f32b74677ae3fac00ecabfbfd866426b06586 (patch)
tree75403fe082d4faa085a4be478a0ba1a90fdbdfdd /video
parenta62276bf5635dc9c4d0b7a3a20e0e1b01d545d4a (diff)
downloadmpv-708f32b74677ae3fac00ecabfbfd866426b06586.tar.bz2
mpv-708f32b74677ae3fac00ecabfbfd866426b06586.tar.xz
vo_vdpau: add an additional check for timestamp robustness
This might be a good idea in order to prevent queuing a frame too far in the future (causing apparent freezing of the video display), or dropping an infinite number of frames (also apparent as freezing). I think at this point this is most of what we can do if the vdpau time source is unreliable (like with Mesa). There are still inherent race conditions which can't be fixed.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_vdpau.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c
index d7e7206291..dfc6b4d599 100644
--- a/video/out/vo_vdpau.c
+++ b/video/out/vo_vdpau.c
@@ -1037,6 +1037,22 @@ static void flip_page_timed(struct vo *vo, int64_t pts_us, int duration)
uint64_t ideal_pts = pts;
uint64_t npts = duration >= 0 ? pts + duration : UINT64_MAX;
+ /* This should normally never happen.
+ * - The last queued frame can't have a PTS that goes more than 50ms in the
+ * future. This is guaranteed by the playloop, which currently actually
+ * roughly queues 50ms ahead, plus the flip queue offset. Just to be sure
+ * give some additional room by doubling the time.
+ * - The last vsync can never be in the future.
+ */
+ int64_t max_pts_ahead = (vo->flip_queue_offset + 0.050) * 2 * 1e9;
+ if (vc->last_queue_time > now + max_pts_ahead ||
+ vc->recent_vsync_time > now)
+ {
+ vc->last_queue_time = 0;
+ vc->recent_vsync_time = 0;
+ MP_WARN(vo, "Inconsistent timing detected.\n");
+ }
+
#define PREV_VSYNC(ts) prev_vsync(vc, ts)
/* We hope to be here at least one vsync before the frame should be shown.