Skip to content

Commit

Permalink
Services API: Bypass LoadFromScheduler() in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartm committed Mar 26, 2015
1 parent b23a332 commit 119fb55
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
11 changes: 9 additions & 2 deletions mythtv/programs/mythbackend/scheduler.cpp
Expand Up @@ -1715,7 +1715,7 @@ void Scheduler::getConflicting(RecordingInfo *pginfo, RecList *retlist)
}
}

bool Scheduler::GetAllPending(RecList &retList) const
bool Scheduler::GetAllPending(RecList &retList, int recRuleId) const
{
QMutexLocker lockit(&schedLock);

Expand All @@ -1724,6 +1724,9 @@ bool Scheduler::GetAllPending(RecList &retList) const
RecConstIter it = reclist.begin();
for (; it != reclist.end(); ++it)
{
if (recRuleId > 0 &&
(*it)->GetRecordingRuleID() != static_cast<uint>(recRuleId))
continue;
if ((*it)->GetRecordingStatus() == RecStatus::Conflict)
hasconflicts = true;
retList.push_back(new RecordingInfo(**it));
Expand All @@ -1732,7 +1735,7 @@ bool Scheduler::GetAllPending(RecList &retList) const
return hasconflicts;
}

bool Scheduler::GetAllPending(ProgramList &retList) const
bool Scheduler::GetAllPending(ProgramList &retList, int recRuleId) const
{
QMutexLocker lockit(&schedLock);

Expand All @@ -1741,6 +1744,10 @@ bool Scheduler::GetAllPending(ProgramList &retList) const
RecConstIter it = reclist.begin();
for (; it != reclist.end(); ++it)
{
if (recRuleId > 0 &&
(*it)->GetRecordingRuleID() != static_cast<uint>(recRuleId))
continue;

if ((*it)->GetRecordingStatus() == RecStatus::Conflict)
hasconflicts = true;
retList.push_back(new ProgramInfo(**it));
Expand Down
4 changes: 2 additions & 2 deletions mythtv/programs/mythbackend/scheduler.h
Expand Up @@ -62,8 +62,8 @@ class Scheduler : public MThread, public MythScheduler
const QDateTime &recendts);
// Returns a list of all pending recordings and returns
// true iff there are conflicts
bool GetAllPending(RecList &retList) const;
bool GetAllPending(ProgramList &retList) const;
bool GetAllPending(RecList &retList, int recRuleId = 0) const;
bool GetAllPending(ProgramList &retList, int recRuleId = 0) const;
virtual void GetAllPending(QStringList &strList) const;
virtual QMap<QString,ProgramInfo*> GetRecording(void) const;

Expand Down
43 changes: 25 additions & 18 deletions mythtv/programs/mythbackend/services/dvr.cpp
Expand Up @@ -552,26 +552,29 @@ DTC::ProgramList* Dvr::GetUpcomingList( int nStartIndex,
int nRecordId,
int nRecStatus )
{
RecordingList recordingList;
RecordingList tmpList;
bool hasConflicts;
RecordingList recordingList; // Auto-delete deque
RecList tmpList; // Standard deque, objects must be deleted

if (nRecordId <= 0)
nRecordId = -1;

LoadFromScheduler(tmpList, hasConflicts, "", nRecordId);
// NOTE: Fetching this information directly from the schedule is
// significantly faster than using ProgramInfo::LoadFromScheduler()
Scheduler *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
if (scheduler)
scheduler->GetAllPending(tmpList, nRecordId);

// Sort the upcoming into only those which will record
RecordingList::iterator it = tmpList.begin();
RecList::iterator it = tmpList.begin();
for(; it < tmpList.end(); ++it)
{
if (nRecordId > 0 &&
(*it)->GetRecordingRuleID() != static_cast<uint>(nRecordId))
continue;

if ((nRecStatus != 0) &&
((*it)->GetRecordingStatus() != nRecStatus))
{
delete *it;
*it = NULL;
continue;
}

if (!bShowAll && ((((*it)->GetRecordingStatus() >= RecStatus::Failing) &&
((*it)->GetRecordingStatus() <= RecStatus::WillRecord)) ||
Expand All @@ -585,6 +588,9 @@ DTC::ProgramList* Dvr::GetUpcomingList( int nStartIndex,
{
recordingList.push_back(new RecordingInfo(**it));
}

delete *it;
*it = NULL;
}

// ----------------------------------------------------------------------
Expand Down Expand Up @@ -626,28 +632,29 @@ DTC::ProgramList* Dvr::GetConflictList( int nStartIndex,
int nCount,
int nRecordId )
{
RecordingList recordingList;
RecordingList tmpList;
bool hasConflicts;
RecordingList recordingList; // Auto-delete deque
RecList tmpList; // Standard deque, objects must be deleted

if (nRecordId <= 0)
nRecordId = -1;

LoadFromScheduler(tmpList, hasConflicts, "", nRecordId);
// NOTE: Fetching this information directly from the schedule is
// significantly faster than using ProgramInfo::LoadFromScheduler()
Scheduler *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
if (scheduler)
scheduler->GetAllPending(tmpList, nRecordId);

// Sort the upcoming into only those which are conflicts
RecordingList::iterator it = tmpList.begin();
RecList::iterator it = tmpList.begin();
for(; it < tmpList.end(); ++it)
{
if (nRecordId > 0 &&
(*it)->GetRecordingRuleID() != static_cast<uint>(nRecordId))
continue;

if (((*it)->GetRecordingStatus() == RecStatus::Conflict) &&
((*it)->GetRecordingStartTime() >= MythDate::current()))
{
recordingList.push_back(new RecordingInfo(**it));
}
delete *it;
*it = NULL;
}

// ----------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion mythtv/programs/mythbackend/services/guide.cpp
Expand Up @@ -140,7 +140,6 @@ DTC::ProgramGuide *Guide::GetProgramGuide( const QDateTime &rawStartTime ,
// Get all Pending Scheduled Programs
// ----------------------------------------------------------------------

LOG(VB_GENERAL, LOG_NOTICE, "Guide::GetProgramGuide() - GetAllPending");
// NOTE: Fetching this information directly from the schedule is
// significantly faster than using ProgramInfo::LoadFromScheduler()
Scheduler *scheduler = dynamic_cast<Scheduler*>(gCoreContext->GetScheduler());
Expand Down

0 comments on commit 119fb55

Please sign in to comment.