]> www.vanbest.org Git - sasc-ng.git/commitdiff
fixed deCSA when first recording FTA then view encrypted
authorleslie <unknown>
Sun, 17 Feb 2008 13:13:23 +0000 (14:13 +0100)
committerleslie <unknown>
Sun, 17 Feb 2008 13:13:23 +0000 (14:13 +0100)
cam.c
cam.h

diff --git a/cam.c b/cam.c
index d0c426f352ac482dcbdd93c19731f7401c45c480..1a20ea0ad7875db8c1758f3837c64cf9a8fc34eb 100644 (file)
--- a/cam.c
+++ b/cam.c
@@ -2419,17 +2419,19 @@ public:
   cDeCsaTSBuffer(int File, int Size, int CardIndex, cDeCSA *DeCsa, bool ScActive);
   ~cDeCsaTSBuffer();
   uchar *Get(void);
+  void SetActive(bool ScActive);
   };
 
 cDeCsaTSBuffer::cDeCsaTSBuffer(int File, int Size, int CardIndex, cDeCSA *DeCsa, bool ScActive)
 {
   SetDescription("TS buffer on device %d", CardIndex);
-  f=File; cardIndex=CardIndex; decsa=DeCsa; scActive=ScActive;
+  f=File; cardIndex=CardIndex; decsa=DeCsa;
   delivered=false;
   lastP=0; lastCount=0;
   ringBuffer=new cRingBufferLinear(Size,TS_SIZE,true,"FFdecsa-TS");
   ringBuffer->SetTimeouts(100,100);
   if(decsa) decsa->SetActive(true);
+  SetActive(ScActive);
   Start();
 }
 
@@ -2440,6 +2442,11 @@ cDeCsaTSBuffer::~cDeCsaTSBuffer()
   delete ringBuffer;
 }
 
+void cDeCsaTSBuffer::SetActive(bool ScActive)
+{
+  scActive=ScActive;
+}
+
 void cDeCsaTSBuffer::Action(void)
 {
   if(ringBuffer) {
@@ -2677,6 +2684,9 @@ bool cScDvbDevice::Ready(void)
 bool cScDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On)
 {
   if(cam) cam->SetPid(Type,Handle->pid,On);
+  tsMutex.Lock();
+  if(tsBuffer) tsBuffer->SetActive(ScActive());
+  tsMutex.Unlock();
   return cDvbDevice::SetPid(Handle,Type,On);
 }
 
@@ -2765,24 +2775,32 @@ void cScDvbDevice::CiStartDecrypting(void)
 }
 #endif //APIVERSNUM < 10500
 
+bool cScDvbDevice::ScActive(void)
+{
+#if APIVERSNUM >= 10500
+  return dynamic_cast<cScCamSlot *>(CamSlot())!=0;
+#else
+  return cam && softcsa;
+#endif
+}
+
 bool cScDvbDevice::OpenDvr(void)
 {
   CloseDvr();
   fd_dvr=DvbOpen(DEV_DVB_DVR,CardIndex(),O_RDONLY|O_NONBLOCK,true);
   if(fd_dvr>=0) {
-#if APIVERSNUM >= 10500
-    bool active=dynamic_cast<cScCamSlot *>(CamSlot())!=0;
-#else
-    bool active=cam && softcsa;
-#endif
-    tsBuffer=new cDeCsaTSBuffer(fd_dvr,MEGABYTE(2),CardIndex()+1,decsa,active);
+    tsMutex.Lock();
+    tsBuffer=new cDeCsaTSBuffer(fd_dvr,MEGABYTE(2),CardIndex()+1,decsa,ScActive());
+    tsMutex.Unlock();
     }
   return fd_dvr>=0;
 }
 
 void cScDvbDevice::CloseDvr(void)
 {
+  tsMutex.Lock();
   delete tsBuffer; tsBuffer=0;
+  tsMutex.Unlock();
   if(fd_dvr>=0) { close(fd_dvr); fd_dvr=-1; }
 }
 
diff --git a/cam.h b/cam.h
index 852b961fdfb93b598530b11644d44f2cb97f9cbb..94031d6da801c1d2cce8b89292f7626882eb0cb1 100644 (file)
--- a/cam.h
+++ b/cam.h
@@ -151,6 +151,7 @@ class cScDvbDevice : public cDvbDevice {
 private:
   cDeCSA *decsa;
   cDeCsaTSBuffer *tsBuffer;
+  cMutex tsMutex;
 #if APIVERSNUM >= 10500
   cScCiAdapter *ciadapter;
   cCiAdapter *hwciadapter;
@@ -171,6 +172,7 @@ private:
   void LateInit(void);
   void EarlyShutdown(void);
   int FindLRUPrg(int source, int transponder, int prg);
+  bool ScActive(void);
 #endif //SASC
 protected:
 #ifndef SASC