From 322f6c6af9f6478ec5ff607dc1cf97a9c09a093b Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 12 Nov 2014 16:39:43 +0100 Subject: [PATCH] linuxdvb: Add Skip Initial Bytes... --- docs/html/config_tvadapters.html | 5 +++++ src/input/mpegts/linuxdvb/linuxdvb_frontend.c | 22 ++++++++++++++++++- src/input/mpegts/linuxdvb/linuxdvb_private.h | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/html/config_tvadapters.html b/docs/html/config_tvadapters.html index 3ace1e45..1d573aee 100644 --- a/docs/html/config_tvadapters.html +++ b/docs/html/config_tvadapters.html @@ -34,6 +34,11 @@ The rows have the following functions
Power Save
If enabled, allows the tuner to go to sleep when idle.

+

Skip Initial Bytes
+
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.
+

Advanced Settings
diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index a25968c2..81ce6c15 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -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); diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index a0c8a4b6..d7c419cc 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -111,6 +111,7 @@ struct linuxdvb_frontend * Configuration */ int lfe_powersave; + uint32_t lfe_skip_bytes; /* * Satconf (DVB-S only)