vlc | branch: master | Thomas Guillem <[email protected]> | Mon Sep 2 15:31:32 2019 +0200| [aaaf7ea2170483b02557f37bc9b71866cb3ff1a0] | committer: Thomas Guillem
vout: update the clock between prepare() and display() The clock was updated just after the display returned. This could lead to a (very) small imprecision (delay between the display implementation exit path and vlc_tick_now() duration). Instead, we can update the clock just after prepare(), using system_pts. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aaaf7ea2170483b02557f37bc9b71866cb3ff1a0 --- src/video_output/video_output.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index 8706ae12b0..0aebe05137 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -1192,9 +1192,24 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced) if (!is_forced) { system_now = vlc_tick_now(); - vlc_clock_Wait(sys->clock, system_now, pts, sys->rate, - VOUT_REDISPLAY_DELAY); + if (unlikely(system_now > system_pts)) + { + /* vd->prepare took too much time. Tell the clock that the pts was + * rendered late. */ + system_pts = system_now; + } + else + { + /* Wait to reach system_pts */ + vlc_clock_Wait(sys->clock, system_now, pts, sys->rate, + VOUT_REDISPLAY_DELAY); + + /* Don't touch system_pts. Tell the clock that the pts was rendered + * at the expected date */ + } + vlc_clock_Update(sys->clock, system_pts, pts, sys->rate); } + sys->displayed.date = system_pts; /* Display the direct buffer returned by vout_RenderPicture */ vout_display_Display(vd, todisplay); @@ -1203,16 +1218,6 @@ static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced) if (subpic) subpicture_Delete(subpic); - if (!is_forced) - { - system_now = vlc_tick_now(); - const vlc_tick_t drift = vlc_clock_Update(sys->clock, system_now, - pts, sys->rate); - if (drift != VLC_TICK_INVALID && drift != INT64_MAX) - system_now += drift; - } - sys->displayed.date = system_now; - vout_statistic_AddDisplayed(&sys->statistic, 1); return VLC_SUCCESS; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
