summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorchi <vdr@jwendel.de>2022-02-12 09:49:54 +0100
committerhorchi <vdr@jwendel.de>2022-02-12 09:49:54 +0100
commit9c515233168067ee8e56d35a8ee89bfc4d74e618 (patch)
tree44dbd7fb64ef237295a099ed571ea9b800f55077
parent29d493f3120a2da8d400e2427151551e32781a86 (diff)
downloadvdr-plugin-epg2vdr-9c515233168067ee8e56d35a8ee89bfc4d74e618.tar.gz
vdr-plugin-epg2vdr-9c515233168067ee8e56d35a8ee89bfc4d74e618.tar.bz2
2022-01-12: version 1.2.6 (horchi)\n - change: Further porting to vdr 2.6 (fixed detection of timer stop)\n\n1.2.6
-rw-r--r--HISTORY.h9
-rw-r--r--status.c87
-rw-r--r--timer.c6
-rw-r--r--update.h52
4 files changed, 101 insertions, 53 deletions
diff --git a/HISTORY.h b/HISTORY.h
index 4035a81..801c7bc 100644
--- a/HISTORY.h
+++ b/HISTORY.h
@@ -5,8 +5,8 @@
*
*/
-#define _VERSION "1.2.5"
-#define VERSION_DATE "04.01.2022"
+#define _VERSION "1.2.6"
+#define VERSION_DATE "12.01.2022"
#define DB_API 7
@@ -19,8 +19,11 @@
/*
* ------------------------------------
+2022-01-12: version 1.2.6 (horchi)
+ - change: Further porting to vdr 2.6 (fixed detection of timer stop)
+
2022-01-04: version 1.2.5 (horchi)
- - change: Makefile change du to more distribution compatibility
+ - change: Makefile change due to more distribution compatibility
2022-01-03: version 1.2.4 (horchi)
- change: Removed dependency to mysql-compat package
diff --git a/status.c b/status.c
index dcda89b..3cd154a 100644
--- a/status.c
+++ b/status.c
@@ -124,7 +124,7 @@ void cUpdate::Recording(const cDevice* Device, const char* Name, const char* Fil
tell(1, "Recording of '%s' has '%s' [%s]", Name, On ? "started" : "stopped", FileName);
- // schedule this notification to perfrom it in oure context not in the cStatus Interface context
+ // schedule this notification to perfrom it in our context not in the cStatus Interface context
// due to the needed list locks!
action.name = notNull(Name, "");
@@ -147,7 +147,7 @@ void cUpdate::Recording(const cDevice* Device, const char* Name, const char* Fil
int cUpdate::performRecordingActions()
{
- const int allowedBreakDuration = 2;
+ const int allowedBreakDuration {2};
GET_TIMERS_READ(timers); // get timers lock
GET_RECORDINGS_READ(recordings); // recordings lock
@@ -168,7 +168,7 @@ int cUpdate::performRecordingActions()
if (ti->Recording()) // timer nimmt gerade auf
{
- cRunningRecording* recording = 0;
+ cRunningRecording* recording {nullptr};
// check if already known
@@ -209,8 +209,62 @@ int cUpdate::performRecordingActions()
for (cRunningRecording* rr = runningRecordings.First(); rr; rr = runningRecordings.Next(rr))
{
const cRecording* pRecording = recordings->GetByName(action.fileName.c_str());
+ double recFraction {100.0};
+ long timerLengthSecs {0};
+ bool complete {false};
+
+ const cTimer* t = Timers->GetById(rr->id, rr->remote);
+
+ if (t && t->Recording())
+ continue;
+
+ tell(2,"Info: Valid timer for recording '%s' on Server '%s'", rr->file.c_str(), rr->remote);
+ timerLengthSecs = rr->stopTime - rr->startTime;
+
+ if (pRecording && timerLengthSecs)
+ {
+ int recLen = RecLengthInSecs(pRecording);
+ recFraction = double(recLen) * 100.0 / timerLengthSecs;
+ }
+
+ // assure timer has reached it's end or at least 90% (vps) / 98% were recorded
+
+ complete = recFraction >= (rr->vps ? 90 : 98);
+
+ if (complete)
+ tell(1, "Info: Finished (%d) '%s'; recorded %d%%; VPS %s", getTimerIdOf(rr->aux.c_str()),
+ rr->file.c_str(), (int)round(recFraction), rr->vps ? "Yes": "No");
+ else
+ tell(1, "Info: Finished (%d) '%s' (not complete! - recorded only %d%%); VPS %s", getTimerIdOf(rr->aux.c_str()),
+ rr->file.c_str(), (int)round(recFraction), rr->vps ? "Yes": "No");
+
+ if (complete)
+ rr->lastBreak = 0; // reset break
+ else if (!rr->lastBreak)
+ rr->lastBreak = time(0); // store first break
+
+ if (!rr->lastBreak || time(0) - rr->lastBreak > allowedBreakDuration || time(0) >= rr->stopTime)
+ {
+ char* infoTxt;
+ asprintf(&infoTxt, "Recording '%s' finished - %s complete (%d%%)", rr->file.c_str(), complete ? "" : "NOT", (int)round(recFraction));
+ tell(1, "Info: %s", infoTxt);
+ rr->finished = yes;
+ rr->failed = !complete;
+ rr->setInfo(infoTxt);
+ free(infoTxt);
+ }
+ }
+ }
+
+ /*
+ if (!action.on)
+ {
+ // loop over running recordings ..
+
+ for (cRunningRecording* rr = runningRecordings.First(); rr; rr = runningRecordings.Next(rr))
+ {
+ const cRecording* pRecording = recordings->GetByName(action.fileName.c_str());
const cTimer* pendingTimer = 0;
- int complete;
double recFraction = 100.0;
long timerLengthSecs = 0;
bool vpsUsed = false;
@@ -219,29 +273,31 @@ int cUpdate::performRecordingActions()
if (pendingTimer)
{
+ bool complete {false};
+
tell(2,"Info: valid timer for recording '%s' on Server '%s'", pendingTimer->File(), pendingTimer->Remote());
timerLengthSecs = pendingTimer->StopTime() - pendingTimer->StartTime();
if (pendingTimer->Event())
{
- tell(2,"Info: valid event for recording '%s'", pendingTimer->File());
- tell(2,"Info: pendingTimer->Event()->Vps() (%ld)", pendingTimer->Event()->Vps());
- vpsUsed = pendingTimer->HasFlags(tfVps) && pendingTimer->Event()->Vps();
+ tell(2,"Info: valid event for recording '%s'", pendingTimer->File());
+ tell(2,"Info: pendingTimer->Event()->Vps() (%ld)", pendingTimer->Event()->Vps());
+ vpsUsed = pendingTimer->HasFlags(tfVps) && pendingTimer->Event()->Vps();
}
else
{
- tell(2,"Info: no event for recording '%s'", pendingTimer->File());
+ tell(2,"Info: No event for recording '%s'", pendingTimer->File());
}
// still recording :o ?
- if (pendingTimer && pendingTimer->Recording())
+ if (pendingTimer->Recording())
continue;
if (pRecording && timerLengthSecs)
{
int recLen = RecLengthInSecs(pRecording);
- recFraction = double(recLen) * 100 / timerLengthSecs;
+ recFraction = double(recLen) * 100.0 / timerLengthSecs;
}
// assure timer has reached it's end or at least 90% (vps) / 98% were recorded
@@ -249,10 +305,10 @@ int cUpdate::performRecordingActions()
complete = recFraction >= (vpsUsed ? 90 : 98);
if (complete)
- tell(1, "Info: Finished (%d) '%s'; recorded %d%%; VPS %s", getTimerIdOf(rr->aux),
+ tell(1, "Info: Finished (%d) '%s'; recorded %d%%; VPS %s", getTimerIdOf(rr->aux.c_str()),
pendingTimer->File(), (int)round(recFraction), vpsUsed ? "Yes": "No");
else
- tell(1, "Info: Finished (%d) '%s' (not complete! - recorded only %d%%); VPS %s", getTimerIdOf(rr->aux),
+ tell(1, "Info: Finished (%d) '%s' (not complete! - recorded only %d%%); VPS %s", getTimerIdOf(rr->aux.c_str()),
pendingTimer->File(), (int)round(recFraction), vpsUsed ? "Yes": "No");
if (complete)
@@ -260,9 +316,7 @@ int cUpdate::performRecordingActions()
else if (!rr->lastBreak)
rr->lastBreak = time(0); // store first break
- if (!rr->lastBreak ||
- time(0) - rr->lastBreak > allowedBreakDuration ||
- time(0) >= pendingTimer->StopTime())
+ if (!rr->lastBreak || time(0) - rr->lastBreak > allowedBreakDuration || time(0) >= pendingTimer->StopTime())
{
char* infoTxt;
@@ -280,10 +334,11 @@ int cUpdate::performRecordingActions()
}
else
{
- tell(2,"Info: no timer for id '%d'", rr->id);
+ tell(1, "Info: No timer for id '%d' found", rr->id);
}
}
}
+ */
}
return done;
diff --git a/timer.c b/timer.c
index 0301723..6e6f63f 100644
--- a/timer.c
+++ b/timer.c
@@ -802,9 +802,9 @@ int cUpdate::recordingChanged()
// first: update timer state ..
- if (!isEmpty(rr->aux))
+ if (!rr->aux.empty())
{
- int timerid = getTimerIdOf(rr->aux);
+ int timerid = getTimerIdOf(rr->aux.c_str());
timerDb->clear();
timerDb->setValue("ID", timerid);
timerDb->setValue("VDRUUID", Epg2VdrConfig.uuid);
@@ -820,7 +820,7 @@ int cUpdate::recordingChanged()
else
timerDb->setCharValue("STATE", rr->failed ? tsError : rr->finished ? tsFinished : tsRunning);
- timerDb->setValue("INFO", rr->info);
+ timerDb->setValue("INFO", rr->info.c_str());
timerDb->store();
}
else
diff --git a/update.h b/update.h
index 173763f..77481cb 100644
--- a/update.h
+++ b/update.h
@@ -5,8 +5,7 @@
*
*/
-#ifndef __UPDATE_H
-#define __UPDATE_H
+#pragma once
#include <mysql.h>
#include <queue>
@@ -38,42 +37,36 @@ class cRunningRecording : public cListObject
cRunningRecording(const cTimer* t, long did = na)
{
+ doneid = did;
id = t->Id();
-
- if (remote)
- free(remote);
-
remote = t->Remote() ? strdup(t->Remote()) : nullptr;
- doneid = did;
- lastBreak = 0;
- info = 0;
-
- finished = no;
- failed = no;
-
- // copy until timer get waste ..
-
- aux = strdup(t->Aux() ? t->Aux() : "");
+ aux = notNull(t->Aux());
+ startTime = t->StartTime();
+ stopTime = t->StopTime();
+ file = notNull(t->File());
+ if (t->Event())
+ vps = t->HasFlags(tfVps) && t->Event()->Vps();
}
~cRunningRecording()
{
- free(aux);
- free(info);
+ free(remote);
}
- void setInfo(const char* i) { info = strdup(i); }
-
- // data
+ void setInfo(const char* i) { info = notNull(i); }
- int id = 0; // use timer->Id(), timer->Remote and GetById instead of pointer to a timer
+ int id {0}; // use timer->Id(), timer->Remote and GetById instead of pointer to a timer
char* remote {nullptr};
- time_t lastBreak;
- int finished;
- int failed;
- long doneid;
- char* aux {nullptr};
- char* info {nullptr};
+ time_t lastBreak {0};
+ int finished {no};
+ int failed {no};
+ long doneid {0};
+ std::string aux;
+ std::string info;
+ std::string file;
+ time_t startTime {0};
+ time_t stopTime {0};
+ bool vps {false};
};
//***************************************************************************
@@ -327,6 +320,3 @@ class cUpdate : public cThread, public cStatus, public cParameters
static const char* auxFields[];
};
-
-//***************************************************************************
-#endif //__UPDATE_H