summaryrefslogtreecommitdiffstats
path: root/video/out/wayland_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/wayland_common.c')
-rw-r--r--video/out/wayland_common.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 55a4c36f1e..70e72b491c 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1581,16 +1581,19 @@ void queue_new_sync(struct vo_wayland_state *wl)
void wayland_sync_swap(struct vo_wayland_state *wl)
{
int index = wl->sync_size - 1;
+ int64_t mp_time = mp_time_us();
wl->last_skipped_vsyncs = 0;
- // If these are the same (can happen if a frame takes too long), update
- // the ust/msc/sbc based on when the next frame is expected to arrive.
+ // If these are the same, presentation feedback has not been received.
+ // This will happen if the window is obscured/hidden in some way. Update
+ // the values based on the difference in mp_time.
if (wl->sync[index].ust == wl->last_ust && wl->last_ust) {
- wl->sync[index].ust += wl->sync[index].refresh_usec;
+ wl->sync[index].ust += mp_time - wl->sync[index].last_mp_time;
wl->sync[index].msc += 1;
wl->sync[index].sbc += 1;
}
+ wl->sync[index].last_mp_time = mp_time;
int64_t ust_passed = wl->sync[index].ust ? wl->sync[index].ust - wl->last_ust: 0;
wl->last_ust = wl->sync[index].ust;
@@ -1609,7 +1612,7 @@ void wayland_sync_swap(struct vo_wayland_state *wl)
}
uint64_t now_monotonic = ts.tv_sec * 1000000LL + ts.tv_nsec / 1000;
- uint64_t ust_mp_time = mp_time_us() - (now_monotonic - wl->sync[index].ust);
+ uint64_t ust_mp_time = mp_time - (now_monotonic - wl->sync[index].ust);
wl->last_sbc_mp_time = ust_mp_time;
}
@@ -1650,26 +1653,6 @@ void vo_wayland_wait_frame(struct vo_wayland_state *wl)
wl_display_read_events(wl->display);
wl_display_roundtrip(wl->display);
}
-
- if (wl->frame_wait) {
- if (!wl->hidden) {
- wl->timeout_count += 1;
- } else {
- wl->timeout_count = 0;
- }
- } else {
- if (wl->hidden) {
- wl->timeout_count -= 1;
- } else {
- wl->timeout_count = 0;
- }
- }
-
- if (wl->timeout_count > wl->current_output->refresh_rate) {
- wl->hidden = true;
- } else if (wl->timeout_count < -1*wl->current_output->refresh_rate) {
- wl->hidden = false;
- }
}
void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us)