[MPlayer-dev-eng] [PATCH] 64-bit get time 2nd try

Dan Oscarsson Dan.Oscarsson at tieto.com
Sun Oct 10 14:58:54 CEST 2010


lör 2010-10-09 klockan 19:47 +0200 skrev Reimar Döffinger:
> > On MS Windows I can add high precision timers to get a better clock
> > there, though I cannot test it.
> 
> Rather pointless with a scheduler precision that is not any more accurate.

Maybe, but in my code I do frame scheduling related to display vsyncs.
If both the calculation of when next vsync will occur and the sleep
timing in mplayer is bad, then you have two bad time sources instead of
one.


> 
> > +// Returns current time in microseconds in 64 bit quantity so it does not wrap
> > +uint64_t get_time(void)
> > +{
> > +  uint64_t t;
> > +
> > +  if (wraps == -1) {
> > +    prev_time = (uint64_t)1000 * timeGetTime();
> > +    wraps = 0;
> > +  }
> > +  t = (uint64_t)1000 * (wraps * (uint64_t)0x100000000 + timeGetTime());
> > +  if (prev_time > t) {
> > +     wraps++;
> > +     t += 1000 * (uint64_t)0x100000000;
> > +  }
> 
> Of course this can't detect wraps if there's more than those 44 days
> between calls.

Does not matter unless you plan to pause the playing for 44 days.
The GetTimer call will wrap in little more than 1 hour, so a pause of 3
hours will get all the existing handling of timer differences wrong as
it the wraps more than once.

Maybe I should use av_gettime as it supports 64-bit time values?

   Dan



More information about the MPlayer-dev-eng mailing list