From 339185dd6fad3d4d3e511798603eb26f2ab0397e Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 23 Feb 2020 05:34:45 -0500 Subject: [PATCH] demo: handle_input() deadline check #377 --- src/demo/demo.c | 4 ++-- src/demo/reel.c | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/demo/demo.c b/src/demo/demo.c index 624e29755..2daec2471 100644 --- a/src/demo/demo.c +++ b/src/demo/demo.c @@ -352,8 +352,8 @@ summary_table(struct ncdirect* nc, const char* spec){ qprefix(nsdelta, GIG, timebuf, 0); bprefix(totalbytes, 1, totalbuf, 0); qprefix(totalrenderns, GIG, rtimebuf, 0); - table_segment(nc, "", "══╧═════════╧════════╪═══════╪═════════╪═════════╪═══╪═══════╪═══════╝\n"); - table_printf(nc, "│", " %*ss", PREFIXSTRLEN, timebuf); + table_segment(nc, "", "══╧═════════╪════════╪═══════╪═════════╪═════════╪═══╪═══════╪═══════╝\n"); + table_printf(nc, "│", " │%*ss", PREFIXSTRLEN, timebuf); table_printf(nc, "│", "%7lu", totalframes); table_printf(nc, "│", "%*s", BPREFIXSTRLEN, totalbuf); table_printf(nc, "│", " %*ss", PREFIXSTRLEN, rtimebuf); diff --git a/src/demo/reel.c b/src/demo/reel.c index 27afa8859..85fda267a 100644 --- a/src/demo/reel.c +++ b/src/demo/reel.c @@ -223,10 +223,15 @@ handle_input(struct notcurses* nc, struct ncreel* pr, int efd, wchar_t key = -1; int pret; DEMO_RENDER(nc); + int64_t deadlinens = timespec_to_ns(deadline); do{ struct timespec pollspec, cur; clock_gettime(CLOCK_MONOTONIC, &cur); - timespec_subtract(&pollspec, deadline, &cur); + int64_t curns = timespec_to_ns(&cur); + if(curns > deadlinens){ + return 0; + } + ns_to_timespec(curns - deadlinens, &pollspec); pret = ppoll(fds, sizeof(fds) / sizeof(*fds), &pollspec, &sset); if(pret == 0){ return 0;