summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ambithread.c10
-rw-r--r--boblightservice.c8
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;
}