| 819 | void WaitToDelete(ProgramInfo *pginfo) |
| 820 | { |
| 821 | VERBOSE(VB_GENERAL, |
| 822 | "Transcode: delete old file: " |
| 823 | "waiting while program is in use."); |
| 824 | unsigned inUse = 1; |
| 825 | MSqlQuery query(MSqlQuery::InitCon()); |
| 826 | while (inUse) |
| 827 | { |
| 828 | query.prepare("SELECT count(*) FROM inuseprograms " |
| 829 | "WHERE chanid = :CHANID " |
| 830 | "AND starttime = :STARTTIME " |
| 831 | "AND recusage != 'jobqueue' ;"); |
| 832 | query.bindValue(":CHANID", pginfo->chanid); |
| 833 | query.bindValue(":STARTTIME", pginfo->recstartts); |
| 834 | if (!query.exec() || !query.next()) |
| 835 | { |
| 836 | VERBOSE(VB_GENERAL, |
| 837 | "Transcode: delete old file: in-use query failed;"); |
| 838 | VERBOSE(VB_GENERAL, |
| 839 | " proceeding with delete of old file."); |
| 840 | return; |
| 841 | } |
| 842 | inUse = query.value(0).toUInt(); |
| 843 | if (inUse) |
| 844 | { |
| 845 | unsigned secondsToWait = 10; |
| 846 | VERBOSE(VB_GENERAL, |
| 847 | QString("Transcode: program in use, " |
| 848 | "rechecking in %1 seconds.").arg(secondsToWait)); |
| 849 | sleep(secondsToWait); |
| 850 | } |
| 851 | } |
| 852 | VERBOSE(VB_GENERAL, "Transcode: program is no longer in use."); |
| 853 | } |
| 854 | |