summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Engel <dengel@mythtv.org>2013-01-30 21:09:06 (GMT)
committer David Engel <dengel@mythtv.org>2013-01-30 21:45:57 (GMT)
commit5587501e8b5f55694f6036bc187e9d63ac4fc83a (patch)
tree9ec23270059f9c22da3ee46f0431d05cd21dc755
parent4aabde2288f2b08420aab28ad0da05c66f7628f9 (diff)
Use recording rule priority as the primary scheduling priority.
Previously, priorities like input and channel were added to the recording rule priority to calculate a single priority used in scheduling. Now, the recording rule priority is used by itself as the primary priority. The other priorities are summed together and used as a secondary priority. What this means is all programs matching a given recording rule, including those on less desirable inputs and channels, are scheduled before any programs matching lower priority rules. This is more in line with the way most users assume and expect the scheduler to work and still allows the ancillary priorities to influence the scheduling of specific showings. Note: this is essentially a reintroduction of the "ComplexPriority" scheme.
-rw-r--r--mythtv/libs/libmythtv/recordinginfo.cpp9
-rw-r--r--mythtv/libs/libmythtv/recordinginfo.h9
-rw-r--r--mythtv/programs/mythbackend/scheduler.cpp77
3 files changed, 78 insertions, 17 deletions
diff --git a/mythtv/libs/libmythtv/recordinginfo.cpp b/mythtv/libs/libmythtv/recordinginfo.cpp
index af610f6..ccab50b 100644
--- a/mythtv/libs/libmythtv/recordinginfo.cpp
+++ b/mythtv/libs/libmythtv/recordinginfo.cpp
@@ -103,7 +103,8 @@ RecordingInfo::RecordingInfo(
uint _subtitleType,
uint _videoproperties,
uint _audioproperties,
- bool _future) :
+ bool _future,
+ int _schedorder) :
ProgramInfo(
_title, _subtitle, _description, _season, _episode,
_category, _chanid, _chanstr, _chansign, _channame,
@@ -113,6 +114,7 @@ RecordingInfo::RecordingInfo(
oldrecstatus(_oldrecstatus),
savedrecstatus(rsUnknown),
future(_future),
+ schedorder(_schedorder),
desiredrecstartts(_startts),
desiredrecendts(_endts),
record(NULL)
@@ -211,6 +213,7 @@ RecordingInfo::RecordingInfo(
oldrecstatus(rsUnknown),
savedrecstatus(rsUnknown),
future(false),
+ schedorder(0),
desiredrecstartts(_startts),
desiredrecendts(_endts),
record(NULL)
@@ -244,6 +247,7 @@ RecordingInfo::RecordingInfo(
oldrecstatus(rsUnknown),
savedrecstatus(rsUnknown),
future(false),
+ schedorder(0),
desiredrecstartts(),
desiredrecendts(),
record(NULL)
@@ -394,6 +398,7 @@ void RecordingInfo::clone(const RecordingInfo &other,
oldrecstatus = other.oldrecstatus;
savedrecstatus = other.savedrecstatus;
future = other.future;
+ schedorder = other.schedorder;
desiredrecstartts = other.desiredrecstartts;
desiredrecendts = other.desiredrecendts;
}
@@ -420,6 +425,7 @@ void RecordingInfo::clone(const ProgramInfo &other,
oldrecstatus = rsUnknown;
savedrecstatus = rsUnknown;
future = false;
+ schedorder = 0;
desiredrecstartts = QDateTime();
desiredrecendts = QDateTime();
}
@@ -434,6 +440,7 @@ void RecordingInfo::clear(void)
oldrecstatus = rsUnknown;
savedrecstatus = rsUnknown;
future = false;
+ schedorder = 0;
desiredrecstartts = QDateTime();
desiredrecendts = QDateTime();
}
diff --git a/mythtv/libs/libmythtv/recordinginfo.h b/mythtv/libs/libmythtv/recordinginfo.h
index c775e71..9844266 100644
--- a/mythtv/libs/libmythtv/recordinginfo.h
+++ b/mythtv/libs/libmythtv/recordinginfo.h
@@ -36,6 +36,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
oldrecstatus(rsUnknown),
savedrecstatus(rsUnknown),
future(false),
+ schedorder(0),
desiredrecstartts(),
desiredrecendts(),
record(NULL) {}
@@ -44,6 +45,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
oldrecstatus(other.oldrecstatus),
savedrecstatus(other.savedrecstatus),
future(other.future),
+ schedorder(other.schedorder),
desiredrecstartts(other.desiredrecstartts),
desiredrecendts(other.desiredrecendts),
record(NULL) {}
@@ -52,6 +54,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
oldrecstatus(rsUnknown),
savedrecstatus(rsUnknown),
future(false),
+ schedorder(0),
desiredrecstartts(startts),
desiredrecendts(endts),
record(NULL) {}
@@ -60,6 +63,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
oldrecstatus(rsUnknown),
savedrecstatus(rsUnknown),
future(false),
+ schedorder(0),
desiredrecstartts(startts),
desiredrecendts(endts),
record(NULL) {}
@@ -69,6 +73,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
oldrecstatus(rsUnknown),
savedrecstatus(rsUnknown),
future(false),
+ schedorder(0),
desiredrecstartts(startts),
desiredrecendts(endts),
record(NULL) {}
@@ -134,7 +139,8 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
uint subtitleType,
uint videoproperties,
uint audioproperties,
- bool future);
+ bool future,
+ int schedorder);
/// Create RecordingInfo from 'record'+'channel' tables,
/// user in scheduler.cpp @ ~ 3566 & ~ 3643
@@ -253,6 +259,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
RecStatusType oldrecstatus;
RecStatusType savedrecstatus;
bool future;
+ int schedorder;
QDateTime desiredrecstartts;
QDateTime desiredrecendts;
diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp
index 970e414..26fdc09 100644
--- a/mythtv/programs/mythbackend/scheduler.cpp
+++ b/mythtv/programs/mythbackend/scheduler.cpp
@@ -323,6 +323,9 @@ static bool comp_priority(RecordingInfo *a, RecordingInfo *b)
if (a->GetRecordingPriority() != b->GetRecordingPriority())
return a->GetRecordingPriority() > b->GetRecordingPriority();
+ if (a->GetRecordingPriority2() != b->GetRecordingPriority2())
+ return a->GetRecordingPriority2() > b->GetRecordingPriority2();
+
QDateTime pasttime = MythDate::current().addSecs(-30);
int apast = (a->GetRecordingStartTime() < pasttime &&
!a->IsReactivated());
@@ -346,8 +349,8 @@ static bool comp_priority(RecordingInfo *a, RecordingInfo *b)
return a->GetRecordingStartTime() < b->GetRecordingStartTime();
}
- if (a->GetRecordingPriority2() != b->GetRecordingPriority2())
- return a->GetRecordingPriority2() < b->GetRecordingPriority2();
+ if (a->schedorder != b->schedorder)
+ return a->schedorder < b->schedorder;
if (a->GetInputID() != b->GetInputID())
return a->GetInputID() < b->GetInputID();
@@ -355,6 +358,49 @@ static bool comp_priority(RecordingInfo *a, RecordingInfo *b)
return a->GetRecordingRuleID() < b->GetRecordingRuleID();
}
+static bool comp_retry(RecordingInfo *a, RecordingInfo *b)
+{
+ int arec = (a->GetRecordingStatus() != rsRecording &&
+ a->GetRecordingStatus() != rsTuning);
+ int brec = (b->GetRecordingStatus() != rsRecording &&
+ b->GetRecordingStatus() != rsTuning);
+
+ if (arec != brec)
+ return arec < brec;
+
+ if (a->GetRecordingPriority() != b->GetRecordingPriority())
+ return a->GetRecordingPriority() > b->GetRecordingPriority();
+
+ if (a->GetRecordingPriority2() != b->GetRecordingPriority2())
+ return a->GetRecordingPriority2() > b->GetRecordingPriority2();
+
+ QDateTime pasttime = MythDate::current().addSecs(-30);
+ int apast = (a->GetRecordingStartTime() < pasttime &&
+ !a->IsReactivated());
+ int bpast = (b->GetRecordingStartTime() < pasttime &&
+ !b->IsReactivated());
+
+ if (apast != bpast)
+ return apast < bpast;
+
+ int aprec = RecTypePrecedence(a->GetRecordingRuleType());
+ int bprec = RecTypePrecedence(b->GetRecordingRuleType());
+
+ if (aprec != bprec)
+ return aprec < bprec;
+
+ if (a->GetRecordingStartTime() != b->GetRecordingStartTime())
+ return a->GetRecordingStartTime() > b->GetRecordingStartTime();
+
+ if (a->schedorder != b->schedorder)
+ return a->schedorder > b->schedorder;
+
+ if (a->GetInputID() != b->GetInputID())
+ return a->GetInputID() > b->GetInputID();
+
+ return a->GetRecordingRuleID() < b->GetRecordingRuleID();
+}
+
bool Scheduler::FillRecordList(void)
{
schedTime = MythDate::current();
@@ -1139,7 +1185,9 @@ bool Scheduler::TryAnotherShowing(RecordingInfo *p, bool samePriority,
continue;
if (samePriority &&
- (q->GetRecordingPriority() < p->GetRecordingPriority()))
+ (q->GetRecordingPriority() < p->GetRecordingPriority() ||
+ (q->GetRecordingPriority() == p->GetRecordingPriority() &&
+ q->GetRecordingPriority2() < p->GetRecordingPriority2())))
{
continue;
}
@@ -1255,7 +1303,7 @@ void Scheduler::SchedNewRecords(void)
}
else
{
- retrylist.push_front(p);
+ retrylist.push_back(p);
PrintRec(p, " #");
PrintRec(conflict, " !");
}
@@ -1265,6 +1313,7 @@ void Scheduler::SchedNewRecords(void)
++i;
if (i == worklist.end() || lastpri != (*i)->GetRecordingPriority())
{
+ SORT_RECLIST(retrylist, comp_retry);
MoveHigherRecords();
retrylist.clear();
}
@@ -1313,9 +1362,6 @@ void Scheduler::MoveHigherRecords(bool livetv)
PrintRec(p, " ?");
- if (!livetv && TryAnotherShowing(p, false))
- continue;
-
BackupRecStatus();
p->SetRecordingStatus(rsWillRecord);
if (!livetv)
@@ -1343,6 +1389,7 @@ void Scheduler::MoveHigherRecords(bool livetv)
void Scheduler::PruneRedundants(void)
{
RecordingInfo *lastp = NULL;
+ int lastrecpri2 = 0;
RecIter i = worklist.begin();
while (i != worklist.end())
@@ -1394,6 +1441,7 @@ void Scheduler::PruneRedundants(void)
!lastp->IsSameTimeslot(*p))
{
lastp = p;
+ lastrecpri2 = lastp->GetRecordingPriority2();
lastp->SetRecordingPriority2(0);
++i;
}
@@ -1402,11 +1450,11 @@ void Scheduler::PruneRedundants(void)
// Flag lower priority showings that will recorded so we
// can warn the user about them
if (lastp->GetRecordingStatus() == rsWillRecord &&
- p->GetRecordingPriority() >
- lastp->GetRecordingPriority() - lastp->GetRecordingPriority2())
+ p->GetRecordingPriority2() >
+ lastrecpri2 - lastp->GetRecordingPriority2())
{
lastp->SetRecordingPriority2(
- lastp->GetRecordingPriority() - p->GetRecordingPriority());
+ lastrecpri2 - p->GetRecordingPriority2());
}
delete p;
*(i++) = NULL;
@@ -4073,8 +4121,8 @@ void Scheduler::AddNewRecords(void)
result.value(40).toUInt(),//subtitleType
result.value(39).toUInt(),//videoproperties
result.value(41).toUInt(),//audioproperties
- result.value(46).toInt());//future
- p->SetRecordingPriority2(result.value(47).toInt()); // schedorder
+ result.value(46).toInt(),//future
+ result.value(47).toInt());//schedorder
if (!p->future && !p->IsReactivated() &&
p->oldrecstatus != rsAborted &&
@@ -4083,8 +4131,7 @@ void Scheduler::AddNewRecords(void)
p->SetRecordingStatus(p->oldrecstatus);
}
- p->SetRecordingPriority(p->GetRecordingPriority() +
- result.value(51).toInt());
+ p->SetRecordingPriority2(result.value(51).toInt());
// Check to see if the program is currently recording and if
// the end time was changed. Ideally, checking for a new end
@@ -4121,7 +4168,7 @@ void Scheduler::AddNewRecords(void)
RecStatusType newrecstatus = rsUnknown;
// Check for rsOffLine
if ((doRun || specsched) &&
- (!cardMap.contains(p->GetCardID()) || !p->GetRecordingPriority2()))
+ (!cardMap.contains(p->GetCardID()) || !p->schedorder))
newrecstatus = rsOffLine;
// Check for rsTooManyRecordings