Skip to content

Commit

Permalink
x11, wayland: always round up wait times
Browse files Browse the repository at this point in the history
If wait_us is >0 and <500, the wait time gets rounded down 0,
effectively turning this into busy waiting. Round it up instead.
  • Loading branch information
wm4 committed Aug 26, 2016
1 parent 872b7a2 commit 37d6604
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us)
};

int64_t wait_us = until_time_us - mp_time_us();
int timeout_ms = MPCLAMP((wait_us + 500) / 1000, 0, 10000);
int timeout_ms = MPCLAMP((wait_us + 999) / 1000, 0, 10000);

wl_display_dispatch_pending(dp);
wl_display_flush(dp);
Expand Down
2 changes: 1 addition & 1 deletion video/out/x11_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ void vo_x11_wait_events(struct vo *vo, int64_t until_time_us)
{ .fd = x11->wakeup_pipe[0], .events = POLLIN },
};
int64_t wait_us = until_time_us - mp_time_us();
int timeout_ms = MPCLAMP((wait_us + 500) / 1000, 0, 10000);
int timeout_ms = MPCLAMP((wait_us + 999) / 1000, 0, 10000);

poll(fds, 2, timeout_ms);

Expand Down

0 comments on commit 37d6604

Please sign in to comment.