projects
/
experiments
/
fps-limit.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4ae705d
)
Fix the call to clock_nanosleep(): we use a relative delay
author
Antonio Ospite <ospite@studenti.unina.it>
Fri, 22 Mar 2013 12:17:18 +0000
(13:17 +0100)
committer
Antonio Ospite <ospite@studenti.unina.it>
Fri, 22 Mar 2013 12:17:18 +0000
(13:17 +0100)
fps-limit.c
patch
|
blob
|
history
diff --git
a/fps-limit.c
b/fps-limit.c
index
746c957
..
7759349
100644
(file)
--- a/
fps-limit.c
+++ b/
fps-limit.c
@@
-68,9
+68,10
@@
int main(void)
timespecsub(&time_end, &time_start, &elapsed);
dbg("Elapsed s: %ld ns: %ld", elapsed.tv_sec, elapsed.tv_nsec);
if (elapsed.tv_sec == 0 && elapsed.tv_nsec < NSEC_PER_SEC / FPS) {
timespecsub(&time_end, &time_start, &elapsed);
dbg("Elapsed s: %ld ns: %ld", elapsed.tv_sec, elapsed.tv_nsec);
if (elapsed.tv_sec == 0 && elapsed.tv_nsec < NSEC_PER_SEC / FPS) {
+ /* remaining delay, _relative_ to time_end */
remaining.tv_nsec = (NSEC_PER_SEC / FPS) - elapsed.tv_nsec;
dbg("Sleeping for: ns: %ld", remaining.tv_nsec);
remaining.tv_nsec = (NSEC_PER_SEC / FPS) - elapsed.tv_nsec;
dbg("Sleeping for: ns: %ld", remaining.tv_nsec);
- clock_nanosleep(CLOCK_MONOTONIC,
TIMER_ABSTIME
, &remaining, NULL);
+ clock_nanosleep(CLOCK_MONOTONIC,
0
, &remaining, NULL);
}
}
}
}