linuxdvb: Add Skip Initial Bytes...

This commit is contained in:
Jaroslav Kysela 2014-11-12 16:39:43 +01:00
parent 8fca50269a
commit 322f6c6af9
3 changed files with 27 additions and 1 deletions

View 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>

View 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);

View file

@ -111,6 +111,7 @@ struct linuxdvb_frontend
* Configuration
*/
int lfe_powersave;
uint32_t lfe_skip_bytes;
/*
* Satconf (DVB-S only)