diff --git a/mythtv/programs/mythbackend/mainserver.cpp b/mythtv/programs/mythbackend/mainserver.cpp
index ef16e5539c..f7048351ce 100644
a
|
b
|
void MainServer::HandleAnnounce(QStringList &slist, QStringList commands, |
1863 | 1863 | |
1864 | 1864 | bool wasAsleep = true; |
1865 | 1865 | TVRec::s_inputsLock.lockForRead(); |
| 1866 | #if 1 // KdW test |
| 1867 | for (auto iter = m_encoderList->begin(); iter != m_encoderList->end(); ++iter) |
| 1868 | { |
| 1869 | EncoderLink *elink = *iter; |
| 1870 | #else |
1866 | 1871 | foreach (auto elink, *m_encoderList) |
1867 | 1872 | { |
| 1873 | #endif |
1868 | 1874 | if (elink->GetHostName() == commands[2]) |
1869 | 1875 | { |
1870 | 1876 | if (! (elink->IsWaking() || elink->IsAsleep())) |
… |
… |
void MainServer::DoHandleStopRecording( |
2919 | 2925 | |
2920 | 2926 | elink->StopRecording(); |
2921 | 2927 | |
| 2928 | // KdW test -- Crash test loop |
| 2929 | #if 0 |
| 2930 | for (int i=0; i<200000; i++) |
| 2931 | { |
| 2932 | int j = 0; |
| 2933 | for (auto iter2 = m_encoderList->begin(); iter2 != m_encoderList->end(); ++iter2) // crash in here |
| 2934 | // for (auto iter2 = m_encoderList->cbegin(); iter2 != m_encoderList->cend(); ++iter2) // no crash when using const |
| 2935 | { |
| 2936 | j++; |
| 2937 | EncoderLink *elink2 = *iter2; |
| 2938 | if (elink2->IsLocal()) |
| 2939 | { |
| 2940 | (void) iter2.key(); |
| 2941 | } |
| 2942 | } |
| 2943 | } |
| 2944 | #endif |
| 2945 | |
2922 | 2946 | while (elink->IsBusyRecording() || |
2923 | 2947 | elink->GetState() == kState_ChangingState) |
2924 | 2948 | { |
… |
… |
void MainServer::HandleLockTuner(PlaybackSock *pbs, int cardid) |
4238 | 4262 | QString enchost; |
4239 | 4263 | |
4240 | 4264 | TVRec::s_inputsLock.lockForRead(); |
| 4265 | #if 1 // KdW test |
| 4266 | QMap<int, EncoderLink *>::Iterator iter = m_encoderList->begin(); |
| 4267 | for (; iter != m_encoderList->end(); ++iter) |
| 4268 | { |
| 4269 | EncoderLink *elink = *iter; |
| 4270 | #else |
4241 | 4271 | foreach (auto elink, *m_encoderList) |
4242 | 4272 | { |
| 4273 | #endif |
4243 | 4274 | // we're looking for a specific card but this isn't the one we want |
4244 | 4275 | if ((cardid != -1) && (cardid != elink->GetInputID())) |
4245 | 4276 | continue; |
… |
… |
void MainServer::HandleGetFreeInputInfo(PlaybackSock *pbs, |
4363 | 4394 | // Lopp over each encoder and divide the inputs into busy and free |
4364 | 4395 | // lists. |
4365 | 4396 | TVRec::s_inputsLock.lockForRead(); |
| 4397 | #if 1 // KdW test |
| 4398 | QMap<int, EncoderLink *>::Iterator iter = m_encoderList->begin(); |
| 4399 | for (; iter != m_encoderList->end(); ++iter) |
| 4400 | { |
| 4401 | EncoderLink *elink = *iter; |
| 4402 | #else |
4366 | 4403 | foreach (auto elink, *m_encoderList) |
4367 | 4404 | { |
| 4405 | #endif |
4368 | 4406 | InputInfo info; |
4369 | 4407 | info.m_inputId = elink->GetInputID(); |
4370 | 4408 | |
… |
… |
void MainServer::HandleSetChannelInfo(QStringList &slist, PlaybackSock *pbs) |
4895 | 4933 | } |
4896 | 4934 | |
4897 | 4935 | TVRec::s_inputsLock.lockForRead(); |
| 4936 | #if 1 // KdW test |
| 4937 | QMap<int, EncoderLink *>::iterator it = m_encoderList->begin(); |
| 4938 | for (; it != m_encoderList->end(); ++it) |
| 4939 | { |
| 4940 | if (*it) |
| 4941 | { |
| 4942 | ok &= (*it)->SetChannelInfo(chanid, sourceid, oldcnum, |
| 4943 | callsign, channum, channame, xmltv); |
| 4944 | } |
| 4945 | } |
| 4946 | #else |
4898 | 4947 | foreach (auto & encoder, *m_encoderList) |
4899 | 4948 | { |
4900 | 4949 | if (encoder) |
… |
… |
void MainServer::HandleSetChannelInfo(QStringList &slist, PlaybackSock *pbs) |
4903 | 4952 | callsign, channum, channame, xmltv); |
4904 | 4953 | } |
4905 | 4954 | } |
| 4955 | #endif |
4906 | 4956 | TVRec::s_inputsLock.unlock(); |
4907 | 4957 | |
4908 | 4958 | retlist << ((ok) ? "1" : "0"); |
… |
… |
size_t MainServer::GetCurrentMaxBitrate(void) |
5091 | 5141 | size_t totalKBperMin = 0; |
5092 | 5142 | |
5093 | 5143 | TVRec::s_inputsLock.lockForRead(); |
| 5144 | #if 1 // KdW test |
| 5145 | QMap<int, EncoderLink*>::iterator it = m_encoderList->begin(); |
| 5146 | for (; it != m_encoderList->end(); ++it) |
| 5147 | { |
| 5148 | EncoderLink *enc = *it; |
| 5149 | #else |
5094 | 5150 | foreach (auto enc, *m_encoderList) |
5095 | 5151 | { |
| 5152 | #endif |
5096 | 5153 | if (!enc->IsConnected() || !enc->IsBusy()) |
5097 | 5154 | continue; |
5098 | 5155 | |
… |
… |
void MainServer::HandleIsRecording(QStringList &slist, PlaybackSock *pbs) |
7328 | 7385 | QStringList retlist; |
7329 | 7386 | |
7330 | 7387 | TVRec::s_inputsLock.lockForRead(); |
| 7388 | #if 1 // KdW test |
| 7389 | QMap<int, EncoderLink *>::Iterator iter = m_encoderList->begin(); |
| 7390 | for (; iter != m_encoderList->end(); ++iter) |
| 7391 | { |
| 7392 | EncoderLink *elink = *iter; |
| 7393 | #else |
7331 | 7394 | foreach (auto elink, *m_encoderList) |
7332 | 7395 | { |
| 7396 | #endif |
7333 | 7397 | if (elink->IsBusyRecording()) { |
7334 | 7398 | RecordingsInProgress++; |
7335 | 7399 | |
… |
… |
void MainServer::connectionClosed(MythSocket *socket) |
7793 | 7857 | |
7794 | 7858 | bool isFallingAsleep = true; |
7795 | 7859 | TVRec::s_inputsLock.lockForRead(); |
| 7860 | #if 1 // KdW test |
| 7861 | QMap<int, EncoderLink *>::Iterator iter = m_encoderList->begin(); |
| 7862 | for (; iter != m_encoderList->end(); ++iter) |
| 7863 | { |
| 7864 | EncoderLink *elink = *iter; |
| 7865 | #else |
7796 | 7866 | foreach (auto elink, *m_encoderList) |
7797 | 7867 | { |
| 7868 | #endif |
7798 | 7869 | if (elink->GetSocket() == pbs) |
7799 | 7870 | { |
7800 | 7871 | if (!elink->IsFallingAsleep()) |
… |
… |
void MainServer::connectionClosed(MythSocket *socket) |
7834 | 7905 | if (chain->HostSocketCount() == 0) |
7835 | 7906 | { |
7836 | 7907 | TVRec::s_inputsLock.lockForRead(); |
| 7908 | #if 1 // KdW test |
| 7909 | for (auto it2 = m_encoderList->begin(); it2 != m_encoderList->end(); ++it2) |
| 7910 | { |
| 7911 | EncoderLink *enc = *it2; |
| 7912 | #else |
7837 | 7913 | foreach (auto enc, *m_encoderList) |
7838 | 7914 | { |
| 7915 | #endif |
7839 | 7916 | if (enc->IsLocal()) |
7840 | 7917 | { |
7841 | 7918 | while (enc->GetState() == kState_ChangingState) |
… |
… |
void MainServer::reconnectTimeout(void) |
8181 | 8258 | QStringList strlist( str ); |
8182 | 8259 | |
8183 | 8260 | TVRec::s_inputsLock.lockForRead(); |
| 8261 | #if 1 // KdW test |
| 8262 | QMap<int, EncoderLink *>::Iterator iter = m_encoderList->begin(); |
| 8263 | for (; iter != m_encoderList->end(); ++iter) |
| 8264 | { |
| 8265 | EncoderLink *elink = *iter; |
| 8266 | #else |
8184 | 8267 | foreach (auto elink, *m_encoderList) |
8185 | 8268 | { |
| 8269 | #endif |
8186 | 8270 | elink->CancelNextRecording(true); |
8187 | 8271 | ProgramInfo *pinfo = elink->GetRecording(); |
8188 | 8272 | if (pinfo) |
… |
… |
void MainServer::UpdateSystemdStatus (void) |
8354 | 8438 | { |
8355 | 8439 | int active = 0; |
8356 | 8440 | TVRec::s_inputsLock.lockForRead(); |
| 8441 | #if 1 // KdW test HIT |
| 8442 | for (auto iter = m_encoderList->begin(); iter != m_encoderList->end(); ++iter) |
| 8443 | { |
| 8444 | EncoderLink *elink = *iter; |
| 8445 | #else |
8357 | 8446 | foreach (auto elink, *m_encoderList) |
8358 | 8447 | { |
| 8448 | #endif |
8359 | 8449 | if (not elink->IsLocal()) |
8360 | 8450 | continue; |
8361 | 8451 | switch (elink->GetState()) |
diff --git a/mythtv/programs/mythbackend/scheduler.cpp b/mythtv/programs/mythbackend/scheduler.cpp
index 2a1173df95..25277a8909 100644
a
|
b
|
void Scheduler::HandleWakeSlave(RecordingInfo &ri, int prerollseconds) |
2607 | 2607 | "to reschedule around its tuners.") |
2608 | 2608 | .arg(nexttv->GetHostName())); |
2609 | 2609 | |
| 2610 | #if 1 // KdW test |
| 2611 | QMap<int, EncoderLink*>::iterator it = m_tvList->begin(); |
| 2612 | for (; it != m_tvList->end(); ++it) |
| 2613 | { |
| 2614 | if ((*it)->GetHostName() == nexttv->GetHostName()) |
| 2615 | (*it)->SetSleepStatus(sStatus_Undefined); |
| 2616 | } |
| 2617 | #else |
2610 | 2618 | foreach (auto & enc, *m_tvList) |
2611 | 2619 | { |
2612 | 2620 | if (enc->GetHostName() == nexttv->GetHostName()) |
2613 | 2621 | enc->SetSleepStatus(sStatus_Undefined); |
2614 | 2622 | } |
| 2623 | #endif |
2615 | 2624 | |
2616 | 2625 | EnqueuePlace("HandleWakeSlave3"); |
2617 | 2626 | } |
… |
… |
bool Scheduler::HandleRecording( |
2764 | 2773 | "to reschedule around its tuners.") |
2765 | 2774 | .arg(nexttv->GetHostName())); |
2766 | 2775 | |
| 2776 | #if 1 // KdW test |
| 2777 | QMap<int, EncoderLink *>::Iterator enciter = |
| 2778 | m_tvList->begin(); |
| 2779 | for (; enciter != m_tvList->end(); ++enciter) |
| 2780 | { |
| 2781 | EncoderLink *enc = *enciter; |
| 2782 | #else |
2767 | 2783 | foreach (auto enc, *m_tvList) |
2768 | 2784 | { |
| 2785 | #endif |
2769 | 2786 | if (enc->GetHostName() == nexttv->GetHostName()) |
2770 | 2787 | enc->SetSleepStatus(sStatus_Undefined); |
2771 | 2788 | } |
… |
… |
void Scheduler::PutInactiveSlavesToSleep(void) |
3452 | 3469 | QReadLocker tvlocker(&TVRec::s_inputsLock); |
3453 | 3470 | |
3454 | 3471 | bool someSlavesCanSleep = false; |
| 3472 | #if 1 // KdW test |
| 3473 | QMap<int, EncoderLink *>::Iterator enciter = m_tvList->begin(); |
| 3474 | for (; enciter != m_tvList->end(); ++enciter) |
| 3475 | { |
| 3476 | EncoderLink *enc = *enciter; |
| 3477 | #else |
3455 | 3478 | foreach (auto enc, *m_tvList) |
3456 | 3479 | { |
| 3480 | #endif |
3457 | 3481 | if (enc->CanSleep()) |
3458 | 3482 | someSlavesCanSleep = true; |
3459 | 3483 | } |
… |
… |
void Scheduler::PutInactiveSlavesToSleep(void) |
3533 | 3557 | LOG(VB_SCHEDULE, LOG_DEBUG, QString(" Shutting down slaves which will " |
3534 | 3558 | "be inactive for the next %1 minutes and can be put to sleep.") |
3535 | 3559 | .arg(sleepThreshold / 60)); |
3536 | | |
| 3560 | #if 1 // KdW test |
| 3561 | enciter = m_tvList->begin(); |
| 3562 | for (; enciter != m_tvList->end(); ++enciter) |
| 3563 | { |
| 3564 | EncoderLink *enc = *enciter; |
| 3565 | #else |
3537 | 3566 | foreach (auto enc, *m_tvList) |
3538 | 3567 | { |
| 3568 | #endif |
3539 | 3569 | if ((!enc->IsLocal()) && |
3540 | 3570 | (enc->IsAwake()) && |
3541 | 3571 | (!SlavesInUse.contains(enc->GetHostName())) && |
… |
… |
void Scheduler::PutInactiveSlavesToSleep(void) |
3558 | 3588 | |
3559 | 3589 | if (enc->GoToSleep()) |
3560 | 3590 | { |
| 3591 | #if 1 // KdW test |
| 3592 | QMap<int, EncoderLink *>::Iterator slviter = |
| 3593 | m_tvList->begin(); |
| 3594 | for (; slviter != m_tvList->end(); ++slviter) |
| 3595 | { |
| 3596 | EncoderLink *slv = *slviter; |
| 3597 | #else |
3561 | 3598 | foreach (auto slv, *m_tvList) |
3562 | 3599 | { |
| 3600 | #endif |
3563 | 3601 | if (slv->GetHostName() == thisHost) |
3564 | 3602 | { |
3565 | 3603 | LOG(VB_SCHEDULE, LOG_DEBUG, |
… |
… |
void Scheduler::PutInactiveSlavesToSleep(void) |
3576 | 3614 | LOG(VB_GENERAL, LOG_ERR, LOC + |
3577 | 3615 | QString("Unable to shutdown %1 slave backend, setting " |
3578 | 3616 | "sleep status to undefined.").arg(thisHost)); |
| 3617 | #if 1 // KdW test |
| 3618 | QMap<int, EncoderLink *>::Iterator slviter = |
| 3619 | m_tvList->begin(); |
| 3620 | for (; slviter != m_tvList->end(); ++slviter) |
| 3621 | { |
| 3622 | EncoderLink *slv = *slviter; |
| 3623 | #else |
3579 | 3624 | foreach (auto slv, *m_tvList) |
3580 | 3625 | { |
| 3626 | #endif |
3581 | 3627 | if (slv->GetHostName() == thisHost) |
3582 | 3628 | slv->SetSleepStatus(sStatus_Undefined); |
3583 | 3629 | } |
… |
… |
bool Scheduler::WakeUpSlave(const QString& slaveHostname, bool setWakingStatus) |
3605 | 3651 | LOG(VB_GENERAL, LOG_NOTICE, |
3606 | 3652 | QString("Trying to Wake Up %1, but this slave " |
3607 | 3653 | "does not have a WakeUpCommand set.").arg(slaveHostname)); |
3608 | | |
| 3654 | #if 1 // KdW test |
| 3655 | QMap<int, EncoderLink *>::Iterator enciter = m_tvList->begin(); |
| 3656 | for (; enciter != m_tvList->end(); ++enciter) |
| 3657 | { |
| 3658 | EncoderLink *enc = *enciter; |
| 3659 | #else |
3609 | 3660 | foreach (auto enc, *m_tvList) |
3610 | 3661 | { |
| 3662 | #endif |
3611 | 3663 | if (enc->GetHostName() == slaveHostname) |
3612 | 3664 | enc->SetSleepStatus(sStatus_Undefined); |
3613 | 3665 | } |
… |
… |
bool Scheduler::WakeUpSlave(const QString& slaveHostname, bool setWakingStatus) |
3616 | 3668 | } |
3617 | 3669 | |
3618 | 3670 | QDateTime curtime = MythDate::current(); |
| 3671 | #if 1 // KdW test |
| 3672 | QMap<int, EncoderLink *>::Iterator enciter = m_tvList->begin(); |
| 3673 | for (; enciter != m_tvList->end(); ++enciter) |
| 3674 | { |
| 3675 | EncoderLink *enc = *enciter; |
| 3676 | #else |
3619 | 3677 | foreach (auto enc, *m_tvList) |
3620 | 3678 | { |
| 3679 | #endif |
3621 | 3680 | if (setWakingStatus && (enc->GetHostName() == slaveHostname)) |
3622 | 3681 | enc->SetSleepStatus(sStatus_Waking); |
3623 | 3682 | enc->SetLastWakeTime(curtime); |
… |
… |
void Scheduler::WakeUpSlaves(void) |
3640 | 3699 | |
3641 | 3700 | QStringList SlavesThatCanWake; |
3642 | 3701 | QString thisSlave; |
| 3702 | #if 1 // KdW test |
| 3703 | QMap<int, EncoderLink *>::Iterator enciter = m_tvList->begin(); |
| 3704 | for (; enciter != m_tvList->end(); ++enciter) |
| 3705 | { |
| 3706 | EncoderLink *enc = *enciter; |
| 3707 | #else |
3643 | 3708 | foreach (auto enc, *m_tvList) |
3644 | 3709 | { |
| 3710 | #endif |
3645 | 3711 | if (enc->IsLocal()) |
3646 | 3712 | continue; |
3647 | 3713 | |
… |
… |
void Scheduler::AddNewRecords(void) |
4314 | 4380 | RecList tmpList; |
4315 | 4381 | |
4316 | 4382 | QMap<int, bool> cardMap; |
| 4383 | #if 1 // KdW test HIT |
| 4384 | QMap<int, EncoderLink *>::Iterator enciter = m_tvList->begin(); |
| 4385 | for (; enciter != m_tvList->end(); ++enciter) |
| 4386 | { |
| 4387 | EncoderLink *enc = *enciter; |
| 4388 | #else |
4317 | 4389 | foreach (auto enc, *m_tvList) |
4318 | 4390 | { |
| 4391 | #endif |
4319 | 4392 | if (enc->IsConnected() || enc->IsAsleep()) |
4320 | 4393 | cardMap[enc->GetInputID()] = true; |
4321 | 4394 | } |
… |
… |
int Scheduler::FillRecordingDir( |
5447 | 5520 | QString backuppath = expire->GetPathname(); |
5448 | 5521 | ProgramInfo *programinfo = expire; |
5449 | 5522 | bool foundSlave = false; |
5450 | | |
| 5523 | #if 1 // KdW test |
| 5524 | QMap<int, EncoderLink *>::Iterator enciter = |
| 5525 | m_tvList->begin(); |
| 5526 | for (; enciter != m_tvList->end(); ++enciter) |
| 5527 | { |
| 5528 | if ((*enciter)->GetHostName() == |
| 5529 | programinfo->GetHostname()) |
| 5530 | { |
| 5531 | (*enciter)->CheckFile(programinfo); |
| 5532 | foundSlave = true; |
| 5533 | break; |
| 5534 | } |
| 5535 | } |
| 5536 | #else |
5451 | 5537 | foreach (auto & enc, *m_tvList) |
5452 | 5538 | { |
5453 | 5539 | if (enc->GetHostName() == |
… |
… |
int Scheduler::FillRecordingDir( |
5458 | 5544 | break; |
5459 | 5545 | } |
5460 | 5546 | } |
| 5547 | #endif |
5461 | 5548 | if (foundSlave && |
5462 | 5549 | programinfo->GetPathname() == filename) |
5463 | 5550 | { |
… |
… |
void Scheduler::SchedLiveTV(void) |
5606 | 5693 | return; |
5607 | 5694 | |
5608 | 5695 | // Build a list of active livetv programs |
| 5696 | #if 1 // KdW test |
| 5697 | QMap<int, EncoderLink *>::Iterator enciter = m_tvList->begin(); |
| 5698 | for (; enciter != m_tvList->end(); ++enciter) |
| 5699 | { |
| 5700 | EncoderLink *enc = *enciter; |
| 5701 | #else |
5609 | 5702 | foreach (auto enc, *m_tvList) |
5610 | 5703 | { |
| 5704 | #endif |
5611 | 5705 | if (kState_WatchingLiveTV != enc->GetState()) |
5612 | 5706 | continue; |
5613 | 5707 | |