From 1df6a87249291566d978f3d104ca68dbb075b37b Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Thu, 16 Jan 2014 11:57:54 +0100 Subject: Now waiting explicitly until all CAM slots are ready before switching to the initial channel when VDR is started --- ci.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'ci.c') diff --git a/ci.c b/ci.c index 90903fbd..1d55ca7f 100644 --- a/ci.c +++ b/ci.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: ci.c 3.7 2014/01/15 10:20:48 kls Exp $ + * $Id: ci.c 3.8 2014/01/16 11:43:33 kls Exp $ */ #include "ci.h" @@ -1536,15 +1536,6 @@ void cCiAdapter::AddCamSlot(cCamSlot *CamSlot) } } -bool cCiAdapter::Ready(void) -{ - for (int i = 0; i < MAX_CAM_SLOTS_PER_ADAPTER; i++) { - if (camSlots[i] && !camSlots[i]->Ready()) - return false; - } - return true; -} - void cCiAdapter::Action(void) { cTPDU TPDU; @@ -1566,8 +1557,6 @@ void cCiAdapter::Action(void) // --- cCamSlot -------------------------------------------------------------- -cCamSlots CamSlots; - #define MODULE_CHECK_INTERVAL 500 // ms #define MODULE_RESET_TIMEOUT 2 // s @@ -2034,6 +2023,26 @@ uchar *cCamSlot::Decrypt(uchar *Data, int &Count) return Data; } +// --- cCamSlots ------------------------------------------------------------- + +cCamSlots CamSlots; + +bool cCamSlots::WaitForAllCamSlotsReady(int Timeout) +{ + for (time_t t0 = time(NULL); time(NULL) - t0 < Timeout; ) { + bool ready = true; + for (cCamSlot *CamSlot = CamSlots.First(); CamSlot; CamSlot = CamSlots.Next(CamSlot)) { + if (!CamSlot->Ready()) { + ready = false; + cCondWait::SleepMs(100); + } + } + if (ready) + return true; + } + return false; +} + // --- cChannelCamRelation --------------------------------------------------- #define CAM_CHECKED_TIMEOUT 15 // seconds before a CAM that has been checked for a particular channel will be checked again -- cgit v1.2.3