diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp
index 1d165c4..6a7ba6d 100644
a
|
b
|
bool Scheduler::ChangeRecordingEnd(RecordingInfo *oldp, RecordingInfo *newp) |
690 | 690 | } |
691 | 691 | |
692 | 692 | EncoderLink *tv = (*m_tvList)[oldp->GetCardID()]; |
| 693 | lockit.unlock(); |
693 | 694 | RecStatusType rs = tv->StartRecording(oldp); |
| 695 | lockit.relock(); |
694 | 696 | if (rs != rsRecording) |
695 | 697 | { |
696 | 698 | LOG(VB_GENERAL, LOG_ERR, |
… |
… |
void Scheduler::SlaveDisconnected(uint cardid) |
817 | 819 | |
818 | 820 | void Scheduler::BuildWorkList(void) |
819 | 821 | { |
820 | | reclist_changed = false; |
821 | | |
822 | 822 | RecIter i = reclist.begin(); |
823 | 823 | for (; i != reclist.end(); ++i) |
824 | 824 | { |
… |
… |
void Scheduler::run(void) |
1795 | 1795 | |
1796 | 1796 | while (doRun) |
1797 | 1797 | { |
| 1798 | reclist_changed = false; |
| 1799 | |
1798 | 1800 | QDateTime curtime = QDateTime::currentDateTime(); |
1799 | 1801 | bool statuschanged = false; |
1800 | 1802 | int secs_to_next = (startIter != reclist.end()) ? |
… |
… |
void Scheduler::run(void) |
1905 | 1907 | **it, statuschanged, prerollseconds, tuningTimeout); |
1906 | 1908 | } |
1907 | 1909 | |
| 1910 | // HandleRecording() and HandleTuning() temporarily unlocks |
| 1911 | // schedLock. If anything changed, reclist iterators could be |
| 1912 | // invalidated so start over. |
| 1913 | if (reclist_changed) |
| 1914 | continue; |
| 1915 | |
1908 | 1916 | /// Wake any slave backends that need waking |
1909 | 1917 | curtime = QDateTime::currentDateTime(); |
1910 | 1918 | for (RecIter it = startIter; it != reclist.end(); ++it) |
… |
… |
bool Scheduler::HandleRecording( |
2283 | 2291 | if (ri.GetRecordingStatus() == rsTuning) |
2284 | 2292 | { |
2285 | 2293 | HandleTuning(ri, statuschanged, tuningTimeout); |
2286 | | return false; |
| 2294 | return reclist_changed; |
2287 | 2295 | } |
2288 | 2296 | |
2289 | 2297 | if (ri.GetRecordingStatus() != rsWillRecord) |
… |
… |
bool Scheduler::HandleRecording( |
2351 | 2359 | return false; |
2352 | 2360 | } |
2353 | 2361 | |
2354 | | if ((prerollseconds > 0) && !IsBusyRecording(&ri)) |
| 2362 | schedLock.unlock(); |
| 2363 | bool isBusyRecording = IsBusyRecording(&ri); |
| 2364 | schedLock.lock(); |
| 2365 | if (reclist_changed) |
| 2366 | return reclist_changed; |
| 2367 | |
| 2368 | if ((prerollseconds > 0) && !isBusyRecording) |
2355 | 2369 | { |
2356 | 2370 | // Will use pre-roll settings only if no other |
2357 | 2371 | // program is currently being recorded |
… |
… |
bool Scheduler::HandleRecording( |
2444 | 2458 | { |
2445 | 2459 | if (ri.GetRecordingStatus() == rsWillRecord) |
2446 | 2460 | { |
| 2461 | schedLock.unlock(); |
2447 | 2462 | recStatus = nexttv->StartRecording(&ri); |
2448 | | ri.AddHistory(false); |
| 2463 | schedLock.lock(); |
2449 | 2464 | |
2450 | 2465 | // activate auto expirer |
2451 | 2466 | if (m_expirer) |
… |
… |
bool Scheduler::HandleRecording( |
2456 | 2471 | HandleRecordingStatusChange(ri, recStatus, details); |
2457 | 2472 | statuschanged = true; |
2458 | 2473 | |
2459 | | return false; |
| 2474 | return reclist_changed; |
2460 | 2475 | } |
2461 | 2476 | |
2462 | 2477 | void Scheduler::HandleRecordingStatusChange( |
… |
… |
void Scheduler::HandleRecordingStatusChange( |
2467 | 2482 | |
2468 | 2483 | ri.SetRecordingStatus(recStatus); |
2469 | 2484 | |
2470 | | if (rsTuning != recStatus) |
2471 | | { |
2472 | | bool doSchedAfterStart = |
2473 | | ((rsRecording != recStatus) && (rsTuning != recStatus)) || |
2474 | | schedAfterStartMap[ri.GetRecordingRuleID()] || |
2475 | | (ri.GetParentRecordingRuleID() && |
2476 | | schedAfterStartMap[ri.GetParentRecordingRuleID()]); |
2477 | | ri.AddHistory(doSchedAfterStart); |
2478 | | } |
| 2485 | bool doSchedAfterStart = |
| 2486 | recStatus != rsTuning && |
| 2487 | (recStatus != rsRecording || |
| 2488 | schedAfterStartMap[ri.GetRecordingRuleID()] || |
| 2489 | (ri.GetParentRecordingRuleID() && |
| 2490 | schedAfterStartMap[ri.GetParentRecordingRuleID()])); |
| 2491 | ri.AddHistory(doSchedAfterStart); |
2479 | 2492 | |
2480 | 2493 | QString msg = (rsRecording == recStatus) ? |
2481 | 2494 | QString("Started recording") : |
… |
… |
void Scheduler::HandleTuning( |
2516 | 2529 | } |
2517 | 2530 | else if (tuningTimeout > 0) |
2518 | 2531 | { |
| 2532 | schedLock.unlock(); |
2519 | 2533 | recStatus = (*tvit)->GetRecordingStatus(); |
| 2534 | schedLock.lock(); |
| 2535 | if (reclist_changed) |
| 2536 | return; |
| 2537 | |
2520 | 2538 | if (rsTuning == recStatus) |
2521 | 2539 | { |
2522 | 2540 | // If tuning is still taking place this long after we |