mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SRT: Upgrade libsrt from 1.4.1 to 1.5.1. v6.0.12 (#3362)
Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
parent
7a56208f2f
commit
fe086dfc31
143 changed files with 38185 additions and 15108 deletions
38
trunk/3rdparty/srt-1-fit/common/win_time.cpp
vendored
38
trunk/3rdparty/srt-1-fit/common/win_time.cpp
vendored
|
@ -27,39 +27,11 @@ void SRTCompat_timeradd(struct timeval *a, struct timeval *b, struct timeval *re
|
|||
}
|
||||
}
|
||||
|
||||
int SRTCompat_gettimeofday(struct timeval* tp, struct timezone* tz)
|
||||
int SRTCompat_gettimeofday(struct timeval* tp, struct timezone*)
|
||||
{
|
||||
static LARGE_INTEGER tickFrequency, epochOffset;
|
||||
|
||||
// For our first call, use "ftime()", so that we get a time with a proper epoch.
|
||||
// For subsequent calls, use "QueryPerformanceCount()", because it's more fine-grain.
|
||||
static int isFirstCall = 1;
|
||||
|
||||
LARGE_INTEGER tickNow;
|
||||
QueryPerformanceCounter(&tickNow);
|
||||
|
||||
if (isFirstCall)
|
||||
{
|
||||
struct timeb tb;
|
||||
ftime(&tb);
|
||||
tp->tv_sec = (long)tb.time;
|
||||
tp->tv_usec = 1000*tb.millitm;
|
||||
|
||||
// Also get our counter frequency:
|
||||
QueryPerformanceFrequency(&tickFrequency);
|
||||
|
||||
// And compute an offset to add to subsequent counter times, so we get a proper epoch:
|
||||
epochOffset.QuadPart = tb.time*tickFrequency.QuadPart + (tb.millitm*tickFrequency.QuadPart)/1000 - tickNow.QuadPart;
|
||||
|
||||
isFirstCall = 0; // for next time
|
||||
}
|
||||
else
|
||||
{
|
||||
// Adjust our counter time so that we get a proper epoch:
|
||||
tickNow.QuadPart += epochOffset.QuadPart;
|
||||
|
||||
tp->tv_sec = (long) (tickNow.QuadPart / tickFrequency.QuadPart);
|
||||
tp->tv_usec = (long) (((tickNow.QuadPart % tickFrequency.QuadPart) * 1000000L) / tickFrequency.QuadPart);
|
||||
}
|
||||
struct timeb tb;
|
||||
ftime(&tb);
|
||||
tp->tv_sec = (long)tb.time;
|
||||
tp->tv_usec = 1000*tb.millitm;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue