Ticket #3326: multirecmjl.patch
| File multirecmjl.patch, 5.3 KB (added by , 18 years ago) |
|---|
-
scheduler.h
87 87 void PruneOverlaps(void); 88 88 void BuildListMaps(void); 89 89 void ClearListMaps(void); 90 boolFindNextConflict(const RecList &cardlist,90 int FindNextConflict(const RecList &cardlist, 91 91 const ProgramInfo *p, RecConstIter &iter, 92 92 bool openEnd = false) const; 93 93 const ProgramInfo *FindConflict(const QMap<int, RecList> &reclists, 94 const ProgramInfo *p, bool openEnd, int *preference) const; 95 const ProgramInfo *FindConflict(const QMap<int, RecList> &reclists, 94 96 const ProgramInfo *p, bool openEnd = false) const; 95 97 void MarkOtherShowings(ProgramInfo *p); 96 98 void MarkShowingsList(RecList &showinglist, ProgramInfo *p); -
scheduler.cpp
278 278 return a->recstartts < b->recstartts; 279 279 } 280 280 281 if(a->title != b->title) 282 { 283 return a->title > b->title; 284 } 285 281 286 if (a->inputid != b->inputid) 282 287 return a->inputid < b->inputid; 283 288 … … 751 756 recordidlistmap.clear(); 752 757 } 753 758 754 boolScheduler::FindNextConflict(759 int Scheduler::FindNextConflict( 755 760 const RecList &cardlist, 756 761 const ProgramInfo *p, 757 762 RecConstIter &j, 758 763 bool openEnd) const 759 764 { 765 bool found_ideal = false; 766 760 767 bool is_conflict_dbg = false; 761 768 762 769 for ( ; j != cardlist.end(); j++) … … 813 820 GetSharedInputGroup(p->inputid, q->inputid) && 814 821 p->GetMplexID() && (p->GetMplexID() == q->GetMplexID())) 815 822 { 823 found_ideal = true; 816 824 continue; 817 825 } 818 826 819 827 if (is_conflict_dbg) 820 828 cout << "\n Found conflict" << endl; 821 829 822 return true;830 return -1; 823 831 } 824 832 825 833 if (is_conflict_dbg) 826 834 cout << "\n No conflict" << endl; 827 835 828 return false; 836 // Actually... give multiplex/inputgroup overlaps a priority. 837 if(found_ideal) 838 { 839 return 1; 840 }else{ 841 return 0; 842 } 829 843 } 830 844 831 845 const ProgramInfo *Scheduler::FindConflict( … … 833 847 const ProgramInfo *p, 834 848 bool openend) const 835 849 { 850 int preference = 0; 851 return FindConflict(reclists, p, openend, &preference); 852 } 853 854 const ProgramInfo *Scheduler::FindConflict( 855 const QMap<int, RecList> &reclists, 856 const ProgramInfo *p, 857 bool openend, int *preference) const 858 { 836 859 bool is_conflict_dbg = false; 837 860 838 861 QMap<int, RecList>::const_iterator it = reclists.begin(); … … 846 869 847 870 const RecList &cardlist = *it; 848 871 RecConstIter k = cardlist.begin(); 849 if (FindNextConflict(cardlist, p, k, openend)) 872 int result = FindNextConflict(cardlist, p, k, openend); 873 if (result < 0) 850 874 { 851 875 return *k; 852 876 } 877 // The more group overlaps the better. 878 *preference += result; 853 879 } 854 880 855 881 return NULL; … … 1050 1076 1051 1077 bool openEnd = (bool)gContext->GetNumSetting("SchedOpenEnd", 0); 1052 1078 1079 int bestpreference = -1; 1080 ProgramInfo *best_program = NULL; 1081 1053 1082 RecIter i = worklist.begin(); 1054 1083 while (i != worklist.end()) 1055 1084 { … … 1058 1087 MarkOtherShowings(p); 1059 1088 else if (p->recstatus == rsUnknown) 1060 1089 { 1061 const ProgramInfo *conflict = FindConflict(cardlistmap, p, openEnd); 1090 int preference = 0; 1091 const ProgramInfo *conflict = FindConflict(cardlistmap, p, openEnd, &preference); 1062 1092 if (!conflict) 1063 1093 { 1094 cout << QString(" No conflict, preference %2 ").arg(preference); 1095 // Decide if this is the best choice, but don't set it stone yet. 1096 if(preference > bestpreference) 1097 { 1098 bestpreference = preference; 1099 best_program = p; 1100 } 1101 } 1102 else 1103 { 1104 retrylist.push_front(p); 1105 PrintRec(p, " #"); 1106 PrintRec(conflict, " !"); 1107 } 1108 } 1109 1110 int lastpri = p->recpriority; 1111 QDateTime lastrecstart = p->recstartts; 1112 const char* lastchanid = p->chanid; 1113 i++; 1114 1115 // If we've moved on to a different program, or the end, save the best showing. 1116 1117 if(i == worklist.end() || lastrecstart != (*i)->recstartts || lastchanid != (*i)->chanid) 1118 { 1119 p = best_program; 1120 if(bestpreference > -1) 1121 { 1064 1122 p->recstatus = rsWillRecord; 1065 1123 1066 1124 if (p->recstartts < schedTime.addSecs(90)) … … 1081 1139 MarkOtherShowings(p); 1082 1140 PrintRec(p, " +"); 1083 1141 } 1084 else 1085 { 1086 retrylist.push_front(p); 1087 PrintRec(p, " #"); 1088 PrintRec(conflict, " !"); 1089 } 1142 bestpreference = -1; 1143 1090 1144 } 1091 1092 int lastpri = p->recpriority; 1093 i++; 1145 1094 1146 if (i == worklist.end() || lastpri != (*i)->recpriority) 1095 1147 { 1096 1148 MoveHigherRecords();
