Skip to content

Commit

Permalink
Add mplexid to RecordingInfo for use within the scheduler.
Browse files Browse the repository at this point in the history
This avoids having to repeatedly query the database when checking for
conflicts between virtual tuners.
  • Loading branch information
gigem committed Jun 16, 2013
1 parent 7e250bc commit 23914b0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
9 changes: 8 additions & 1 deletion mythtv/libs/libmythtv/recordinginfo.cpp
Expand Up @@ -104,7 +104,8 @@ RecordingInfo::RecordingInfo(
uint _videoproperties, uint _videoproperties,
uint _audioproperties, uint _audioproperties,
bool _future, bool _future,
int _schedorder) : int _schedorder,
uint _mplexid) :
ProgramInfo( ProgramInfo(
_title, _subtitle, _description, _season, _episode, _title, _subtitle, _description, _season, _episode,
_category, _chanid, _chanstr, _chansign, _channame, _category, _chanid, _chanstr, _chansign, _channame,
Expand All @@ -115,6 +116,7 @@ RecordingInfo::RecordingInfo(
savedrecstatus(rsUnknown), savedrecstatus(rsUnknown),
future(_future), future(_future),
schedorder(_schedorder), schedorder(_schedorder),
mplexid(_mplexid),
desiredrecstartts(_startts), desiredrecstartts(_startts),
desiredrecendts(_endts), desiredrecendts(_endts),
record(NULL) record(NULL)
Expand Down Expand Up @@ -214,6 +216,7 @@ RecordingInfo::RecordingInfo(
savedrecstatus(rsUnknown), savedrecstatus(rsUnknown),
future(false), future(false),
schedorder(0), schedorder(0),
mplexid(0),
desiredrecstartts(_startts), desiredrecstartts(_startts),
desiredrecendts(_endts), desiredrecendts(_endts),
record(NULL) record(NULL)
Expand Down Expand Up @@ -248,6 +251,7 @@ RecordingInfo::RecordingInfo(
savedrecstatus(rsUnknown), savedrecstatus(rsUnknown),
future(false), future(false),
schedorder(0), schedorder(0),
mplexid(0),
desiredrecstartts(), desiredrecstartts(),
desiredrecendts(), desiredrecendts(),
record(NULL) record(NULL)
Expand Down Expand Up @@ -399,6 +403,7 @@ void RecordingInfo::clone(const RecordingInfo &other,
savedrecstatus = other.savedrecstatus; savedrecstatus = other.savedrecstatus;
future = other.future; future = other.future;
schedorder = other.schedorder; schedorder = other.schedorder;
mplexid = other.mplexid;
desiredrecstartts = other.desiredrecstartts; desiredrecstartts = other.desiredrecstartts;
desiredrecendts = other.desiredrecendts; desiredrecendts = other.desiredrecendts;
} }
Expand Down Expand Up @@ -426,6 +431,7 @@ void RecordingInfo::clone(const ProgramInfo &other,
savedrecstatus = rsUnknown; savedrecstatus = rsUnknown;
future = false; future = false;
schedorder = 0; schedorder = 0;
mplexid = 0;
desiredrecstartts = QDateTime(); desiredrecstartts = QDateTime();
desiredrecendts = QDateTime(); desiredrecendts = QDateTime();
} }
Expand All @@ -441,6 +447,7 @@ void RecordingInfo::clear(void)
savedrecstatus = rsUnknown; savedrecstatus = rsUnknown;
future = false; future = false;
schedorder = 0; schedorder = 0;
mplexid = 0;
desiredrecstartts = QDateTime(); desiredrecstartts = QDateTime();
desiredrecendts = QDateTime(); desiredrecendts = QDateTime();
} }
Expand Down
9 changes: 8 additions & 1 deletion mythtv/libs/libmythtv/recordinginfo.h
Expand Up @@ -37,6 +37,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
savedrecstatus(rsUnknown), savedrecstatus(rsUnknown),
future(false), future(false),
schedorder(0), schedorder(0),
mplexid(0),
desiredrecstartts(), desiredrecstartts(),
desiredrecendts(), desiredrecendts(),
record(NULL) {} record(NULL) {}
Expand All @@ -46,6 +47,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
savedrecstatus(other.savedrecstatus), savedrecstatus(other.savedrecstatus),
future(other.future), future(other.future),
schedorder(other.schedorder), schedorder(other.schedorder),
mplexid(other.mplexid),
desiredrecstartts(other.desiredrecstartts), desiredrecstartts(other.desiredrecstartts),
desiredrecendts(other.desiredrecendts), desiredrecendts(other.desiredrecendts),
record(NULL) {} record(NULL) {}
Expand All @@ -55,6 +57,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
savedrecstatus(rsUnknown), savedrecstatus(rsUnknown),
future(false), future(false),
schedorder(0), schedorder(0),
mplexid(0),
desiredrecstartts(startts), desiredrecstartts(startts),
desiredrecendts(endts), desiredrecendts(endts),
record(NULL) {} record(NULL) {}
Expand All @@ -64,6 +67,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
savedrecstatus(rsUnknown), savedrecstatus(rsUnknown),
future(false), future(false),
schedorder(0), schedorder(0),
mplexid(0),
desiredrecstartts(startts), desiredrecstartts(startts),
desiredrecendts(endts), desiredrecendts(endts),
record(NULL) {} record(NULL) {}
Expand All @@ -74,6 +78,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
savedrecstatus(rsUnknown), savedrecstatus(rsUnknown),
future(false), future(false),
schedorder(0), schedorder(0),
mplexid(0),
desiredrecstartts(startts), desiredrecstartts(startts),
desiredrecendts(endts), desiredrecendts(endts),
record(NULL) {} record(NULL) {}
Expand Down Expand Up @@ -140,7 +145,8 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
uint videoproperties, uint videoproperties,
uint audioproperties, uint audioproperties,
bool future, bool future,
int schedorder); int schedorder,
uint mplexid);


