Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
linuxdvb: Add Skip Initial Bytes...
  • Loading branch information
perexg committed Nov 12, 2014
1 parent 8fca502 commit 322f6c6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/html/config_tvadapters.html
Expand Up @@ -34,6 +34,11 @@ <h3>The adapters and tuners are listed / edited in a tree</h3>
<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>
Expand Down
22 changes: 21 additions & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_frontend.c
Expand Up @@ -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),
},
{}
}
};
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/linuxdvb/linuxdvb_private.h
Expand Up @@ -111,6 +111,7 @@ struct linuxdvb_frontend
* Configuration
*/
int lfe_powersave;
uint32_t lfe_skip_bytes;

/*
* Satconf (DVB-S only)
Expand Down

0 comments on commit 322f6c6

Please sign in to comment.