diff options
author | Christian Völlinger <zerov83@gmail.com> | 2013-12-31 12:33:42 +0100 |
---|---|---|
committer | Christian Völlinger <zerov83@gmail.com> | 2013-12-31 12:33:42 +0100 |
commit | d2d7b2d550f965302b1d265622d3a5f273eee39a (patch) | |
tree | bb2b6d9b72ba1ea9191e79061a6ba7b57634f6b0 | |
parent | 36ab01b35f87a616af20e8b3063a3995a119f197 (diff) | |
download | vdr-plugin-boblight-d2d7b2d550f965302b1d265622d3a5f273eee39a.tar.gz vdr-plugin-boblight-d2d7b2d550f965302b1d265622d3a5f273eee39a.tar.bz2 |
Reduce load
-rw-r--r-- | ambithread.c | 10 | ||||
-rw-r--r-- | boblightservice.c | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/ambithread.c b/ambithread.c index 78f3e2d..8a2f2e2 100644 --- a/ambithread.c +++ b/ambithread.c @@ -65,6 +65,8 @@ void cAmbiThread::Stop() void cAmbiThread::Action() { MsTime wait = 0; + MsTime lastPing = 0; + int lastPingResult = na; cMutexLock lock(&mutex); tell(0, "boblight Thread started (pid=%d)", getpid()); @@ -83,8 +85,14 @@ void cAmbiThread::Action() continue; } + // Reduce load, just ping every second + if(start - lastPing > 1000) { + lastPing = start; + lastPingResult = bob.ping(); + } + // Softhddevice is not detached, work... - if(bob.ping() == success) { + if(lastPingResult == success) { if(cfg.dirty > 0) { cfg.dirty = 0; diff --git a/boblightservice.c b/boblightservice.c index c3c52c3..e8e289c 100644 --- a/boblightservice.c +++ b/boblightservice.c @@ -56,9 +56,11 @@ int cBoblight::open() int cBoblight::close() { - tell(1, "Destroying boblight"); - boblight_destroy(m_boblight); // calls delete *void - m_boblight = 0; // set pointer to 0 + if(m_boblight != 0) { + tell(1, "Destroying boblight"); + boblight_destroy(m_boblight); // calls delete *void + m_boblight = 0; + } // set pointer to 0 return success; } |