Broken CAM connections are now restored automatically

This commit is contained in:
Klaus Schmidinger 2003-02-16 11:20:55 +01:00
parent 96df157057
commit 9c04942eaa
3 changed files with 45 additions and 34 deletions

10
ci.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: ci.c 1.6 2003/02/15 14:14:57 kls Exp $ * $Id: ci.c 1.7 2003/02/16 11:20:55 kls Exp $
*/ */
/* XXX TODO /* XXX TODO
@ -1423,8 +1423,9 @@ int cCiHandler::CloseAllSessions(int Slot)
return result; return result;
} }
void cCiHandler::Process(void) bool cCiHandler::Process(void)
{ {
bool result = true;
cMutexLock MutexLock(&mutex); cMutexLock MutexLock(&mutex);
for (int Slot = 0; Slot < numSlots; Slot++) { for (int Slot = 0; Slot < numSlots; Slot++) {
tc = tpl->Process(Slot); tc = tpl->Process(Slot);
@ -1453,8 +1454,10 @@ void cCiHandler::Process(void)
} }
} }
} }
else if (CloseAllSessions(Slot)) else if (CloseAllSessions(Slot)) {
tpl->ResetSlot(Slot); tpl->ResetSlot(Slot);
result = false;
}
else if (tpl->ModuleReady(Slot)) { else if (tpl->ModuleReady(Slot)) {
dbgprotocol("Module ready in slot %d\n", Slot); dbgprotocol("Module ready in slot %d\n", Slot);
tpl->NewConnection(Slot); tpl->NewConnection(Slot);
@ -1464,6 +1467,7 @@ void cCiHandler::Process(void)
if (sessions[i]) if (sessions[i])
sessions[i]->Process(); sessions[i]->Process();
} }
return result;
} }
bool cCiHandler::EnterMenu(int Slot) bool cCiHandler::EnterMenu(int Slot)

4
ci.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: ci.h 1.2 2003/02/09 11:44:00 kls Exp $ * $Id: ci.h 1.3 2003/02/16 10:55:21 kls Exp $
*/ */
#ifndef __CI_H #ifndef __CI_H
@ -95,7 +95,7 @@ private:
public: public:
~cCiHandler(); ~cCiHandler();
static cCiHandler *CreateCiHandler(const char *FileName); static cCiHandler *CreateCiHandler(const char *FileName);
void Process(void); bool Process(void);
bool EnterMenu(int Slot); bool EnterMenu(int Slot);
cCiMenu *GetMenu(void); cCiMenu *GetMenu(void);
cCiEnquiry *GetEnquiry(void); cCiEnquiry *GetEnquiry(void);

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbdevice.c 1.44 2003/02/09 12:41:14 kls Exp $ * $Id: dvbdevice.c 1.45 2003/02/16 10:58:59 kls Exp $
*/ */
#include "dvbdevice.h" #include "dvbdevice.h"
@ -65,7 +65,7 @@ static int DvbOpen(const char *Name, int n, int Mode, bool ReportError = false)
class cDvbTuner : public cThread { class cDvbTuner : public cThread {
private: private:
enum eTunerStatus { tsIdle, tsSet, tsTuned, tsLocked }; enum eTunerStatus { tsIdle, tsSet, tsTuned, tsLocked, tsCam };
int fd_frontend; int fd_frontend;
int cardIndex; int cardIndex;
fe_type_t frontendType; fe_type_t frontendType;
@ -74,7 +74,6 @@ private:
const char *diseqcCommands; const char *diseqcCommands;
bool active; bool active;
eTunerStatus tunerStatus; eTunerStatus tunerStatus;
bool caSet;
cMutex mutex; cMutex mutex;
cCondVar newSet; cCondVar newSet;
bool SetFrontend(void); bool SetFrontend(void);
@ -96,7 +95,6 @@ cDvbTuner::cDvbTuner(int Fd_Frontend, int CardIndex, fe_type_t FrontendType, cCi
diseqcCommands = NULL; diseqcCommands = NULL;
active = false; active = false;
tunerStatus = tsIdle; tunerStatus = tsIdle;
caSet = false;
Start(); Start();
} }
@ -119,7 +117,8 @@ void cDvbTuner::Set(const cChannel *Channel, bool Tune)
channel = *Channel; channel = *Channel;
if (Tune) if (Tune)
tunerStatus = tsSet; tunerStatus = tsSet;
caSet = false; else if (tunerStatus == tsCam)
tunerStatus = tsLocked;
newSet.Broadcast(); newSet.Broadcast();
} }
@ -251,17 +250,19 @@ void cDvbTuner::Action(void)
if (status & FE_HAS_LOCK) if (status & FE_HAS_LOCK)
tunerStatus = tsLocked; tunerStatus = tsLocked;
} }
if (tunerStatus != tsIdle) {
dvb_frontend_event event; dvb_frontend_event event;
if (ioctl(fd_frontend, FE_GET_EVENT, &event) == 0) { if (ioctl(fd_frontend, FE_GET_EVENT, &event) == 0) {
if (tunerStatus != tsIdle && event.status & FE_REINIT) { if (event.status & FE_REINIT) {
tunerStatus = tsSet; tunerStatus = tsSet;
esyslog("ERROR: frontend %d was reinitialized - re-tuning", cardIndex); esyslog("ERROR: frontend %d was reinitialized - re-tuning", cardIndex);
continue; continue;
} }
} }
if (tunerStatus >= tsLocked) {
if (ciHandler) { if (ciHandler) {
ciHandler->Process(); if (ciHandler->Process()) {
if (!caSet) {//XXX TODO update in case the CA descriptors have changed if (tunerStatus != tsCam) {//XXX TODO update in case the CA descriptors have changed
uchar buffer[2048]; uchar buffer[2048];
int length = cSIProcessor::GetCaDescriptors(channel.Source(), channel.Frequency(), channel.Sid(), sizeof(buffer), buffer); int length = cSIProcessor::GetCaDescriptors(channel.Source(), channel.Frequency(), channel.Sid(), sizeof(buffer), buffer);
if (length > 0) { if (length > 0) {
@ -275,7 +276,13 @@ void cDvbTuner::Action(void)
CaPmt.AddPid(channel.Apid2()); CaPmt.AddPid(channel.Apid2());
if (channel.Dpid1()) if (channel.Dpid1())
CaPmt.AddPid(channel.Dpid1()); CaPmt.AddPid(channel.Dpid1());
caSet = ciHandler->SetCaPmt(CaPmt); if (ciHandler->SetCaPmt(CaPmt))
tunerStatus = tsCam;
}
}
}
else
tunerStatus = tsLocked;
} }
} }
} }