diff options
Diffstat (limited to 'status.c')
-rw-r--r-- | status.c | 87 |
1 files changed, 71 insertions, 16 deletions
@@ -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; |