Skip to content

Commit

Permalink
Remove the LiveTVPriority setting.
Browse files Browse the repository at this point in the history
This is another change in the series of changes to remove some
scheduler related features and settings that the developers no longer
believe are needed or want to support.

The scheduler now always tries to avoid interrupting live TV.
Recordings that conflict with live TV are moved to other inputs or
later times as needed.  Live TV is only interrupted if a recording
can not be moved.
  • Loading branch information
gigem committed Dec 13, 2012
1 parent ec8b37a commit 5173ecb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 83 deletions.
90 changes: 25 additions & 65 deletions mythtv/programs/mythbackend/scheduler.cpp
Expand Up @@ -70,9 +70,7 @@ Scheduler::Scheduler(bool runthread, QMap<int, EncoderLink *> *tvList,
resetIdleTime(false),
m_isShuttingDown(false),
error(0),
livetvTime(QDateTime()),
livetvpriority(0),
prefinputpri(0)
livetvTime(QDateTime())
{
char *debug = getenv("DEBUG_CONFLICTS");
debugConflicts = (debug != NULL);
Expand Down Expand Up @@ -382,8 +380,8 @@ bool Scheduler::FillRecordList(void)
BuildListMaps();
LOG(VB_SCHEDULE, LOG_INFO, "SchedNewRecords...");
SchedNewRecords();
LOG(VB_SCHEDULE, LOG_INFO, "SchedPreserveLiveTV...");
SchedPreserveLiveTV();
LOG(VB_SCHEDULE, LOG_INFO, "SchedLiveTV...");
SchedLiveTV();
LOG(VB_SCHEDULE, LOG_INFO, "ClearListMaps...");
ClearListMaps();

Expand Down Expand Up @@ -1120,7 +1118,7 @@ void Scheduler::RestoreRecStatus(void)
}

bool Scheduler::TryAnotherShowing(RecordingInfo *p, bool samePriority,
bool preserveLive)
bool livetv)
{
PrintRec(p, " >");

Expand All @@ -1133,8 +1131,6 @@ bool Scheduler::TryAnotherShowing(RecordingInfo *p, bool samePriority,
RecStatusType oldstatus = p->GetRecordingStatus();
p->SetRecordingStatus(rsLaterShowing);

bool hasLaterShowing = false;

RecIter j = showinglist->begin();
for ( ; j != showinglist->end(); ++j)
{
Expand All @@ -1148,8 +1144,6 @@ bool Scheduler::TryAnotherShowing(RecordingInfo *p, bool samePriority,
continue;
}

hasLaterShowing = false;

if (q->GetRecordingStatus() != rsEarlierShowing &&
q->GetRecordingStatus() != rsLaterShowing &&
q->GetRecordingStatus() != rsUnknown)
Expand All @@ -1167,23 +1161,22 @@ bool Scheduler::TryAnotherShowing(RecordingInfo *p, bool samePriority,
if (q->GetRecordingStartTime() < schedTime &&
p->GetRecordingStartTime() >= schedTime)
continue;

hasLaterShowing |= preserveLive;
}

if (samePriority)
PrintRec(q, " %");
else
PrintRec(q, " $");

bool failedLiveCheck = false;
if (preserveLive)
const RecordingInfo *conflict = FindConflict(q);
if (conflict)
{
failedLiveCheck |=
(!livetvpriority ||
p->GetRecordingPriority() - prefinputpri >
q->GetRecordingPriority());
PrintRec(conflict, " !");
continue;
}

if (livetv)
{
// It is pointless to preempt another livetv session.
// (the retrylist contains dummy livetv pginfo's)
RecConstIter k = retrylist.begin();
Expand All @@ -1192,44 +1185,14 @@ bool Scheduler::TryAnotherShowing(RecordingInfo *p, bool samePriority,
PrintRec(*k, " L!");
continue;
}
}

const RecordingInfo *conflict = FindConflict(q);
if (conflict)
{
PrintRec(conflict, " !");
continue;
}

if (hasLaterShowing)
{
QString id = p->MakeUniqueSchedulerKey();
hasLaterList[id] = true;
continue;
}

if (failedLiveCheck)
{
// Failed the priority check or "Move scheduled shows to
// avoid LiveTV feature" is turned off.
// However, there is no conflict so if this alternate showing
// is on an equivalent virtual card, allow the move.
bool equiv = (p->GetSourceID() == q->GetSourceID() &&
igrp.GetSharedInputGroup(
p->GetInputID(), q->GetInputID()));

if (!equiv)
continue;
}

if (preserveLive)
{
QString msg = QString(
"Moved \"%1\" on chanid: %2 from card: %3 to %4 "
"Moved \"%1\" on chanid: %2 from card: %3 to %4 at %5 "
"to avoid LiveTV conflict")
.arg(p->GetTitle()).arg(p->GetChanID())
.arg(p->GetCardID()).arg(q->GetCardID());
LOG(VB_SCHEDULE, LOG_INFO, msg);
.arg(p->GetCardID()).arg(q->GetCardID())
.arg(q->GetScheduledStartTime().toLocalTime().toString());
LOG(VB_GENERAL, LOG_INFO, msg);
}

q->SetRecordingStatus(rsWillRecord);
Expand Down Expand Up @@ -1314,10 +1277,10 @@ void Scheduler::SchedNewRecords(void)
}
}

void Scheduler::MoveHigherRecords(bool move_this)
void Scheduler::MoveHigherRecords(bool livetv)
{
RecIter i = retrylist.begin();
for ( ; move_this && i != retrylist.end(); ++i)
for ( ; !livetv && i != retrylist.end(); ++i)
{
RecordingInfo *p = *i;
if (p->GetRecordingStatus() != rsUnknown)
Expand Down Expand Up @@ -1352,25 +1315,25 @@ void Scheduler::MoveHigherRecords(bool move_this)

PrintRec(p, " ?");

if (move_this && TryAnotherShowing(p, false))
if (!livetv && TryAnotherShowing(p, false))
continue;

BackupRecStatus();
p->SetRecordingStatus(rsWillRecord);
if (move_this)
if (!livetv)
MarkOtherShowings(p);

RecConstIter k = conflictlist.begin();
for ( ; FindNextConflict(conflictlist, p, k); ++k)
{
if (!TryAnotherShowing(*k, false, !move_this))
if (!TryAnotherShowing(*k, false, livetv))
{
RestoreRecStatus();
break;
}
}

if (move_this && p->GetRecordingStatus() == rsWillRecord)
if (!livetv && p->GetRecordingStatus() == rsWillRecord)
PrintRec(p, " +");
}
}
Expand Down Expand Up @@ -2575,8 +2538,7 @@ bool Scheduler::HandleRecording(
if (!recPendingList[schedid])
{
schedLock.unlock();
nexttv->RecordPending(&tempri, max(secsleft, 0),
hasLaterList.contains(schedid));
nexttv->RecordPending(&tempri, max(secsleft, 0), false);
recPendingList[schedid] = true;
schedLock.lock();
if (reclist_changed)
Expand Down Expand Up @@ -3898,7 +3860,7 @@ void Scheduler::AddNewRecords(void)
}
}

prefinputpri = gCoreContext->GetNumSetting("PrefInputPriority", 2);
int prefinputpri = gCoreContext->GetNumSetting("PrefInputPriority", 2);
int hdtvpriority = gCoreContext->GetNumSetting("HDTVRecPriority", 0);
int wspriority = gCoreContext->GetNumSetting("WSRecPriority", 0);
int slpriority = gCoreContext->GetNumSetting("SignLangRecPriority", 0);
Expand Down Expand Up @@ -5049,7 +5011,7 @@ void Scheduler::FillDirectoryInfoCache(bool force)
fsInfoCacheFillTime = MythDate::current();
}

