Commit 35c442a3 authored by Christophe Massiot's avatar Christophe Massiot

* dvb.c: Read from DVR in amounts of NB_OUTPUTS * 7 * 188.

This attemps at lowering the latency, at the expense of a slightly
raised CPU consumption. Please yell if you're not OK.
parent 134778fc
......@@ -51,16 +51,11 @@
* Local declarations
*****************************************************************************/
#define FRONTEND_LOCK_TIMEOUT 30000000 /* 30 s */
#define COUNTER_WRAP 200 /* we make 200 read calls per second */
#define MAX_READ_ONCE 50
#define DVR_BUFFER_SIZE 40*188*1024 /* bytes */
static int i_frontend, i_dvr;
static fe_status_t i_last_status;
static mtime_t i_frontend_timeout;
static unsigned int i_read_once = 1;
static unsigned int i_read_counter = 0;
static mtime_t i_last_counter = 0;
static mtime_t i_ca_next_event = 0;
mtime_t i_ca_timeout = 0;
......@@ -176,6 +171,7 @@ static block_t *DVRRead( void )
{
int i, i_len;
block_t *p_ts, **pp_current = &p_ts;
int i_read_once = output_Count() * NB_BLOCKS;
struct iovec p_iov[i_read_once];
for ( i = 0; i < i_read_once; i++ )
......@@ -194,8 +190,6 @@ static block_t *DVRRead( void )
}
i_len /= TS_SIZE;
//msg_Err( NULL, "Meuuh %d %d", i_len, i_read_once );
pp_current = &p_ts;
while ( i_len && *pp_current )
{
......@@ -206,27 +200,6 @@ static block_t *DVRRead( void )
block_DeleteChain( *pp_current );
*pp_current = NULL;
i_read_counter++;
if ( i_read_counter >= COUNTER_WRAP )
{
mtime_t i_current_date = mdate();
if ( i_last_counter )
{
/* Adjust the buffer size to keep the read() calls frequency
* at a certain limit */
i_read_once = (mtime_t)i_read_once * 1000000LL
/ (i_current_date - i_last_counter);
if ( i_read_once < 1 )
i_read_once = 1;
if ( i_read_once > MAX_READ_ONCE )
i_read_once = MAX_READ_ONCE;
}
i_read_counter = 0;
i_last_counter = i_current_date;
}
return p_ts;
}
......
......@@ -149,6 +149,18 @@ void output_Put( output_t *p_output, block_t *p_block );
void comm_Open( void );
void comm_Read( void );
/*****************************************************************************
* output_Count
*****************************************************************************/
static inline int output_Count( void )
{
int i, i_nb = 0;
for ( i = 0; i < i_nb_outputs; i++ )
if ( pp_outputs[i]->i_maddr )
i_nb++;
return i_nb;
}
/*****************************************************************************
* block_New
*****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment