summaryrefslogtreecommitdiff
path: root/ambithread.c
diff options
context:
space:
mode:
authorChristian Völlinger <zerov83@gmail.com>2013-12-08 20:15:32 +0100
committerChristian Völlinger <zerov83@gmail.com>2013-12-08 20:15:32 +0100
commitbf2ab7b480ac602e3380f5864f8ac3cc31d79dd2 (patch)
treea4f276f3d249b10e182d85ad4dd834475250cdd8 /ambithread.c
parent47e367a8524a09dbdce8016296a611674e536225 (diff)
downloadvdr-plugin-boblight-bf2ab7b480ac602e3380f5864f8ac3cc31d79dd2.tar.gz
vdr-plugin-boblight-bf2ab7b480ac602e3380f5864f8ac3cc31d79dd2.tar.bz2
Erkennung ob Softhddevice detached ist.
Diffstat (limited to 'ambithread.c')
-rw-r--r--ambithread.c91
1 files changed, 71 insertions, 20 deletions
diff --git a/ambithread.c b/ambithread.c
index 3ee66e7..3b972bf 100644
--- a/ambithread.c
+++ b/ambithread.c
@@ -76,7 +76,14 @@ void cAmbiThread::Action()
{
MsTime start = msNow();
- // work ...
+ if(softhddeviceNotDetached() == fail)
+ {
+ bob.close();
+ waitCondition.TimedWait(mutex, 1000);
+ continue;
+ }
+
+ // Softhddevice is not detached, work...
if(bob.ping() == success) {
if(cfg.dirty > 0) {
@@ -84,32 +91,52 @@ void cAmbiThread::Action()
bob.sendOptions();
}
- if (cfg.viewMode == vmAtmo)
+ switch(cfg.viewMode)
{
- if (grabImage() == success)
- {
- detectCineBars();
+ case vmAtmo:
+ if (grabImage() == success)
+ {
+ detectCineBars();
+ putData();
+
+ MsTime elapsed = msNow() - start;
+ wait = 1000 / cfg.frequence - elapsed;
+ tell(3, "sleeping %ldms (%d Hz)", wait, cfg.frequence);
+ }
+ else
+ {
+ wait = 10000; // retry softhd grab every 10 seconds
+ }
+ break;
+
+ case vmBlack:
+ case vmFixedCol:
putData();
+ wait = 500; // less load on fixed color or black
+ break;
+
+ case vmDetached:
+ bob.close();
+ wait = 1000;
+ break;
- MsTime elapsed = msNow() - start;
- wait = 1000 / cfg.frequence - elapsed;
- tell(3, "sleeping %ldms (%d Hz)", wait, cfg.frequence);
- }
- else
- {
- wait = 10000; // retry softhd grab every 10 seconds
- }
- }
- else
- {
- putData();
- wait = 500; // less load on fixed color or black
+ default:
+ break;
}
}
else { // Connection lost, reconnect
- bob.close();
- bob.open();
wait = 10000;
+ switch(cfg.viewMode)
+ {
+ case vmDetached:
+ bob.close();
+ break;
+
+ default:
+ bob.close();
+ bob.open();
+ wait = 5000;
+ }
}
waitCondition.TimedWait(mutex, wait); // wait time in ms
@@ -121,6 +148,30 @@ void cAmbiThread::Action()
tell(0, "boblight thread ended (pid=%d)", getpid());
}
+int cAmbiThread::softhddeviceNotDetached()
+{
+ cPlugin* softHdPlugin = cPluginManager::GetPlugin("softhddevice");
+ if(!softHdPlugin)
+ {
+ error("Can't find softhddevice");
+ return fail;
+ }
+ int reply_code = 0;
+ cString reply_msg;
+ reply_msg = softHdPlugin->SVDRPCommand("STAT", "", reply_code);
+
+ if(910 == reply_code)
+ {
+ tell(1, "Softhddevice NOT detached: %d", reply_code);
+ return success;
+ }
+ else
+ {
+ tell(1, "Softhddevice detached: %d", reply_code);
+ return fail;
+ }
+}
+
//***************************************************************************
// Grab Image
//***************************************************************************