Skip to content

Commit

Permalink
timer: use MP_TIME macros
Browse files Browse the repository at this point in the history
  • Loading branch information
kasper93 committed Oct 22, 2023
1 parent 08ae71f commit 647f938
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions osdep/poll_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ int mp_poll(struct pollfd *fds, int nfds, int64_t timeout_ns)
{
#if HAVE_PPOLL
struct timespec ts;
ts.tv_sec = timeout_ns / UINT64_C(1000000000);
ts.tv_nsec = timeout_ns % UINT64_C(1000000000);
ts.tv_sec = timeout_ns / MP_TIME_S_TO_NS(1);
ts.tv_nsec = timeout_ns % MP_TIME_S_TO_NS(1);
return ppoll(fds, nfds, &ts, NULL);
#endif
return poll(fds, nfds, timeout_ns / 1e6);
Expand Down
6 changes: 3 additions & 3 deletions osdep/timer-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ void mp_sleep_ns(int64_t ns)
if (ns < 0)
return;
struct timespec ts;
ts.tv_sec = ns / UINT64_C(1000000000);
ts.tv_nsec = ns % UINT64_C(1000000000);
ts.tv_sec = ns / MP_TIME_S_TO_NS(1);
ts.tv_nsec = ns % MP_TIME_S_TO_NS(1);
nanosleep(&ts, NULL);
}

Expand All @@ -40,7 +40,7 @@ uint64_t mp_raw_time_ns(void)
#else
timespec_get(&tp, TIME_UTC);
#endif
return tp.tv_sec * UINT64_C(1000000000) + tp.tv_nsec;
return MP_TIME_S_TO_NS(tp.tv_sec) + tp.tv_nsec;
}

void mp_raw_time_init(void)
Expand Down
2 changes: 1 addition & 1 deletion video/out/drm_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ static void drm_pflip_cb(int fd, unsigned int msc, unsigned int sec,
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
goto fail;
int64_t now_monotonic = ts.tv_sec * UINT64_C(1000000000) + ts.tv_nsec;
int64_t now_monotonic = ts.tv_sec * MP_TIME_S_TO_NS(1) + ts.tv_nsec;
int64_t ust_mp_time = mp_time_ns() - (now_monotonic - vsync->ust * 1000);

const uint64_t ust_since_enqueue = vsync->ust - frame_vsync->ust;
Expand Down
2 changes: 1 addition & 1 deletion video/out/present_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void present_sync_swap(struct mp_present *present)
if (clock_gettime(CLOCK_MONOTONIC, &ts))
return;

int64_t now_monotonic = ts.tv_sec * UINT64_C(1000000000) + ts.tv_nsec;
int64_t now_monotonic = MP_TIME_S_TO_NS(ts.tv_sec) + ts.tv_nsec;
int64_t ust_mp_time = mp_time_ns() - (now_monotonic - ust);

present->last_queue_display_time = ust_mp_time;
Expand Down
2 changes: 1 addition & 1 deletion video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ static void feedback_presented(void *data, struct wp_presentation_feedback *fbac
// - these values are updated every time the compositor receives feedback.

int64_t sec = (uint64_t) tv_sec_lo + ((uint64_t) tv_sec_hi << 32);
int64_t ust = sec * UINT64_C(1000000000) + (uint64_t) tv_nsec;
int64_t ust = MP_TIME_S_TO_NS(sec) + (uint64_t) tv_nsec;
int64_t msc = (uint64_t) seq_lo + ((uint64_t) seq_hi << 32);
present_update_sync_values(wl->present, ust, msc);
}
Expand Down

0 comments on commit 647f938

Please sign in to comment.