void Scheduler::SchedPreserveLiveTV(void)
void Scheduler::SchedLiveTV(void)
{
if (!livetvTime.isValid())
return;
Expand All @@ -5060,8 +5022,6 @@ void Scheduler::SchedPreserveLiveTV(void)
return;
}

livetvpriority = gCoreContext->GetNumSetting("LiveTVPriority", 0);

// Build a list of active livetv programs
QMap<int, EncoderLink *>::Iterator enciter = m_tvList->begin();
for (; enciter != m_tvList->end(); ++enciter)
Expand Down Expand Up @@ -5092,7 +5052,7 @@ void Scheduler::SchedPreserveLiveTV(void)
if (retrylist.empty())
return;

MoveHigherRecords(false);
MoveHigherRecords(true);

while (!retrylist.empty())
{
Expand Down
9 changes: 3 additions & 6 deletions mythtv/programs/mythbackend/scheduler.h
Expand Up @@ -133,10 +133,10 @@ class Scheduler : public MThread, public MythScheduler
void BackupRecStatus(void);
void RestoreRecStatus(void);
bool TryAnotherShowing(RecordingInfo *p, bool samePriority,
bool preserveLive = false);
bool livetv = false);
void SchedNewRecords(void);
void MoveHigherRecords(bool move_this = true);
void SchedPreserveLiveTV(void);
void MoveHigherRecords(bool livetv = false);
void SchedLiveTV(void);
void PruneRedundants(void);
void UpdateNextRecord(void);

Expand Down Expand Up @@ -247,9 +247,6 @@ class Scheduler : public MThread, public MythScheduler

// Try to avoid LiveTV sessions until this time
QDateTime livetvTime;
int livetvpriority;
int prefinputpri;
QMap<QString, bool> hasLaterList;

// cache IsSameProgram()
typedef pair<const RecordingInfo*,const RecordingInfo*> IsSameKey;
Expand Down
12 changes: 0 additions & 12 deletions mythtv/programs/mythfrontend/globalsettings.cpp
Expand Up @@ -2180,17 +2180,6 @@ static HostComboBox *LongChannelFormat()
return gc;
}

static GlobalCheckBox *LiveTVPriority()
{
GlobalCheckBox *bc = new GlobalCheckBox("LiveTVPriority");
bc->setLabel(QObject::tr("Allow Live TV to move scheduled shows"));
bc->setValue(false);
bc->setHelpText(QObject::tr("If enabled, scheduled recordings will "
"be moved to other cards (where possible), so that "
"Live TV will not be interrupted."));
return bc;
}

static HostCheckBox *ChannelGroupRememberLast()
{
HostCheckBox *gc = new HostCheckBox("ChannelGroupRememberLast");
Expand Down Expand Up @@ -3356,7 +3345,6 @@ GeneralSettings::GeneralSettings()
general->addChild(ChannelOrdering());
general->addChild(ChannelFormat());
general->addChild(LongChannelFormat());
general->addChild(LiveTVPriority());
addChild(general);

VerticalConfigurationGroup* autoexp = new VerticalConfigurationGroup(false);
Expand Down

0 comments on commit 5173ecb

Please sign in to comment.