/// Create RecordingInfo from 'record'+'channel' tables, /// Create RecordingInfo from 'record'+'channel' tables,
/// user in scheduler.cpp @ ~ 3566 & ~ 3643 /// user in scheduler.cpp @ ~ 3566 & ~ 3643
Expand Down Expand Up @@ -260,6 +266,7 @@ class MTV_PUBLIC RecordingInfo : public ProgramInfo
RecStatusType savedrecstatus; RecStatusType savedrecstatus;
bool future; bool future;
int schedorder; int schedorder;
uint mplexid; // Only valid within the scheduler
QDateTime desiredrecstartts; QDateTime desiredrecstartts;
QDateTime desiredrecendts; QDateTime desiredrecendts;


Expand Down
19 changes: 13 additions & 6 deletions mythtv/programs/mythbackend/scheduler.cpp
Expand Up @@ -848,6 +848,7 @@ void Scheduler::SlaveConnected(RecordingList &slavelist)


if (sp->GetInputID() && !found) if (sp->GetInputID() && !found)
{ {
sp->mplexid = sp->QueryMplexID();
reclist.push_back(new RecordingInfo(*sp)); reclist.push_back(new RecordingInfo(*sp));
reclist_changed = true; reclist_changed = true;
sp->AddHistory(false); sp->AddHistory(false);
Expand Down Expand Up @@ -1084,15 +1085,14 @@ bool Scheduler::FindNextConflict(
.arg(p->GetCardID()).arg(q->GetCardID()) .arg(p->GetCardID()).arg(q->GetCardID())
.arg(igrp.GetSharedInputGroup( .arg(igrp.GetSharedInputGroup(
p->GetInputID(), q->GetInputID())) p->GetInputID(), q->GetInputID()))
.arg(p->QueryMplexID()).arg(q->QueryMplexID())); .arg(p->mplexid).arg(q->mplexid));
} }


