diff options
| author | UjinT34 <41110182+UjinT34@users.noreply.github.com> | 2026-02-10 17:55:21 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-10 14:55:21 +0000 |
| commit | ff061d177e86435a0d9f5605153a4567e2fcd88b (patch) | |
| tree | 5c5fad1a485b2af162e3d3e11aecacaa8e03834f /src/helpers/time/Time.cpp | |
| parent | 407a623801b8cb5b863e5056b2d5a195452776fa (diff) | |
protocols: commit and presentation timing fixes (#13174)
* move commit timing fields to surface state
* fix toTimespec init
* update sendQueued api
* update onPresented api
* set zero copy flag
* send clock id
* move presented calcs inside condition
* use only CLOCK_MONOTONIC for commit/presentation timings
* fix setSetTimestamp
* do not wait for commit timing while tearing
* proto config
* fix config defaults
Diffstat (limited to 'src/helpers/time/Time.cpp')
| -rw-r--r-- | src/helpers/time/Time.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/helpers/time/Time.cpp b/src/helpers/time/Time.cpp index 7ef24e22..f454b784 100644 --- a/src/helpers/time/Time.cpp +++ b/src/helpers/time/Time.cpp @@ -103,7 +103,7 @@ Time::steady_tp Time::fromTimespec(const timespec* ts) { } struct timespec Time::toTimespec(const steady_tp& tp) { - struct timespec mono, real; + timespec mono{}, real{}; clock_gettime(CLOCK_MONOTONIC, &mono); clock_gettime(CLOCK_REALTIME, &real); Time::steady_tp now = Time::steadyNow(); @@ -136,3 +136,10 @@ struct timespec Time::toTimespec(const steady_tp& tp) { auto sum = timeadd(tpTime, diffFinal); return timespec{.tv_sec = sum.first, .tv_nsec = sum.second}; } + +Time::steady_dur Time::till(const timespec& ts) { + timespec mono{}; + clock_gettime(CLOCK_MONOTONIC, &mono); + const auto delay = (ts.tv_sec - mono.tv_sec) * 1000000000 + (ts.tv_nsec - mono.tv_nsec); + return std::chrono::nanoseconds(delay); +} |
