CPUUsage (Windows): detect perflib support dynamically based on OS version

This commit is contained in:
李通洲
2025-07-02 19:32:18 +08:00
parent 2e5769def2
commit 98738b6920
3 changed files with 69 additions and 46 deletions
+3 -2
View File
@@ -28,10 +28,11 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
{
sumValue += *percent;
#if FF_ENABLE_CPUUSAGE_PERFLIB
#if WIN32
// Windows may return values greater than 100%, cap them to 100%
if (*percent > 100) *percent = 100;
#endif
if (*percent > maxValue)
{
maxValue = *percent;
@@ -47,7 +48,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
++index;
}
double avgValue = sumValue / (double) valueCount;
#if FF_ENABLE_CPUUSAGE_PERFLIB
#if WIN32
// See above comment
if (avgValue > 100) avgValue = 100;
#endif