call drawdevices only every 500ms, added profiling code

This commit is contained in:
louis 2014-11-02 17:32:22 +01:00
parent ef4502cc02
commit 037e8e0cb1
7 changed files with 52 additions and 8 deletions

View File

@ -6,6 +6,9 @@
# External image lib to use: imagemagick, graphicsmagick # External image lib to use: imagemagick, graphicsmagick
IMAGELIB = imagemagick IMAGELIB = imagemagick
# Config
CONFIG := #-DDOPROFILE # enable profiling code
# The official name of this plugin. # The official name of this plugin.
PLUGIN = skindesigner PLUGIN = skindesigner
@ -42,7 +45,7 @@ PACKAGE = vdr-$(ARCHIVE)
SOFILE = libvdr-$(PLUGIN).so SOFILE = libvdr-$(PLUGIN).so
### Includes and Defines and Dependencies: ### Includes and Defines and Dependencies:
DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' $(CONFIG)
DEFINES += $(shell xml2-config --cflags) DEFINES += $(shell xml2-config --cflags)
INCLUDES += $(shell pkg-config --cflags freetype2 fontconfig) INCLUDES += $(shell pkg-config --cflags freetype2 fontconfig)

View File

@ -18,6 +18,7 @@ cSDDisplayChannel::cSDDisplayChannel(cTemplate *channelTemplate, bool WithInfo)
currentLast = 0; currentLast = 0;
channelChange = false; channelChange = false;
initial = true; initial = true;
devicesLast = cTimeMs::Now();
channelView = new cDisplayChannelView(channelTemplate->GetRootView()); channelView = new cDisplayChannelView(channelTemplate->GetRootView());
if (!channelView->createOsd()) { if (!channelView->createOsd()) {
@ -185,7 +186,10 @@ void cSDDisplayChannel::Flush(void) {
channelView->DrawScreenResolution(); channelView->DrawScreenResolution();
channelView->DrawSignal(); channelView->DrawSignal();
channelView->DrawAudioInfo(); channelView->DrawAudioInfo();
if (initial || cTimeMs::Now() - devicesLast > 500) {
channelView->DrawDevices(initial); channelView->DrawDevices(initial);
devicesLast = cTimeMs::Now();
}
} else { } else {
channelView->ClearStatusIcons(); channelView->ClearStatusIcons();
channelView->ClearScreenResolution(); channelView->ClearScreenResolution();

View File

@ -18,6 +18,7 @@ private:
int lastSignalQuality; int lastSignalQuality;
int lastScreenWidth; int lastScreenWidth;
int currentLast; int currentLast;
uint64_t devicesLast;
const cEvent *present; const cEvent *present;
void SetProgressBar(const cEvent *present); void SetProgressBar(const cEvent *present);
public: public:

View File

@ -167,9 +167,12 @@ vector<string>& splitstring::split(char delim, int rep) {
return flds; return flds;
} }
cStopWatch::cStopWatch(void) { cStopWatch::cStopWatch(const char* message) {
start = cTimeMs::Now(); start = cTimeMs::Now();
last = start; last = start;
if (message) {
dsyslog("skindesigner: Starting StopWatch %s", message);
}
} }
void cStopWatch::Report(const char* message) { void cStopWatch::Report(const char* message) {

View File

@ -33,7 +33,7 @@ private:
uint64_t start; uint64_t start;
uint64_t last; uint64_t last;
public: public:
cStopWatch(void); cStopWatch(const char* message = NULL);
~cStopWatch(void) {}; ~cStopWatch(void) {};
void Report(const char* message); void Report(const char* message);
void Stop(const char* message); void Stop(const char* message);

View File

@ -364,8 +364,18 @@ void cDisplayChannelView::DrawSignal(void) {
} }
time_t Now = time(NULL); time_t Now = time(NULL);
if (Now != lastSignalDisplay) { if (Now != lastSignalDisplay) {
#ifdef DOPROFILE
cStopWatch watch("DrawSignal");
#endif
int SignalStrength = cDevice::ActualDevice()->SignalStrength(); int SignalStrength = cDevice::ActualDevice()->SignalStrength();
#ifdef DOPROFILE
watch.Report("SignalStrength");
#endif
int SignalQuality = cDevice::ActualDevice()->SignalQuality(); int SignalQuality = cDevice::ActualDevice()->SignalQuality();
#ifdef DOPROFILE
watch.Report("SignalQuality");
watch.Stop("DrawSignal");
#endif
if (SignalStrength < 0) SignalStrength = 0; if (SignalStrength < 0) SignalStrength = 0;
if (SignalQuality < 0) SignalQuality = 0; if (SignalQuality < 0) SignalQuality = 0;
if ((SignalStrength == 0)&&(SignalQuality==0)) if ((SignalStrength == 0)&&(SignalQuality==0))

View File

@ -1,5 +1,6 @@
#include <vdr/menu.h> #include <vdr/menu.h>
#include "../config.h" #include "../config.h"
#include "../libcore/helpers.h"
#include "viewhelpers.h" #include "viewhelpers.h"
cViewHelpers::cViewHelpers(void) { cViewHelpers::cViewHelpers(void) {
@ -28,6 +29,9 @@ void cViewHelpers::InitDevices(void) {
} }
bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices) { bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<map<string,string> > *devices) {
#ifdef DOPROFILE
cStopWatch watch("SetDevices");
#endif
int numDevices = cDevice::NumDevices(); int numDevices = cDevice::NumDevices();
if (!initial) { if (!initial) {
//check if drawing is necessary //check if drawing is necessary
@ -37,12 +41,24 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
if (!device || !device->NumProvidedSystems()) { if (!device || !device->NumProvidedSystems()) {
continue; continue;
} }
if ((device->SignalStrength() != lastSignalStrength[i]) || (device->SignalQuality() != lastSignalQuality[i])) { int signalStrength = device->SignalStrength();
#ifdef DOPROFILE
watch.Report(*cString::sprintf("SignalStrength() device %d", i));
#endif
int signalQuality = device->SignalQuality();
#ifdef DOPROFILE
watch.Report(*cString::sprintf("SignalQuality() device %d", i));
#endif
if ((signalStrength != lastSignalStrength[i]) || (signalQuality != lastSignalQuality[i])) {
changed = true; changed = true;
break; break;
} }
} }
if (!changed) { if (!changed) {
#ifdef DOPROFILE
watch.Stop("SetDevices End");
#endif
return false; return false;
} }
} }
@ -55,7 +71,6 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
else else
deviceLiveTV = primaryDevice->DeviceNumber(); deviceLiveTV = primaryDevice->DeviceNumber();
} }
//check currently recording devices //check currently recording devices
for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) { for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) {
if (!timer->Recording()) { if (!timer->Recording()) {
@ -90,7 +105,13 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
deviceVals.insert(pair< string, string >("devices[hascam]", "0")); deviceVals.insert(pair< string, string >("devices[hascam]", "0"));
} }
int signalStrength = device->SignalStrength(); int signalStrength = device->SignalStrength();
#ifdef DOPROFILE
watch.Report(*cString::sprintf("SignalStrength() device %d", i));
#endif
int signalQuality = device->SignalQuality(); int signalQuality = device->SignalQuality();
#ifdef DOPROFILE
watch.Report(*cString::sprintf("SignalQuality() device %d", i));
#endif
stringstream strCamNumber; stringstream strCamNumber;
strCamNumber << camNumber; strCamNumber << camNumber;
deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str())); deviceVals.insert(pair< string, string >("devices[cam]", strCamNumber.str()));
@ -129,6 +150,8 @@ bool cViewHelpers::SetDevices(bool initial, map<string,int> *intTokens, vector<m
} }
intTokens->insert(pair<string, int>("numdevices", actualNumDevices)); intTokens->insert(pair<string, int>("numdevices", actualNumDevices));
#ifdef DOPROFILE
watch.Stop("SetDevices End");
#endif
return true; return true;
} }