Browse Source

VLCVideoUIView: follow guidelines from WWDC21

When using timestamp vs targetTimestamp, one must take care to compare
the VSYNC against the previous VSYNC (so targetTimestamp vs previous
targetTimestamp) and not use timestamp + targetTimestamp.

Also get the current time through CoreAnimation time functions to build
the difference with now, allowing a bit of latency to be introduced in
timestamp.
Alexandre Janniaux 5 years ago
parent
commit
1798183ce4
  1. 7
      modules/video_output/apple/VLCVideoUIView.m

7
modules/video_output/apple/VLCVideoUIView.m

@ -93,6 +93,7 @@
CADisplayLink *_displayLink; CADisplayLink *_displayLink;
dispatch_queue_t _eventq; dispatch_queue_t _eventq;
vlc_tick_t _last_ca_target_ts;
} }
- (id)initWithWindow:(vout_window_t *)wnd; - (id)initWithWindow:(vout_window_t *)wnd;
@ -115,6 +116,7 @@
{ {
_wnd = wnd; _wnd = wnd;
_enabled = NO; _enabled = NO;
_last_ca_target_ts = VLC_TICK_INVALID;
atomic_init(&_avstatEnabled, false); atomic_init(&_avstatEnabled, false);
UIView *superview = [self fetchViewContainer]; UIView *superview = [self fetchViewContainer];
@ -230,8 +232,11 @@
/* this compute the length of the VSYNC and the next date for the /* this compute the length of the VSYNC and the next date for the
* VSYNC. */ * VSYNC. */
vlc_tick_t last_ca_target_ts =_last_ca_target_ts == VLC_TICK_INVALID ?
ca_current_ts : _last_ca_target_ts;
vlc_tick_t clock_offset = ca_current_ts - ca_now_ts; vlc_tick_t clock_offset = ca_current_ts - ca_now_ts;
vlc_tick_t vsync_length = ca_target_ts - ca_current_ts; vlc_tick_t vsync_length = ca_target_ts - last_ca_target_ts;
_last_ca_target_ts = ca_target_ts;
if (atomic_load(&_avstatEnabled)) if (atomic_load(&_avstatEnabled))
msg_Info(_wnd, "avstats: [RENDER][CADISPLAYLINK] ts=%" PRId64 " " msg_Info(_wnd, "avstats: [RENDER][CADISPLAYLINK] ts=%" PRId64 " "

Loading…
Cancel
Save