From 628a28201b797635486aad40fad042c4c4222656 Mon Sep 17 00:00:00 2001 From: kamel5 Date: Wed, 10 Feb 2021 16:02:44 +0100 Subject: [PATCH] Revision cViewReplay::SetTimeShiftValues() When the timeshift recording reaches the end time of the start event, the progress bar and the end time no longer shows any useful information. From this version the current live event is used to calculate the progress bar and the end time. --- coreengine/viewdisplayreplay.c | 34 +++++++++++++++++----------------- coreengine/viewdisplayreplay.h | 1 - 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/coreengine/viewdisplayreplay.c b/coreengine/viewdisplayreplay.c index db767dc..aed160d 100644 --- a/coreengine/viewdisplayreplay.c +++ b/coreengine/viewdisplayreplay.c @@ -162,15 +162,6 @@ void cViewReplay::ClearVariables(void) { globalTimers.ClearTimers(); } -void cViewReplay::SetTimeShift(int framesTotal, int timeShiftLength) { - timeShiftActive = true; - timeShiftFramesTotal = framesTotal; - this->timeShiftLength = timeShiftLength; - int mins = (timeShiftLength / 60) % 60; - int hours = (timeShiftLength / 3600) % 24; - timeShiftDuration = cString::sprintf("%d:%02d", hours, mins); -} - void cViewReplay::SetRecording(const cRecording *recording) { this->recording = recording; if (veRecTitle) { @@ -195,31 +186,40 @@ void cViewReplay::GetGlobalTimers(void) { void cViewReplay::SetTimeShiftValues(void) { if (!recording) return; - bool isTimeShift = false; + timeShiftActive = false; #if APIVERSNUM >= 20101 int usage = recording->IsInUse(); if (usage & ruTimer) - isTimeShift = true; + timeShiftActive = true; else { GetGlobalTimers(); if (globalTimers.IsRecording(recording)) - isTimeShift = true; + timeShiftActive = true; } #endif - if (!isTimeShift) + if (!timeShiftActive) return; const cRecordingInfo *recInfo = recording->Info(); if (!recInfo) return; - const cEvent *event = recInfo->GetEvent(); + const cSchedule *Schedule = NULL; + { + LOCK_SCHEDULES_READ; + Schedule = Schedules->GetSchedule(recInfo->ChannelID()); + } + if (!Schedule) + return; + const cEvent *event = Schedule->GetEventAround(time(NULL)); if (!event) return; double fps = recording->FramesPerSecond(); time_t liveEventStop = event->EndTime(); time_t recordingStart = time(0) - recording->LengthInSeconds(); - int framesTotal = (liveEventStop - recordingStart)*fps; - int recLength = liveEventStop - recordingStart; - SetTimeShift(framesTotal, recLength); + timeShiftFramesTotal = (liveEventStop - recordingStart) * fps; + timeShiftLength = liveEventStop - recordingStart; + int mins = (timeShiftLength / 60) % 60; + int hours = (timeShiftLength / 3600) % 24; + timeShiftDuration = cString::sprintf("%d:%02d", hours, mins); } void cViewReplay::SetTitle(const char *title) { diff --git a/coreengine/viewdisplayreplay.h b/coreengine/viewdisplayreplay.h index b9ed9eb..55e7966 100644 --- a/coreengine/viewdisplayreplay.h +++ b/coreengine/viewdisplayreplay.h @@ -45,7 +45,6 @@ public: void PreCache(void); void SetModeOnly(bool modeOnly) { this->modeOnly = modeOnly; }; void SetRecordingLength(int length) { reclength = length; }; - void SetTimeShift(int framesTotal, int timeShiftLength); void SetRecording(const cRecording *recording); void SetTitle(const char *title); void SetCurrent(const char *current);