CPU Usage Dive by Zero Issue (Chrome Console Error Reported)

Added explicit checks in “CpuUse::UpdateCpuUse” to avoid division by zero; CPU usage and overhead are forced to 0 when times are zero

Validated audio driver CPU usage in “AudioHost::getJackStatus”, replacing non‑finite results with 0
This commit is contained in:
Extremesecrecy
2025-07-24 07:50:33 -07:00
parent 43cc758d18
commit b3853e1bdb
2 changed files with 16 additions and 7 deletions
+5 -1
View File
@@ -2119,7 +2119,11 @@ public:
if (this->audioDriver != nullptr)
{
result.cpuUsage_ = audioDriver->CpuUse();
result.cpuUsage_ = audioDriver->CpuUse();
if (!std::isfinite(result.cpuUsage_))
{
result.cpuUsage_ = 0.0f;
}
}
GetCpuFrequency(&result.cpuFreqMin_, &result.cpuFreqMax_);
result.hasCpuGovernor_ = HasCpuGovernor();
+11 -6
View File
@@ -140,14 +140,19 @@ namespace pipedal
overheadTime = readTime;
}
SampleT totalTime = writeTime+ readTime + processingTime;
SampleT maxTime = waitTime+processingTime;
SampleT totalTime = writeTime + readTime + processingTime;
SampleT maxTime = waitTime + processingTime;
float result = 100.0f*(processingTime)/(maxTime);
float overhead = 100.0F*(overheadTime*2)/totalTime;
float result = 0.0f;
float overhead = 0.0f;
if (maxTime != 0 && totalTime != 0)
{
std::lock_guard lock { sync};
result = 100.0f * (processingTime) / (maxTime);
overhead = 100.0f * (overheadTime * 2) / totalTime;
}
{
std::lock_guard lock{sync};
currentCpuUse = result;
currentOverhead = overhead;
}