From: Miguel F. <mfr...@gm...> - 2004-10-29 13:06:07
|
hi, On Tue, 26 Oct 2004 20:03:06 -0200, Miguel Freitas <mfr...@gm...> wrote: > On Tue, 26 Oct 2004 18:20:18 -0200, Miguel Freitas <mfr...@gm...> wrote: > > > If xine's current behavior is really an issue for so many people, one > > > could use clock_gettime(CLOCK_MONOTONIC, tp) instead, which is available > > > on all platforms relevant to this jumping system clock "issue" (IOW > > > Linux). This monotonic clock may not be 100% accurate, though. (It's just > > > as accurate as an unadjusted system clock, as there's no way to adjust > > > it...) > > > > hey, nice! i've never heard about this function before. > > when you say it is not 100% accurate, does it mean its accuracy has > > any reason to be worse than gettimeofday? if not, i'd propose using > > the monotonic clock whenever available or falling back to > > gettimeofday. > > ok, i just tried using CLOCK_MONOTONIC but it didn't worked. greping > on kernel sources tell me this might be only supported on 2.6. is this > true? i was forced to turn off my computer so i tried it on kernel 2.6. it worked fine, that is, system time adjust produced no noticeable effect on xine playback. therefore i ask: should i commit this patch (closing bug #781532)? in case you have not looked on what it does: - a new function is created, xine_monotonic_clock(), which is a drop-in replacement for gettimeofday(). this function should be used whenever a monotonic clock is desirable. the function will do it's best, however it does _not_ guarantee monotonicity since it will depend on kernel support. - the availability of posix monotonic clock is tested with 3 conditions 1) definition of _POSIX_MONOTONIC_CLOCK so code will compile. 2) the resolution of monotonic clock is good enough 3) clock_gettime(CLOCK_MONOTONIC) reports no errors. if any of the above conditions fail, the code will fallback to gettimeofday(). comments? miguel ps: gettimeofday() should still be used for pthread_cond_timedwait since, afaict, linux does not yet support pthread_condattr_setclock. |