// if two inputs are in the same input group we have a conflict // if two inputs are in the same input group we have a conflict
// unless the programs are on the same multiplex. // unless the programs are on the same multiplex.
if (p->GetCardID() != q->GetCardID()) if (p->GetCardID() != q->GetCardID())
{ {
uint p_mplexid = p->QueryMplexID(); if (p->mplexid && (p->mplexid == q->mplexid))
if (p_mplexid && (p_mplexid == q->QueryMplexID()))
continue; continue;
} }


Expand Down Expand Up @@ -1700,6 +1700,7 @@ void Scheduler::AddRecording(const RecordingInfo &pi)
QString("Adding '%1' to reclist.").arg(pi.GetTitle())); QString("Adding '%1' to reclist.").arg(pi.GetTitle()));


RecordingInfo * new_pi = new RecordingInfo(pi); RecordingInfo * new_pi = new RecordingInfo(pi);
new_pi->mplexid = new_pi->QueryMplexID();
reclist.push_back(new_pi); reclist.push_back(new_pi);
reclist_changed = true; reclist_changed = true;


Expand Down Expand Up @@ -3997,7 +3998,8 @@ void Scheduler::AddNewRecords(void)
" p.subtitletypes+0, p.audioprop+0, RECTABLE.storagegroup, "//40-42 " p.subtitletypes+0, p.audioprop+0, RECTABLE.storagegroup, "//40-42
" capturecard.hostname, recordmatch.oldrecstatus, NULL, "//43-45 " capturecard.hostname, recordmatch.oldrecstatus, NULL, "//43-45
" oldrecstatus.future, cardinput.schedorder, " //46-47 " oldrecstatus.future, cardinput.schedorder, " //46-47
" p.syndicatedepisodenumber, p.partnumber, p.parttotal, ") + //48-50 " p.syndicatedepisodenumber, p.partnumber, p.parttotal, " //48-50
" c.mplexid, ") + //51
pwrpri + QString( pwrpri + QString(
"FROM recordmatch " "FROM recordmatch "
"INNER JOIN RECTABLE ON (recordmatch.recordid = RECTABLE.recordid) " "INNER JOIN RECTABLE ON (recordmatch.recordid = RECTABLE.recordid) "
Expand Down Expand Up @@ -4056,6 +4058,10 @@ void Scheduler::AddNewRecords(void)
&& callsign == lastp->GetChannelSchedulingID()) && callsign == lastp->GetChannelSchedulingID())
continue; continue;


uint mplexid = result.value(51).toUInt();
if (mplexid == 32767)
mplexid = 0;

RecordingInfo *p = new RecordingInfo( RecordingInfo *p = new RecordingInfo(
title, title,
result.value(5).toString(),//subtitle result.value(5).toString(),//subtitle
Expand Down Expand Up @@ -4119,7 +4125,8 @@ void Scheduler::AddNewRecords(void)
result.value(39).toUInt(),//videoproperties result.value(39).toUInt(),//videoproperties
result.value(41).toUInt(),//audioproperties result.value(41).toUInt(),//audioproperties
result.value(46).toInt(),//future result.value(46).toInt(),//future
result.value(47).toInt());//schedorder result.value(47).toInt(),//schedorder
mplexid); //mplexid


if (!p->future && !p->IsReactivated() && if (!p->future && !p->IsReactivated() &&
p->oldrecstatus != rsAborted && p->oldrecstatus != rsAborted &&
Expand All @@ -4128,7 +4135,7 @@ void Scheduler::AddNewRecords(void)
p->SetRecordingStatus(p->oldrecstatus); p->SetRecordingStatus(p->oldrecstatus);
} }


p->SetRecordingPriority2(result.value(51).toInt()); p->SetRecordingPriority2(result.value(52).toInt());


// Check to see if the program is currently recording and if // Check to see if the program is currently recording and if
// the end time was changed. Ideally, checking for a new end // the end time was changed. Ideally, checking for a new end
Expand Down

0 comments on commit 23914b0

Please sign in to comment.