Ticket #7731: fix_bookmark_3.patch
File fix_bookmark_3.patch, 4.4 KB (added by , 14 years ago) |
---|
-
programs/mythtranscode/main.cpp
28 28 ProgramInfo *pginfo); 29 29 int BuildKeyframeIndex(MPEG2fixup *m2f, QString &infile, 30 30 QMap <long long, long long> &posMap, int jobID); 31 void CompleteJob(int jobID, ProgramInfo *pginfo, 32 bool useCutlist, int &resultCode);31 void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist, 32 QMap <long long, int> *deleteMap, int &resultCode); 33 33 void UpdateJobQueue(float percent_done); 34 34 int CheckJobQueue(); 35 35 static int glbl_jobID = -1; … … 674 674 } 675 675 676 676 if (jobID >= 0) 677 CompleteJob(jobID, pginfo, useCutlist, exitcode);677 CompleteJob(jobID, pginfo, useCutlist, &deleteMap, exitcode); 678 678 679 679 transcode->deleteLater(); 680 680 … … 816 816 return unlink(filename.toLocal8Bit().constData()); 817 817 } 818 818 819 void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist, int &resultCode) 819 long long ComputeNewBookmark(long long oldBookmark, 820 QMap<long long, int> *deleteMap) 820 821 { 822 if (deleteMap == NULL) 823 return oldBookmark; 824 long long subtraction = 0; 825 long long startOfCutRegion = 0; 826 QMap<long long, int> delMap = *deleteMap; 827 bool withinCut = false; 828 while (delMap.count() && delMap.begin().key() <= oldBookmark) 829 { 830 if (delMap.begin().data() == MARK_CUT_START && !withinCut) 831 { 832 withinCut = true; 833 startOfCutRegion = delMap.begin().key(); 834 } 835 else if (delMap.begin().data() == MARK_CUT_END && withinCut) 836 { 837 withinCut = false; 838 subtraction += (delMap.begin().key() - startOfCutRegion); 839 } 840 delMap.remove(delMap.begin()); 841 } 842 if (withinCut) 843 subtraction += (oldBookmark - startOfCutRegion); 844 return oldBookmark - subtraction; 845 } 846 847 long long ReloadBookmark(ProgramInfo *pginfo) 848 { 849 MSqlQuery query(MSqlQuery::InitCon()); 850 long long currentBookmark = 0; 851 query.prepare("SELECT DISTINCT mark FROM recordedmarkup " 852 "WHERE chanid = :CHANID " 853 "AND starttime = :STARTIME " 854 "AND type = :MARKTYPE ;"); 855 query.bindValue(":CHANID", pginfo->chanid); 856 query.bindValue(":STARTTIME", pginfo->recstartts); 857 query.bindValue(":MARKTYPE", MARK_BOOKMARK); 858 if (query.exec() && query.next()) 859 { 860 currentBookmark = query.value(0).toLongLong(); 861 } 862 return currentBookmark; 863 } 864 865 void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist, 866 QMap <long long, int> *deleteMap, int &resultCode) 867 { 821 868 int status = JobQueue::GetJobStatus(jobID); 822 869 823 870 if (!pginfo) … … 832 879 833 880 if (status == JOB_STOPPING) 834 881 { 882 // Transcoding may take several minutes. Reload the bookmark 883 // in case it changed, then save its translated value back. 884 long long previousBookmark = 885 ComputeNewBookmark(ReloadBookmark(pginfo), deleteMap); 886 pginfo->SetBookmark(previousBookmark); 887 835 888 const QString jobArgs = JobQueue::GetJobArgs(jobID); 836 889 837 890 const QString tmpfile = filename + ".tmp"; … … 977 1030 { 978 1031 query.prepare("DELETE FROM recordedmarkup " 979 1032 "WHERE chanid = :CHANID " 980 "AND starttime = :STARTTIME "); 1033 "AND starttime = :STARTTIME " 1034 "AND type != :BOOKMARK "); 981 1035 query.bindValue(":CHANID", pginfo->chanid); 982 1036 query.bindValue(":STARTTIME", pginfo->recstartts); 1037 query.bindValue(":BOOKMARK", MARK_BOOKMARK); 983 1038 984 1039 if (!query.exec()) 985 1040 MythDB::DBError("Error in mythtranscode", query); 986 1041 987 1042 query.prepare("UPDATE recorded " 988 "SET cutlist = :CUTLIST, bookmark = :BOOKMARK,"1043 "SET cutlist = :CUTLIST, " 989 1044 "watched = :WATCHED WHERE chanid = :CHANID " 990 1045 "AND starttime = :STARTTIME ;"); 991 1046 query.bindValue(":CUTLIST", "0"); 992 query.bindValue(":BOOKMARK", "0");993 1047 query.bindValue(":WATCHED", "0"); 994 1048 query.bindValue(":CHANID", pginfo->chanid); 995 1049 query.bindValue(":STARTTIME", pginfo->recstartts);