From bb4bcbdce333ebd609664595d29ab58039dd5fec Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Mon, 9 Apr 2012 20:50:46 +0300 Subject: [PATCH] Disabled double update on initialization for measures --- Library/MeasureCPU.cpp | 38 ++++--------------- Library/MeasureCPU.h | 2 - Library/MeterWindow.cpp | 2 +- .../PluginNowPlaying/PluginNowPlaying.vcxproj | 1 - 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/Library/MeasureCPU.cpp b/Library/MeasureCPU.cpp index 2eccaa13..9f3b5efc 100644 --- a/Library/MeasureCPU.cpp +++ b/Library/MeasureCPU.cpp @@ -65,7 +65,6 @@ ULONG CMeasureCPU::c_BufferSize = 0; ** */ CMeasureCPU::CMeasureCPU(CMeterWindow* meterWindow, const WCHAR* name) : CMeasure(meterWindow, name), - m_FirstTime(true), m_Processor(), m_OldTime() { @@ -99,24 +98,12 @@ void CMeasureCPU::ReadConfig(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadConfig(parser, section); - int processor = parser.ReadInt(section, L"Processor", 0); + m_Processor = parser.ReadInt(section, L"Processor", 0); - if (processor < 0 || processor > c_NumOfProcessors) + if (m_Processor < 0 || m_Processor > c_NumOfProcessors) { - LogWithArgs(LOG_WARNING, L"CPU: Processor=%i invalid in [%s]", processor, section); - - processor = 0; - } - - if (processor != m_Processor) - { - m_Processor = processor; - m_FirstTime = true; - } - - if (m_FirstTime) - { - m_OldTime[0] = m_OldTime[1] = 0.0; + LogWithArgs(LOG_WARNING, L"CPU: Processor=%i invalid in [%s]", m_Processor, section); + m_Processor = 0; } } @@ -222,20 +209,11 @@ bool CMeasureCPU::Update() */ void CMeasureCPU::CalcUsage(double idleTime, double systemTime) { - if (!m_FirstTime) - { - double dbCpuUsage; + // CurrentCpuUsage% = 100 - ((IdleTime / SystemTime) * 100) + double dbCpuUsage = 100.0 - ((idleTime - m_OldTime[0]) / (systemTime - m_OldTime[1])) * 100.0; - // CurrentCpuUsage% = 100 - ((IdleTime / SystemTime) * 100) - dbCpuUsage = 100.0 - ((idleTime - m_OldTime[0]) / (systemTime - m_OldTime[1])) * 100.0; - - dbCpuUsage = min(dbCpuUsage, 100.0); - m_Value = max(dbCpuUsage, 0.0); - } - else - { - m_FirstTime = false; - } + dbCpuUsage = min(dbCpuUsage, 100.0); + m_Value = max(dbCpuUsage, 0.0); // store new CPU's idle and system time m_OldTime[0] = idleTime; diff --git a/Library/MeasureCPU.h b/Library/MeasureCPU.h index 5292b79a..fef2b687 100644 --- a/Library/MeasureCPU.h +++ b/Library/MeasureCPU.h @@ -39,8 +39,6 @@ protected: private: void CalcUsage(double idleTime, double systemTime); - bool m_FirstTime; - int m_Processor; double m_OldTime[2]; diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index b7963996..37edf725 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2798,7 +2798,7 @@ void CMeterWindow::Update(bool nodraw) { ++m_UpdateCounter; - if (!m_Measures.empty()) + if (!nodraw && !m_Measures.empty()) { // Pre-updates if (m_HasNetMeasures) diff --git a/Plugins/PluginNowPlaying/PluginNowPlaying.vcxproj b/Plugins/PluginNowPlaying/PluginNowPlaying.vcxproj index 31da62d7..8a23065b 100644 --- a/Plugins/PluginNowPlaying/PluginNowPlaying.vcxproj +++ b/Plugins/PluginNowPlaying/PluginNowPlaying.vcxproj @@ -91,7 +91,6 @@ EditAndContinue 4018;4090;4114;4351;4786;4800;4996 .\sha2;.\taglib;.\taglib\toolkit;.\taglib\mpeg\id3v2\frames;.\taglib\ogg;.\taglib\asf;.\taglib\mp4;.\taglib\ogg\vorbis;.\taglib\ogg\flac;.\taglib\ogg\speex;.\taglib\riff;.\taglib\riff\wav;.\taglib\riff\aiff;.\taglib\flac;.\taglib\mpeg;.\taglib\mpeg\id3v1;.\taglib\mpeg\id3v2;.\taglib\mpc;.\taglib\ape;.\taglib\trueaudio;.\taglib\wavpack;.\SDKs\;%(AdditionalIncludeDirectories) - false _DEBUG;%(PreprocessorDefinitions)