shared: Add timespec_to_proto helper function
Add helper function to convert from struct timespec values to tv_sec_hi,
tv_sec_lo, tv_nsec triplets used for sending high-resolution timestamp
data over the wayland protocol. Replace existing conversion code with
the helper function.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
diff --git a/libweston/compositor.c b/libweston/compositor.c
index 7d7a17e..083664f 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -341,7 +341,9 @@
{
struct wl_client *client = wl_resource_get_client(feedback->resource);
struct wl_resource *o;
- uint64_t secs;
+ uint32_t tv_sec_hi;
+ uint32_t tv_sec_lo;
+ uint32_t tv_nsec;
wl_resource_for_each(o, &output->resource_list) {
if (wl_resource_get_client(o) != client)
@@ -350,10 +352,9 @@
wp_presentation_feedback_send_sync_output(feedback->resource, o);
}
- secs = ts->tv_sec;
+ timespec_to_proto(ts, &tv_sec_hi, &tv_sec_lo, &tv_nsec);
wp_presentation_feedback_send_presented(feedback->resource,
- secs >> 32, secs & 0xffffffff,
- ts->tv_nsec,
+ tv_sec_hi, tv_sec_lo, tv_nsec,
refresh_nsec,
seq >> 32, seq & 0xffffffff,
flags | feedback->psf_flags);