Skip to content

Commit

Permalink
Account for very, large pre-roll values in AssignGroupInput.
Browse files Browse the repository at this point in the history
Refs #13423

(cherry picked from commit b71875f)
  • Loading branch information
gigem committed Apr 25, 2019
1 parent 97786a0 commit 30a59af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions mythtv/programs/mythbackend/scheduler.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythbackend/scheduler.h
Expand Up @@ -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,
Expand Down

0 comments on commit 30a59af

Please sign in to comment.