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

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sun Oct 10 16:15:21 CEST 2010


On Sun, Oct 10, 2010 at 02:58:54PM +0200, Dan Oscarsson wrote:
> > > +// 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.

You are making undocumented assumptions on what it will be used for.
If someone e.g. used it to only implement an "uptime" slave mode
and nothing else it would be a significant issue to the point of
making it useless.

> 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?

How should I know, you don't tell me what your requirements are (do
you even know?).
0 is a wonderful 64 bit value, I doubt it meets most of your requirements
though.


More information about the MPlayer-dev-eng mailing list