From 30a59af73f16c7b97c4704a721b3a366b5b96175 Mon Sep 17 00:00:00 2001 From: David Engel Date: Thu, 25 Apr 2019 09:35:24 -0500 Subject: [PATCH] Account for very, large pre-roll values in AssignGroupInput. Refs #13423 (cherry picked from commit b71875f16c156abeb347e6035c8b7bb72c457904) --- mythtv/programs/mythbackend/scheduler.cpp | 30 +++++++++++------------ mythtv/programs/mythbackend/scheduler.h | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp index 6bb9b1e512e..1eb95fe9167 100644 --- a/mythtv/programs/mythbackend/scheduler.cpp +++ b/mythtv/programs/mythbackend/scheduler.cpp @@ -2668,6 +2668,7 @@ bool Scheduler::HandleRecording( QDateTime curtime = MythDate::current(); QDateTime nextrectime = ri.GetRecordingStartTime(); + int origprerollseconds = prerollseconds; if (ri.GetRecordingStatus() != RecStatus::WillRecord && ri.GetRecordingStatus() != RecStatus::Pending) @@ -2839,21 +2840,18 @@ bool Scheduler::HandleRecording( if (ri.GetRecordingStatus() != RecStatus::Pending) { - if (sinputinfomap[ri.GetInputID()].schedgroup) + if (!AssignGroupInput(tempri, origprerollseconds)) { - if (!AssignGroupInput(tempri)) - { - // We failed to assign an input. Keep asking the main - // server to add one until we get one. - MythEvent me(QString("ADD_CHILD_INPUT %1") - .arg(tempri.GetInputID())); - gCoreContext->dispatch(me); - nextWakeTime = min(nextWakeTime, curtime.addSecs(1)); - return reclist_changed; - } - ri.SetInputID(tempri.GetInputID()); - nexttv = (*m_tvList)[ri.GetInputID()]; + // We failed to assign an input. Keep asking the main + // server to add one until we get one. + MythEvent me(QString("ADD_CHILD_INPUT %1") + .arg(tempri.GetInputID())); + gCoreContext->dispatch(me); + nextWakeTime = min(nextWakeTime, curtime.addSecs(1)); + return reclist_changed; } + ri.SetInputID(tempri.GetInputID()); + nexttv = (*m_tvList)[ri.GetInputID()]; ri.SetRecordingStatus(RecStatus::Pending); tempri.SetRecordingStatus(RecStatus::Pending); @@ -2948,7 +2946,8 @@ void Scheduler::HandleRecordingStatusChange( } } -bool Scheduler::AssignGroupInput(RecordingInfo &ri) +bool Scheduler::AssignGroupInput(RecordingInfo &ri, + int prerollseconds) { if (!sinputinfomap[ri.GetInputID()].schedgroup) return true; @@ -2977,7 +2976,8 @@ bool Scheduler::AssignGroupInput(RecordingInfo &ri) for ( ; j != reclist.end(); ++j) { RecordingInfo *p = (*j); - if (now.secsTo(p->GetRecordingStartTime()) > 300) + if (now.secsTo(p->GetRecordingStartTime()) > + prerollseconds + 60) break; if (p->GetInputID() != inputid) continue; diff --git a/mythtv/programs/mythbackend/scheduler.h b/mythtv/programs/mythbackend/scheduler.h index db956207422..a739d774920 100644 --- a/mythtv/programs/mythbackend/scheduler.h +++ b/mythtv/programs/mythbackend/scheduler.h @@ -216,7 +216,7 @@ class Scheduler : public MThread, public MythScheduler int prerollseconds); void HandleRecordingStatusChange( RecordingInfo &ri, RecStatus::Type recStatus, const QString &details); - bool AssignGroupInput(RecordingInfo &ri); + bool AssignGroupInput(RecordingInfo &ri, int prerollseconds); void HandleIdleShutdown( bool &blockShutdown, QDateTime &idleSince, int prerollseconds, int idleTimeoutSecs, int idleWaitForRecordingTime,