diff options
author | wm4 <wm4@nowhere> | 2014-03-09 15:34:26 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-09 16:49:02 +0100 |
commit | 3620cf97ad97239f3f39093c1c86acc336342b66 (patch) | |
tree | 226a8a2c71d1a2f2da9d1b34572a39db7e989f6a /waftools/generators | |
parent | f50c1d2c2671d8742d2cc6d1f4f2c05e527b02c5 (diff) | |
download | mpv-3620cf97ad97239f3f39093c1c86acc336342b66.tar.bz2 mpv-3620cf97ad97239f3f39093c1c86acc336342b66.tar.xz |
timer: switch to CLOCK_MONOTONIC
Apparently, this is always _really_ monotonic, despite what the Linux
manpages say. So this should be much better than gettimeofday(). (At
times there were kernel bugs which broke the monotonic property.)
From the perspective of the player, time can still be discontinuous
(you could just stop the process with ^Z), but at least it's guaranteed
to be monotonic without further hacks required.
Also note that clock_gettime() returns the time in nanoseconds. We want
microseconds only, because that's the unit we chose internally. Another
problem is that nanoseconds can wrap pretty quickly (less than 300 years
in 63 bits), so it's just better to use microseconds. The devision won't
make the code that much slower (compilers can avoid a real division).
Note: this expects that the system provides clock_gettime() as well as
CLOCK_MONOTONIC. Both are optional according to POSIX. The only system
I know which doesn't have these, OSX, has seperate timer code anyway,
but I still don't know whether more obscure (yet supported) platforms
have a problem with this, so I'm playing safely. But this still expects
that CLOCK_MONOTONIC always works at runtime if it's defined.
Diffstat (limited to 'waftools/generators')
0 files changed, 0 insertions, 0 deletions