<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space"><div><span style="font-family: Arial; font-size: small; ">You can find alot occurences of this problem in
WinCE world. The problem is the "GetSystemTime()" call, which should fill the
SYSTEMTIME struct, but it does not, at least not the milliseconds field (which
is always 0). The solution I used:</span></div></div></blockquote></div><div><blockquote type="cite"><div style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space">
<div><span class="719273517-05112012"><font size="2" face="Arial"></font></span> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New">int
gettimeofday(struct timeval* tp, int* /*tz*/) {<br>#if
defined(_WIN32_WCE)<br> /* FILETIME of Jan 1 1970 00:00:00. */<br>
static const unsigned __int64 epoch = 116444736000000000LL;<br> static
Boolean isFirstCall = True;<br> static LONGLONG unixStartTime =
0;<br> static DWORD firstTickCount=0;</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New"> if
(isFirstCall) {</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New"> FILETIME fileTime;</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New">
GetSystemTimeAsFileTime(&fileTime);</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New"> LARGE_INTEGER date;<br>
date.HighPart = fileTime.dwHighDateTime;<br> date.LowPart =
fileTime.dwLowDateTime;</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New"> unixStartTime= (date.QuadPart - epoch) /
10000000L;</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New"> firstTickCount =
GetTickCount();</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New">
tp->tv_sec=(long)unixStartTime;<br> tp->tv_usec=
0L;</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New"> isFirstCall = False; // for next
time</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New"> }
else {<br> // add elapsed seconds<br>
tp->tv_sec= (long)unixStartTime +
(GetTickCount()-firstTickCount)/1000;<br>
tp->tv_usec=(GetTickCount()-firstTickCount)%1000 *
1000;<br>}</font></span></div>
<div><font face="Courier New"></font> </div>
<div><span class="719273517-05112012"><font size="2" face="Courier New">#else</font></span></div></div></blockquote><div><br></div></div>Correction: On further thought, I don't want to make this change 'as is'. The problem is that it's possible for the "gettimeofday()" function to be called concurrently from multiple threads. (This is legal for LIVE555-based systems that use different "UsageEnvironment" and "TaskScheduler" objects for each thread.) So, the implementation needs to be 'thread safe'. If the "if" branch of the "if (isFirstCall)" statement gets executed concurrently by more than one thread, then "unixStartTime" and/or "firstTickCount" might get set to bad values.<div><br></div><div>So, please rewrite your implementation to ensure that the "if" branch of the code (i.e., the part of the code that sets static variables) is executed only once, even if the code is called by multiple threads. (Because this code is for WinCE only, it's OK to use some WinCE-specific locking mechanism, if necessary.)</div><div><br></div><div>(However, I'll make the change to the timestamp conversion code in the next release of the software.)<br><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; ">Ross Finlayson<br>Live Networks, Inc.<br><a href="http://www.live555.com/">http://www.live555.com/</a></span>
</div>
<br></div></body></html>