Ticket #3291: preservepadding.patch
File preservepadding.patch, 8.2 KB (added by , 17 years ago) |
---|
-
scheduler.h
85 85 void BuildListMaps(void); 86 86 void ClearListMaps(void); 87 87 bool FindNextConflict(RecList &cardlist, ProgramInfo *p, RecIter &iter, 88 bool openEnd = false );88 bool openEnd = false, bool padded = true); 89 89 void MarkOtherShowings(ProgramInfo *p); 90 90 void MarkShowingsList(RecList &showinglist, ProgramInfo *p); 91 91 void BackupRecStatus(void); -
scheduler.cpp
746 746 } 747 747 748 748 bool Scheduler::FindNextConflict(RecList &cardlist, ProgramInfo *p, RecIter &j, 749 bool openEnd )749 bool openEnd, bool padded) 750 750 { 751 int prepostroll = 0; 752 if(padded){ 753 prepostroll +=(int)gContext->GetNumSetting("RecordPreRoll", 0); 754 prepostroll += (int)gContext->GetNumSetting("RecordOverTime", 0); 755 } 751 756 for ( ; j != cardlist.end(); j++) 752 757 { 753 758 ProgramInfo *q = *j; … … 760 765 continue; 761 766 if (openEnd && p->chanid != q->chanid) 762 767 { 763 if (p->recendts < q->recstartts || p->recstartts > q->recendts)768 if (p->recendts.addSecs(prepostroll) < q->recstartts || p->recstartts > q->recendts.addSecs(prepostroll)) 764 769 continue; 765 770 } 766 771 else 767 772 { 768 if (p->recendts <= q->recstartts || p->recstartts >= q->recendts)773 if (p->recendts.addSecs(prepostroll) <= q->recstartts || p->recstartts >= q->recendts.addSecs(prepostroll) ) 769 774 continue; 770 775 } 771 776 if (p->inputid == q->inputid && p->shareable) … … 862 867 RecStatusType oldstatus = p->recstatus; 863 868 p->recstatus = rsLaterShowing; 864 869 865 RecIter j = showinglist->begin(); 866 for ( ; j != showinglist->end(); j++) 867 { 868 ProgramInfo *q = *j; 869 if (q == p) 870 continue; 870 bool padded = false; 871 do{ // do 2 passes of the scheduler... first with padding, then resolve conflicts by doing it without 871 872 872 if (q->recstatus != rsEarlierShowing && 873 q->recstatus != rsLaterShowing && 874 q->recstatus != rsUnknown) 875 continue; 876 if (!p->IsSameTimeslot(*q)) 873 padded = !padded; 874 875 RecIter j = showinglist->begin(); 876 for ( ; j != showinglist->end(); j++) 877 877 { 878 if (!p->IsSameProgram(*q)) 878 ProgramInfo *q = *j; 879 if (q == p) 879 880 continue; 880 if ((p->rectype == kSingleRecord || 881 p->rectype == kOverrideRecord)) 881 882 if (q->recstatus != rsEarlierShowing && 883 q->recstatus != rsLaterShowing && 884 q->recstatus != rsUnknown) 882 885 continue; 883 if (q->recstartts < schedTime && p->recstartts >= schedTime) 886 if (!p->IsSameTimeslot(*q)) 887 { 888 if (!p->IsSameProgram(*q)) 889 continue; 890 if ((p->rectype == kSingleRecord || 891 p->rectype == kOverrideRecord)) 892 continue; 893 if (q->recstartts < schedTime && p->recstartts >= schedTime) 894 continue; 895 } 896 897 PrintRec(q, " #"); 898 RecList &cardlist = cardlistmap[q->cardid]; 899 RecIter k = cardlist.begin(); 900 if (FindNextConflict(cardlist, q, k, false, padded)) 901 { 902 PrintRec(*k, " !"); 884 903 continue; 904 } 905 padded = false; // Did it with padding no need to do second pass. 906 907 q->recstatus = rsWillRecord; 908 MarkOtherShowings(q); 909 PrintRec(p, " -"); 910 PrintRec(q, " +"); 911 return true; 885 912 } 913 }while(padded); 886 914 887 PrintRec(q, " #");888 RecList &cardlist = cardlistmap[q->cardid];889 RecIter k = cardlist.begin();890 if (FindNextConflict(cardlist, q, k))891 {892 PrintRec(*k, " !");893 continue;894 }895 896 q->recstatus = rsWillRecord;897 MarkOtherShowings(q);898 PrintRec(p, " -");899 PrintRec(q, " +");900 return true;901 }902 903 915 p->recstatus = oldstatus; 904 916 return false; 905 917 } … … 910 922 911 923 bool openEnd = (bool)gContext->GetNumSetting("SchedOpenEnd", 0); 912 924 913 RecIter i = worklist.begin();914 while (i != worklist.end())915 { 916 ProgramInfo *p = *i;917 if (p->recstatus == rsRecording) 918 MarkOtherShowings(p);919 else if (p->recstatus == rsUnknown)925 bool padded = false; 926 do{ // do 2 passes of the scheduler... first with padding, then resolve conflicts by doing it wihtough 927 928 padded = !padded; 929 930 RecIter i = worklist.begin(); 931 while (i != worklist.end()) 920 932 { 921 RecList &cardlist = cardlistmap[p->cardid]; 922 RecIter k = cardlist.begin(); 923 if (!FindNextConflict(cardlist, p, k, openEnd)) 933 ProgramInfo *p = *i; 934 if (p->recstatus == rsRecording) 935 MarkOtherShowings(p); 936 else if (p->recstatus == rsUnknown) 924 937 { 925 p->recstatus = rsWillRecord; 926 MarkOtherShowings(p); 927 PrintRec(p, " +"); 938 RecList &cardlist = cardlistmap[p->cardid]; 939 RecIter k = cardlist.begin(); 940 if (!FindNextConflict(cardlist, p, k, openEnd, padded)) 941 { 942 p->recstatus = rsWillRecord; 943 MarkOtherShowings(p); 944 PrintRec(p, " +"); 945 } 946 else 947 { 948 retrylist.push_front(p); 949 PrintRec(p, " #"); 950 PrintRec(*k, " !"); 951 } 928 952 } 929 else 953 954 int lastpri = p->recpriority; 955 i++; 956 if (i == worklist.end() || lastpri != (*i)->recpriority) 930 957 { 931 retrylist.push_front(p); 932 PrintRec(p, " #"); 933 PrintRec(*k, " !"); 958 MoveHigherRecords(); 959 retrylist.clear(); 934 960 } 935 961 } 936 937 int lastpri = p->recpriority; 938 i++; 939 if (i == worklist.end() || lastpri != (*i)->recpriority) 940 { 941 MoveHigherRecords(); 942 retrylist.clear(); 943 } 944 } 962 }while(padded); 945 963 } 946 964 947 965 void Scheduler::MoveHigherRecords(void) … … 958 976 if (TryAnotherShowing(p)) 959 977 continue; 960 978 961 BackupRecStatus(); 962 p->recstatus = rsWillRecord; 963 MarkOtherShowings(p); 979 bool padded = false; 980 do{ // do 2 passes of the scheduler... first with padding, then resolve conflicts by doing it wihtough 981 982 padded = !padded; 964 983 965 RecList &cardlist = cardlistmap[p->cardid]; 966 RecIter k = cardlist.begin(); 967 for ( ; FindNextConflict(cardlist, p, k); k++) 968 { 969 if ((p->recpriority < (*k)->recpriority && !schedMoveHigher) || 970 !TryAnotherShowing(*k)) 984 BackupRecStatus(); 985 p->recstatus = rsWillRecord; 986 MarkOtherShowings(p); 987 988 RecList &cardlist = cardlistmap[p->cardid]; 989 990 RecIter k = cardlist.begin(); 991 for ( ; FindNextConflict(cardlist, p, k, false, padded); k++) 971 992 { 972 RestoreRecStatus(); 973 break; 993 if ((p->recpriority < (*k)->recpriority && !schedMoveHigher) || 994 !TryAnotherShowing(*k)) 995 { 996 RestoreRecStatus(); 997 break; 998 } 974 999 } 975 } 976 977 if (p->recstatus == rsWillRecord) 978 PrintRec(p, " +"); 1000 if (p->recstatus == rsWillRecord) 1001 { 1002 PrintRec(p, " +"); 1003 padded = false; // moving conflicts worked... no need to try second pass 1004 } 1005 }while(padded); 979 1006 } 980 1007 } 981 1008