Ticket #255: smarter-scheduling.2.020rediff.diff

File smarter-scheduling.2.020rediff.diff, 11.1 KB (added by Paul.Hampson@…, 17 years ago)

Rediff of smarter-schduling.2.diff against 0.20

  • libs/libmythtv/programinfo.cpp

     
    38673867        }
    38683868        message += "\n";
    38693869        delete confList;
     3870
     3871        if (gContext->GetNumSetting("OverTimePriority") == 3
     3872            && (gContext->GetNumSetting("RecordOverTime") > 0 ||
     3873                gContext->GetNumSetting("RecordPreRoll") > 0))
     3874            message +=  QObject::tr("\nYou may be able to eliminate "
     3875                    "conflicts by changing your OverTime setting from "
     3876                    "\"Always\" to something less stringent.\n");
    38703877    }
    38713878
    38723879    DialogBox diag(gContext->GetMainWindow(), message);
  • programs/mythbackend/scheduler.cpp

     
    285285    BuildListMaps();
    286286    VERBOSE(VB_SCHEDULE, "SchedNewRecords...");
    287287    SchedNewRecords();
     288    // If user has a global setting to start recordings early or finish
     289    // them late, we'll see if we can better honour this by finding
     290    // alternate showings.
     291    if(gContext->GetNumSetting("OverTimePriority") > 0
     292       && (gContext->GetNumSetting("RecordOverTime") > 0 ||
     293           gContext->GetNumSetting("RecordPreRoll") > 0))
     294    {
     295        VERBOSE(VB_SCHEDULE, "Sort by time...");
     296        reclist.sort(comp_recstart);
     297       
     298        VERBOSE(VB_SCHEDULE, "ShuffleForOverrecord...");
     299        ShuffleForOverrecord();
     300    }
     301   
    288302    VERBOSE(VB_SCHEDULE, "ClearListMaps...");
    289303    ClearListMaps();
    290304
     
    671685    recordidlistmap.clear();
    672686}
    673687
    674 bool Scheduler::FindNextConflict(RecList &cardlist, ProgramInfo *p, RecIter &j)
     688bool Scheduler::FindNextConflict(RecList &cardlist, ProgramInfo *p, RecIter &j, bool findSoftConflicts)
    675689{
     690
     691    int prerollseconds;
     692    int overrecordseconds;
     693
     694    // A "soft conflict" is when two programs overlap only when the
     695    // global underrecord and overrecord settings are taken into
     696    // consideration.
     697    // We consider them if either:
     698    // (a) the user has specified that he ALWAYS wants the overrecord
     699    //     buffers honoured; or
     700    // (b) the user wants them honoured in some cases, and this is one
     701    //     of those as indicated by the findSoftConflicts flag
     702    if (gContext->GetNumSetting("OverTimePriority") == 3)
     703        findSoftConflicts = 1;
     704
     705    if (findSoftConflicts)
     706    {
     707      prerollseconds    = gContext->GetNumSetting("RecordPreRoll");
     708      overrecordseconds = gContext->GetNumSetting("RecordOverTime");
     709    }
     710
    676711    for ( ; j != cardlist.end(); j++)
    677712    {
    678713        ProgramInfo *q = *j;
     
    683718            continue;
    684719        if (p->cardid != 0 && p->cardid != q->cardid)
    685720            continue;
    686         if (p->recendts <= q->recstartts || p->recstartts >= q->recendts)
    687             continue;
     721        if (findSoftConflicts)
     722        {
     723            if (p->recendts.addSecs(overrecordseconds) <=
     724                        q->recstartts.addSecs((-1) * prerollseconds)
     725               || p->recstartts.addSecs((-1) * prerollseconds) >=
     726                        q->recendts.addSecs(overrecordseconds))
     727                continue;
     728        }
     729        else
     730        {
     731            if (p->recendts <= q->recstartts || p->recstartts >= q->recendts)
     732                continue;
     733        }
    688734        if (p->inputid == q->inputid && p->shareable)
    689735            continue;
    690736
     
    949995    }
    950996}
    951997
     998void Scheduler::ShuffleForOverrecord(void)
     999{
     1000    VERBOSE(VB_SCHEDULE, "Trying to accommodate pre-roll / overrecord:");
     1001
     1002    RecIter i = reclist.begin();
     1003
     1004    for ( ; i != reclist.end(); i++)
     1005    {
     1006        ProgramInfo *p = *i;
     1007
     1008        if (p->recstatus != rsRecording && p->recstatus != rsWillRecord)
     1009            continue;
     1010
     1011        // Look for soft conflicts with any other scheduled program
     1012        RecIter k = reclist.begin();
     1013        if (FindNextConflict(reclist, p, k, true))
     1014        {
     1015            // There's a soft conflict, so let's see if a different
     1016            // showing would give us no conflicts at all.
     1017
     1018            // Get list of alternative showings
     1019            RecList &showinglist = titlelistmap[p->title];
     1020            RecIter j = showinglist.begin();
     1021
     1022            // Cycle through showings, looking for one that won't conflict
     1023            for ( ; j != showinglist.end(); j++)
     1024            {
     1025                ProgramInfo *q = *j;
     1026
     1027                // No need to re-check the same showing
     1028                if (q == p)
     1029                    continue;
     1030
     1031                // Don't consider showings that use a different tuner
     1032                // card if the user has specified he doesn't want this.
     1033                if (gContext->GetNumSetting("OverTimePriority") < 2
     1034                    && p->cardid != q->cardid)
     1035                    continue;
     1036                       
     1037                k = reclist.begin();
     1038                if (!FindNextConflict(reclist, q, k, true))
     1039                {
     1040                    // This showing is completely conflict-free, so
     1041                    // substitute it.
     1042
     1043                    q->recstatus = rsWillRecord;
     1044                    MarkOtherShowings(q);
     1045                    PrintRec(p, "  -");
     1046                    PrintRec(q, "  +");
     1047                    break;
     1048                }
     1049            }
     1050        }
     1051    }
     1052}
     1053
    9521054void Scheduler::getConflicting(ProgramInfo *pginfo, QStringList &strlist)
    9531055{
    9541056    QMutexLocker lockit(reclist_lock);
  • programs/mythbackend/scheduler.h

     
    7878    void PruneOverlaps(void);
    7979    void BuildListMaps(void);
    8080    void ClearListMaps(void);
    81     bool FindNextConflict(RecList &cardlist, ProgramInfo *p, RecIter &iter);
     81    bool FindNextConflict(RecList &cardlist, ProgramInfo *p, RecIter &iter, bool findSoftConflicts = false);
    8282    void MarkOtherShowings(ProgramInfo *p);
    8383    void MarkShowingsList(RecList &showinglist, ProgramInfo *p);
    8484    void BackupRecStatus(void);
     
    8787    void SchedNewRecords(void);
    8888    void MoveHigherRecords(void);
    8989    void PruneRedundants(void);
     90    void ShuffleForOverrecord(void);
    9091
    9192    bool ChangeRecordingEnd(ProgramInfo *oldp, ProgramInfo *newp);
    9293
  • programs/mythfrontend/globalsettings.cpp

     
    626626    bs->setLabel(QObject::tr("Time to record before start of show "
    627627                 "(in seconds)"));
    628628    bs->setHelpText(QObject::tr("This global setting allows the recorder "
    629                     "to start before the scheduled start time. It does "
    630                     "not affect the scheduler. It is ignored when two shows "
    631                     "have been scheduled without enough time in between."));
     629                    "to start before the scheduled start time."));
    632630    bs->setValue(0);
    633631    return bs;
    634632}
     
    639637    bs->setLabel(QObject::tr("Time to record past end of show (in seconds)"));
    640638    bs->setValue(0);
    641639    bs->setHelpText(QObject::tr("This global setting allows the recorder "
    642                     "to record beyond the scheduled end time. It does "
    643                     "not affect the scheduler. It is ignored when two shows "
    644                     "have been scheduled without enough time in between."));
     640                    "to record beyond the scheduled end time."));
    645641    return bs;
    646642}
    647643
     
    652648    ge->setValue(QObject::tr("category name"));
    653649    ge->setHelpText(QObject::tr("For a specific category (e.g. "
    654650                                "\"Sports event\"), request that shows "
    655                                 "be autoextended.  Only works if a "
     651                                "be autoextended. Requires that the "
    656652                                "show's category can be determined."));
    657653    return ge;
    658654}
     
    663659                                          0, 180, 60, true);
    664660    bs->setLabel(QObject::tr("Record past end of show (in minutes)"));
    665661    bs->setValue(30);
    666     bs->setHelpText(QObject::tr("For the specified category, an attempt "
    667                                 "will be made to extend the recording "
    668                                 "by the specified time.  It is ignored "
    669                                 "when two shows have been scheduled "
    670                                 "without enough time in between."));
     662    bs->setHelpText(QObject::tr("For the specified category, attempt "
     663                                "to extend the recording "
     664                                "by the specified time."));
    671665    return bs;
    672666}
    673667
     
    676670    VerticalConfigurationGroup *vcg =
    677671        new VerticalConfigurationGroup(false, false);
    678672
    679     vcg->setLabel(QObject::tr("Category record over-time"));
     673    vcg->setLabel(QObject::tr("Category record OverTime"));
    680674    vcg->setUseLabel(true);
    681675    vcg->addChild(OverTimeCategory());
    682676    vcg->addChild(CategoryOverTime());
    683677    return vcg;
    684678}
    685679
     680
     681static HostComboBox *OverTimePriority()
     682{
     683    HostComboBox *gc = new HostComboBox("OverTimePriority");
     684    gc->setLabel(QObject::tr("Apply OverTime buffers"));
     685    gc->addSelection(QObject::tr("Unless conflict, tuner, or reschedule req'd"), "0");
     686    gc->addSelection(QObject::tr("Unless conflict or extra tuner req'd"), "1");
     687    gc->addSelection(QObject::tr("Unless conflict"), "2");
     688    gc->addSelection(QObject::tr("Always (may create conflicts)"), "3");
     689    gc->setHelpText(QObject::tr("When to record the OverTime buffer "
     690                            "specified above. If desired, "
     691                            "MythTV can assign recordings to an idle "
     692                            "tuner card, record an earlier/later showing, "
     693                            "or even cause a conflict "
     694                            "when necessary to honor the OverTime "
     695                            "settings."));
     696    return gc;
     697}
     698
    686699static HostCheckBox *PlayBoxOrdering()
    687700{
    688701    HostCheckBox *gc = new HostCheckBox("PlayBoxOrdering");
     
    35573570        jobs->addChild(AutoRunUserJob(i));
    35583571    addChild(jobs);
    35593572
     3573    VerticalConfigurationGroup* overtime = new VerticalConfigurationGroup(false);
     3574    overtime->setLabel(QObject::tr("General (OverTime Buffer)"));
     3575    overtime->addChild(RecordPreRoll());
     3576    overtime->addChild(RecordOverTime());
     3577    overtime->addChild(OverTimePriority());
     3578    overtime->addChild(CategoryOverTimeSettings());
     3579    addChild(overtime);
     3580
    35603581    VerticalConfigurationGroup* general2 = new VerticalConfigurationGroup(false);
    35613582    general2->setLabel(QObject::tr("General (Advanced)"));
    3562     general2->addChild(RecordPreRoll());
    3563     general2->addChild(RecordOverTime());
    3564     general2->addChild(CategoryOverTimeSettings());
    35653583    general2->addChild(ATSCCheckSignalThreshold());
    35663584    general2->addChild(ATSCCheckSignalWait());
    35673585    general2->addChild(HDRingbufferSize());
  • programs/mythfrontend/main.cpp

     
    392392    {
    393393        GeneralSettings settings;
    394394        settings.exec();
     395       
     396        // Required if user altered OverTime settings
     397        ScheduledRecording::signalChange(0);
    395398    }
    396399    else if (sel == "settings maingeneral")
    397400    {