[mythtv] More scheduling scheduler

Paul Andreassen paulx at andreassen.com.au
Mon Nov 27 12:03:45 UTC 2006


On Mon, 27 Nov 2006 05:15 pm, Kent Williams wrote:
> > -----Original Message-----
> > From: mythtv-dev-bounces at mythtv.org
>
> [mailto:mythtv-dev-bounces at mythtv.org]
>
> > On Behalf Of Paul Andreassen
> > Sent: Sunday, 26 November 2006 6:48 PM
> > To: Development of mythtv
> > Subject: Re: [mythtv] More scheduling scheduler
> >
> > OK, here's the scoop.  In short, the current softpad approach won't be
> > going into trunk.  The main reason is that nobody wants to support it
> > and be responsible for it.
>
> Is it possible to merge it in but leave it disabled, requiring a manual
> setting in the database to enable soft padding so users can't blindly
> enable it?

I thought about this but it isn't really a solution because wants the point if 
only three or four people know about it.

> Or would the issue be maintaining the code through other 
> future changes to the scheduler?

The only scheduler changes needed are :

@@ -480,10 +496,12 @@ bool Scheduler::ChangeRecordingEnd(Progr
     RecordingType oldrectype = oldp->rectype;
     int oldrecordid = oldp->recordid;
     QDateTime oldrecendts = oldp->recendts;
+    int oldsoftend = oldp->softend;
 
     oldp->rectype = newp->rectype;
     oldp->recordid = newp->recordid;
     oldp->recendts = newp->recendts;
+    oldp->softend = 0;
 
     if (specsched)
     {
@@ -506,6 +524,7 @@ bool Scheduler::ChangeRecordingEnd(Progr
         oldp->rectype = oldrectype;
         oldp->recordid = oldrecordid;
         oldp->recendts = oldrecendts;
+        oldp->softend = oldsoftend;
     }
     return rs == rsRecording;
 }
@@ -1942,6 +1952,9 @@ void Scheduler::UpdateMatches(int record
 
 void Scheduler::AddNewRecords(void) 
 {
+    int softStart = gContext->GetNumSetting("SchedSoftStart", 0);
+    int softEnd = gContext->GetNumSetting("SchedSoftEnd", 0);
+
     struct timeval dbstart, dbend;
 
     QMap<RecordingType, int> recTypeRecPriorityMap;
@@ -2262,7 +2275,7 @@ void Scheduler::AddNewRecords(void) 
             if (p->IsSameTimeslot(*r))
             {
                 if (r->inputid == p->inputid &&
-                    r->recendts != p->recendts &&
+                    (r->recendts.addSecs(-60 * r->softend)) != p->recendts &&
                     (r->recordid == p->recordid ||
                      p->rectype == kOverrideRecord))
                     ChangeRecordingEnd(r, p);
@@ -2314,6 +2327,43 @@ void Scheduler::AddNewRecords(void) 
             p->recstatus = rsMissed;
 
         tmpList.push_back(p);
+
+        // Add soft candidates
+        if (p->recstatus == rsUnknown)
+        {
+            if (softStart != 0 && 
+                p->recstartts.addSecs(-60 * softStart) < p->recendts)
+            {
+                ProgramInfo *softp = new ProgramInfo(*p);
+                softp->recstartts = p->recstartts.addSecs(-60 * softStart);
+                softp->softstart = softStart;
+                softp->recpriority2 += 1;
+                tmpList.push_back(softp);
+            }
+
+            if (softEnd != 0 && 
+                p->recstartts < p->recendts.addSecs(60 * softEnd))
+            {
+                ProgramInfo *softp = new ProgramInfo(*p);
+                softp->recendts = p->recendts.addSecs(60 * softEnd);
+                softp->softend = softEnd;
+                softp->recpriority2 += 2;
+                tmpList.push_back(softp);
+            }
+
+            if (softStart != 0 && softEnd != 0 && 
+                p->recstartts.addSecs(-60 * softStart) < 
+                    p->recendts.addSecs(60 * softEnd))
+            {
+                ProgramInfo *softp = new ProgramInfo(*p);
+                softp->recstartts = p->recstartts.addSecs(-60 * softStart);
+                softp->recendts = p->recendts.addSecs(60 * softEnd);
+                softp->softstart = softStart;
+                softp->softend = softEnd;
+                softp->recpriority2 += 3;
+                tmpList.push_back(softp);
+            }
+        }
     }
 
     VERBOSE(VB_SCHEDULE, " +-- Cleanup...");

> Being another Aussie myth user it'd be a shame to see all this work
> which fixes a significant problem for us not go in.
>
> Cheers,
> -Kent

-- 


More information about the mythtv-dev mailing list