Ticket #3326: multirecmjl-v2.patch
| File multirecmjl-v2.patch, 5.0 KB (added by , 18 years ago) |
|---|
-
scheduler.h
102 102 103 103 bool IsSameProgram(const ProgramInfo *a, const ProgramInfo *b) const; 104 104 105 boolFindNextConflict(const RecList &cardlist,105 int FindNextConflict(const RecList &cardlist, 106 106 const ProgramInfo *p, RecConstIter &iter, 107 107 bool openEnd = false) const; 108 const ProgramInfo *FindConflict(const QMap<int, RecList> &reclists, 109 const ProgramInfo *p, bool openEnd = false) const; 108 const ProgramInfo *FindConflict( 109 const QMap<int, RecList> &reclists, const ProgramInfo *p, 110 bool openEnd = false, int *preference = NULL) const; 111 110 112 void MarkOtherShowings(ProgramInfo *p); 111 113 void MarkShowingsList(RecList &showinglist, ProgramInfo *p); 112 114 void BackupRecStatus(void); -
scheduler.cpp
278 278 return a->recstartts < b->recstartts; 279 279 } 280 280 281 if (a->title != b->title) 282 return a->title < b->title; 283 281 284 if (a->inputid != b->inputid) 282 285 return a->inputid < b->inputid; 283 286 … … 793 796 return cache_is_same_program[X] = a->IsSameProgram(*b); 794 797 } 795 798 796 boolScheduler::FindNextConflict(799 int Scheduler::FindNextConflict( 797 800 const RecList &cardlist, 798 801 const ProgramInfo *p, 799 802 RecConstIter &j, 800 803 bool openEnd) const 801 804 { 805 bool found_ideal = false; 802 806 bool is_conflict_dbg = false; 803 807 804 808 for ( ; j != cardlist.end(); j++) … … 855 859 GetSharedInputGroup(p->inputid, q->inputid) && 856 860 p->GetMplexID() && (p->GetMplexID() == q->GetMplexID())) 857 861 { 862 found_ideal = true; 858 863 continue; 859 864 } 860 865 861 866 if (is_conflict_dbg) 862 867 cout << "\n Found conflict" << endl; 863 868 864 return true;869 return -1; 865 870 } 866 871 867 872 if (is_conflict_dbg) 868 873 cout << "\n No conflict" << endl; 869 874 870 return false; 875 // Actually... give multiplex/inputgroup overlaps a priority. 876 return (found_ideal) ? 1 : 0; 871 877 } 872 878 873 879 const ProgramInfo *Scheduler::FindConflict( 874 880 const QMap<int, RecList> &reclists, 875 881 const ProgramInfo *p, 876 bool openend ) const882 bool openend, int *preference) const 877 883 { 878 884 bool is_conflict_dbg = false; 879 885 … … 888 894 889 895 const RecList &cardlist = *it; 890 896 RecConstIter k = cardlist.begin(); 891 i f (FindNextConflict(cardlist, p, k, openend))892 {897 int result = FindNextConflict(cardlist, p, k, openend); 898 if (result < 0) 893 899 return *k; 894 } 900 901 // The more group overlaps the better. 902 if (preference) 903 *preference += result; 895 904 } 896 905 897 906 return NULL; … … 1067 1076 1068 1077 bool openEnd = (bool)gContext->GetNumSetting("SchedOpenEnd", 0); 1069 1078 1079 int bestpreference = -1; 1080 ProgramInfo *best_program = NULL; 1081 1070 1082 RecIter i = worklist.begin(); 1071 1083 while (i != worklist.end()) 1072 1084 { … … 1075 1087 MarkOtherShowings(p); 1076 1088 else if (p->recstatus == rsUnknown) 1077 1089 { 1078 const ProgramInfo *conflict = FindConflict(cardlistmap, p, openEnd); 1090 int preference = 0; 1091 const ProgramInfo *conflict = FindConflict( 1092 cardlistmap, p, openEnd, &preference); 1079 1093 if (!conflict) 1080 1094 { 1095 // Decide if this is the best choice, 1096 // but don't set it stone yet. 1097 if (preference > bestpreference) 1098 { 1099 bestpreference = preference; 1100 best_program = p; 1101 } 1102 } 1103 else 1104 { 1105 retrylist.push_front(p); 1106 PrintRec(p, " #"); 1107 PrintRec(conflict, " !"); 1108 } 1109 } 1110 1111 int lastpri = p->recpriority; 1112 QDateTime lastrecstart = p->recstartts; 1113 const QString &lastchanid = p->chanid; 1114 i++; 1115 1116 // If we've moved on to a different program, or the end, 1117 // save the best showing. 1118 if (i == worklist.end() || lastrecstart != (*i)->recstartts || 1119 lastchanid != (*i)->chanid) 1120 { 1121 p = best_program; 1122 if (bestpreference > -1) 1123 { 1081 1124 p->recstatus = rsWillRecord; 1082 1125 1083 1126 if (p->recstartts < schedTime.addSecs(90)) … … 1093 1136 MarkOtherShowings(p); 1094 1137 PrintRec(p, " +"); 1095 1138 } 1096 else 1097 { 1098 retrylist.push_front(p); 1099 PrintRec(p, " #"); 1100 PrintRec(conflict, " !"); 1101 } 1139 bestpreference = -1; 1102 1140 } 1103 1141 1104 int lastpri = p->recpriority;1105 i++;1106 1142 if (i == worklist.end() || lastpri != (*i)->recpriority) 1107 1143 { 1108 1144 MoveHigherRecords();
