A suggestion for this could be to intialise using time() to get UTC time, then 
use QueryPerformanceFrequency/QueryPerformanceCounter from then on, like this:

int gettimeofday(struct timeval* tp, int* /*tz*/) {
  static bool tickFrequencySet = false;
  static unsigned __int64 tickFrequency = 0;
  static unsigned __int64 timeOffset = 0;
  
  unsigned __int64 tickNow;
 
  if (tickFrequencySet == false) {
    QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(&tickFrequency));
        
    time_t t;
    time(&t);
        
    QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&tickNow));
    tickNow /= tickFrequency;
    timeOffset = t - tickNow;
        
    tickFrequencySet = true;
  }
  
  QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(&tickNow));
  tp->tv_sec = static_cast<long>((tickNow / tickFrequency) + timeOffset);
  tp->tv_usec = static_cast<long>(((tickNow % tickFrequency) * 1000000L) / 
tickFrequency);

  return 0;
}

(better implementations of this are probably available ;))

Andy M

-----Original Message-----
From: Sébastien Escudier [mailto:sebastien-de...@celeos.eu] 
Sent: 2009-04-02 07:58
To: LIVE555 Streaming Media - development & use
Subject: Re: [Live-devel] minor bug on windows implementation ofgettimeofday()

Quoting Ross Finlayson <finlay...@live555.com>:

> Unfortunately I'm not an expert on Windoze-specific API stuff.

You may have a look at vlc times functions :

http://git.videolan.org/gitweb.cgi?p=vlc.git;a=blob;f=src/misc/mtime.c;h=0dbb4df578308b38e6e3ff9487b0e9143f11853b;hb=HEAD

or for a direct access to the file :

http://git.videolan.org/gitweb.cgi?p=vlc.git;a=blob_plain;f=src/misc/mtime.c;hb=HEAD

If you need a high precision clock, with a random epoch, look at mdate.
If you need a constant epoch look at gettimeofday

_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel
_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

Reply via email to