[mythtv] [PATCH] Soft padding proof of concept

David Engel gigem at comcast.net
Sun Oct 2 01:27:11 UTC 2005


I moved this to a new thread so it doesn't get lost in the noise.

Would the proponents of adding soft padding to the scheduler please
try this patch and provide feedback.  If nobody responds, I'll have to
assume it's not really that important after all and consider the
whole issue closed.

David

On Fri, Sep 30, 2005 at 09:25:52PM -0500, David Engel wrote:
> My quick hack is attached.  It's admittedly going to be somewhat
> inefficient due to its brute force nature.  However, it leverages the
> existing scheduler logic by sticking with the concept of throwing all
> combinations into the mix, assigning priorities (either explicitly or
> implicitly) and seeing what comes out the other end.
> 
> For those that would like to try it, tweak the softstart* and softend*
> assignements at the end of the patch.  For best results, keep
> softendpri >= softstartpri and softendoffset >= softstartoffset.  
> 
> Please note that it breaks changing the end-time of in-progress
> recordings, so that feature is disabled.  It can be fixed.  Also, the
> heuristics used to break ties between equal priorities are
> simple-minded.  They can be improved if needed.

-- 
David Engel
gigem at comcast.net
-------------- next part --------------
Index: programs/mythbackend/scheduler.cpp
===================================================================
--- programs/mythbackend/scheduler.cpp	(revision 7354)
+++ programs/mythbackend/scheduler.cpp	(working copy)
@@ -145,12 +145,12 @@
     return a->recordid < b->recordid;
 }
 
-static bool comp_recstart(ProgramInfo *a, ProgramInfo *b)
+static bool comp_redundant(ProgramInfo *a, ProgramInfo *b)
 {
-    if (a->recstartts != b->recstartts)
-        return a->recstartts < b->recstartts;
-    if (a->recendts != b->recendts)
-        return a->recendts < b->recendts;
+    if (a->startts != b->startts)
+        return a->startts < b->startts;
+    if (a->endts != b->endts)
+        return a->endts < b->endts;
 
     // Note: the PruneRedundants logic depends on the following
     if (a->title != b->title)
@@ -162,6 +162,17 @@
     return a->recstatus < b->recstatus;
 }
 
+static bool comp_recstart(ProgramInfo *a, ProgramInfo *b)
+{
+    if (a->recstartts != b->recstartts)
+        return a->recstartts < b->recstartts;
+    if (a->recendts != b->recendts)
+        return a->recendts < b->recendts;
+    if (a->chansign != b->chansign)
+        return a->chansign < b->chansign;
+    return a->recstatus < b->recstatus;
+}
+
 static QDateTime schedTime;
 static bool schedCardsFirst;
 
@@ -182,6 +193,12 @@
     if (apri != bpri)
         return apri < bpri;
 
+    int alen = a->recstartts.secsTo(a->recendts);
+    int blen = b->recstartts.secsTo(b->recendts);
+
+    if (alen != blen)
+        return alen > blen;
+
     if (a->recstartts != b->recstartts)
     {
         if (apast)
@@ -274,10 +291,13 @@
     ClearListMaps();
 
     VERBOSE(VB_SCHEDULE, "Sort by time...");
-    reclist.sort(comp_recstart);
+    reclist.sort(comp_redundant);
     VERBOSE(VB_SCHEDULE, "PruneRedundants...");
     PruneRedundants();
 
+    VERBOSE(VB_SCHEDULE, "Sort by time...");
+    reclist.sort(comp_recstart);
+
     return hasconflicts;
 }
 
@@ -685,19 +705,15 @@
         p->rectype == kFindWeeklyRecord)
         showinglist = recordidlistmap[p->recordid];
 
+    p->recstatus = rsLaterShowing;
+
     RecIter j = showinglist.begin();
     for ( ; j != showinglist.end(); j++)
     {
         ProgramInfo *q = *j;
         if (q == p)
-            break;
-    }
+            continue;
 
-    p->recstatus = rsLaterShowing;
-
-    for (j++; j != showinglist.end(); j++)
-    {
-        ProgramInfo *q = *j;
         if (q->recstatus != rsEarlierShowing &&
             q->recstatus != rsLaterShowing)
             continue;
@@ -2017,11 +2033,13 @@
             ProgramInfo *r = *rec;
             if (p->IsSameTimeslot(*r))
             {
+#if 0
                 if (r->inputid == p->inputid &&
                     r->recendts != p->recendts &&
                     (r->recordid == p->recordid ||
                      p->rectype == kOverrideRecord))
                     ChangeRecordingEnd(r, p);
+#endif
                 delete p;
                 p = NULL;
                 break;
@@ -2066,6 +2084,32 @@
             p->recstatus = rsMissed;
 
         tmpList.push_back(p);
+
+        // Add soft candidates
+        if (p->recstatus == rsUnknown)
+        {
+            int softstartpri = 0;
+            int softstartoffset = 3;
+            int softendpri = 0;
+            int softendoffset = 10;
+            ProgramInfo *softp;
+
+            softp = new ProgramInfo(*p);
+            softp->recpriority += softstartpri;
+            softp->recstartts = softp->recstartts.addSecs(-60 * softstartoffset + 1);
+            tmpList.push_back(softp);
+
+            softp = new ProgramInfo(*p);
+            softp->recpriority += softendpri;
+            softp->recendts = softp->recendts.addSecs(60 * softendoffset);
+            tmpList.push_back(softp);
+
+            softp = new ProgramInfo(*p);
+            softp->recpriority += softstartpri + softendpri;
+            softp->recstartts = softp->recstartts.addSecs(-60 * softstartoffset + 1);
+            softp->recendts = softp->recendts.addSecs(60 * softendoffset);
+            tmpList.push_back(softp);
+        }
     }
 
     VERBOSE(VB_SCHEDULE, " +-- Cleanup...");


More information about the mythtv-dev mailing list