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:
+5
-1
@@ -2119,7 +2119,11 @@ public:
|
|||||||
|
|
||||||
if (this->audioDriver != nullptr)
|
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_);
|
GetCpuFrequency(&result.cpuFreqMin_, &result.cpuFreqMax_);
|
||||||
result.hasCpuGovernor_ = HasCpuGovernor();
|
result.hasCpuGovernor_ = HasCpuGovernor();
|
||||||
|
|||||||
+11
-6
@@ -140,14 +140,19 @@ namespace pipedal
|
|||||||
overheadTime = readTime;
|
overheadTime = readTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
SampleT totalTime = writeTime+ readTime + processingTime;
|
SampleT totalTime = writeTime + readTime + processingTime;
|
||||||
SampleT maxTime = waitTime+processingTime;
|
SampleT maxTime = waitTime + processingTime;
|
||||||
|
|
||||||
|
|
||||||
float result = 100.0f*(processingTime)/(maxTime);
|
float result = 0.0f;
|
||||||
float overhead = 100.0F*(overheadTime*2)/totalTime;
|
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;
|
currentCpuUse = result;
|
||||||
currentOverhead = overhead;
|
currentOverhead = overhead;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user