Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] [PATCH] cDvbTuner



Hi,

inspired from szap I have made some changes to cDvbTuner:

- use WAIT_FOR_LOCK_AFTER_TUNING=1

- discard stale frontend events before FE_SET_FRONTEND

- use frontend event to detect if tuner is locked

- reduce delay in cDvbTuner::Action while waiting for tuner is locked

This seems to make zapping more reliable (black screens, distorsions 
from previous channel).

I have only one dvb-s FF card (Rev. 1.5). So I have no idea if this 
changes work on other setups. Please test and review...

Stefan
--- dvbdevice.c.orig	2004-06-19 11:33:42.000000000 +0200
+++ dvbdevice.c	2004-07-22 21:34:18.000000000 +0200
@@ -35,7 +35,7 @@ extern "C" {
 
 #define DO_REC_AND_PLAY_ON_PRIMARY_DEVICE 1
 #define DO_MULTIPLE_RECORDINGS 1
-//#define WAIT_FOR_LOCK_AFTER_TUNING 1
+#define WAIT_FOR_LOCK_AFTER_TUNING 1
 
 #define DEV_VIDEO         "/dev/video"
 #define DEV_DVB_ADAPTER   "/dev/dvb/adapter"
@@ -241,6 +241,15 @@ bool cDvbTuner::SetFrontend(void)
          esyslog("ERROR: attempt to set channel with unknown DVB frontend type");
          return false;
     }
+  
+  /* discard stale events */
+  dvb_frontend_event event;
+  while (1)
+  {
+    if (ioctl(fd_frontend, FE_GET_EVENT, &event) == -1)
+      break;
+  }
+  
   if (ioctl(fd_frontend, FE_SET_FRONTEND, &Frontend) < 0) {
      esyslog("ERROR: frontend %d: %m", cardIndex);
      return false;
@@ -255,12 +264,14 @@ void cDvbTuner::Action(void)
         cMutexLock MutexLock(&mutex);
         if (tunerStatus == tsSet)
            tunerStatus = SetFrontend() ? tsTuned : tsIdle;
+        /*
         if (tunerStatus == tsTuned) {
            fe_status_t status = fe_status_t(0);
            CHECK(ioctl(fd_frontend, FE_READ_STATUS, &status));
            if (status & FE_HAS_LOCK)
               tunerStatus = tsLocked;
            }
+        */
         if (tunerStatus != tsIdle) {
            dvb_frontend_event event;
            if (ioctl(fd_frontend, FE_GET_EVENT, &event) == 0) {
@@ -269,6 +280,8 @@ void cDvbTuner::Action(void)
                  esyslog("ERROR: frontend %d was reinitialized - re-tuning", cardIndex);
                  continue;
                  }
+              if (event.status & FE_HAS_LOCK)
+                tunerStatus = tsLocked;
               }
            }
         if (ciHandler) {
@@ -293,7 +306,8 @@ void cDvbTuner::Action(void)
               tunerStatus = tsLocked;
            }
         // in the beginning we loop more often to let the CAM connection start up fast
-        newSet.TimedWait(mutex, (ciHandler && (time(NULL) - startTime < 20)) ? 100 : 1000);
+	bool fast = (tunerStatus == tsTuned) || (ciHandler && (time(NULL) - startTime < 20));
+        newSet.TimedWait(mutex, fast ? 100 : 1000);
         }
 }
 

Home | Main Index | Thread Index