]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb: Add Skip Initial Bytes...
authorJaroslav Kysela <perex@perex.cz>
Wed, 12 Nov 2014 15:39:43 +0000 (16:39 +0100)
committerJaroslav Kysela <perex@perex.cz>
Wed, 12 Nov 2014 15:39:43 +0000 (16:39 +0100)
docs/html/config_tvadapters.html
src/input/mpegts/linuxdvb/linuxdvb_frontend.c
src/input/mpegts/linuxdvb/linuxdvb_private.h

index 3ace1e452162388a4de48897944bf1284a310be6..1d573aeee9ae8faff1849faf33a6fd38ab65458b 100644 (file)
@@ -34,6 +34,11 @@ The rows have the following functions
  <dt><b>Power Save</b></dt>
   <dd>If enabled, allows the tuner to go to sleep when idle.</dd>
  <p>
+ <dt><b>Skip Initial Bytes</b></dt>
+  <dd>If set, first bytes from the MPEG-TS stream are discarded. It may be
+      required for some drivers / hardware which does not flush completely
+      the MPEG-TS buffers after a frequency/parameters change.</dd>
+ <p>
  </dl>
  <dt><u><i><b>Advanced Settings</b></i></u></dt>
  <dl>
index a25968c2d2b84b71e60e1cd378ae0651ae7d7976..81ce6c15674d18fcc4e8f36d9e2ad608fd1c8323 100644 (file)
@@ -91,6 +91,13 @@ const idclass_t linuxdvb_frontend_class =
       .name     = "Power Save",
       .off      = offsetof(linuxdvb_frontend_t, lfe_powersave),
     },
+    {
+      .type     = PT_U32,
+      .id       = "skip_bytes",
+      .name     = "Skip Initial Bytes",
+      .opts     = PO_ADVANCED,
+      .off      = offsetof(linuxdvb_frontend_t, lfe_skip_bytes),
+    },
     {}
   }
 };
@@ -808,6 +815,9 @@ linuxdvb_frontend_input_thread ( void *aux )
   int nfds;
   tvhpoll_event_t ev[2];
   tvhpoll_t *efd;
+  ssize_t n;
+  size_t skip = (MIN(lfe->lfe_skip_bytes, 1024*1024) / 188) * 188;
+  size_t counter = 0;
   sbuf_t sb;
 
   /* Get MMI */
@@ -844,7 +854,7 @@ linuxdvb_frontend_input_thread ( void *aux )
     if (ev[0].data.fd != dvr) break;
     
     /* Read */
-    if (sbuf_read(&sb, dvr) < 0) {
+    if ((n = sbuf_read(&sb, dvr)) < 0) {
       if (ERRNO_AGAIN(errno))
         continue;
       if (errno == EOVERFLOW) {
@@ -855,6 +865,16 @@ linuxdvb_frontend_input_thread ( void *aux )
              buf, errno, strerror(errno));
       break;
     }
+
+    /* Skip the initial bytes */
+    if (counter < skip) {
+      counter += n;
+      if (counter < skip) {
+        sbuf_cut(&sb, n);
+      } else {
+        sbuf_cut(&sb, skip - (counter - n));
+      }
+    }
     
     /* Process */
     mpegts_input_recv_packets((mpegts_input_t*)lfe, mmi, &sb, NULL, NULL);
index a0c8a4b6284e59420c20507a26db24bc997a214a..d7c419cc4f2843b7dfa2e14574704a3f35bde1bc 100644 (file)
@@ -111,6 +111,7 @@ struct linuxdvb_frontend
    * Configuration
    */
   int                       lfe_powersave;
+  uint32_t                  lfe_skip_bytes;
 
   /*
    * Satconf (DVB-S only)