Skip to content

Commit

Permalink
[core] Check Win QPC frequency is non-zero
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Aug 12, 2021
1 parent 7728b70 commit f1c96d9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions srtcore/sync_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ static int64_t get_cpu_frequency()
if (QueryPerformanceFrequency(&ccf))
{
frequency = ccf.QuadPart / 1000000; // counts per microsecond
if (frequency == 0)
{
LOGC(inlog.Warn, log << "Win QPC frequency of " << ccf.QuadPart
<< " counts/s is below the required 1 us accuracy. Please consider using C++11 timing (-DENABLE_STDCXX_SYNC=ON) instead.");
frequency = 1; // set back to 1 to avoid division by zero.
}
}
else
{
Expand Down

0 comments on commit f1c96d9

Please sign in to comment.