Commit e286f26c authored by massiot's avatar 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.


git-svn-id: svn://svn.videolan.org/dvblast/trunk@85 55d3f8b6-4a41-4d2d-a900-313d1436a5b8
parent 23121b49
...@@ -51,16 +51,11 @@ ...@@ -51,16 +51,11 @@
* Local declarations * Local declarations
*****************************************************************************/ *****************************************************************************/
#define FRONTEND_LOCK_TIMEOUT 30000000 /* 30 s */ #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 */ #define DVR_BUFFER_SIZE 40*188*1024 /* bytes */
static int i_frontend, i_dvr; static int i_frontend, i_dvr;
static fe_status_t i_last_status; static fe_status_t i_last_status;
static mtime_t i_frontend_timeout; 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; static mtime_t i_ca_next_event = 0;
mtime_t i_ca_timeout = 0; mtime_t i_ca_timeout = 0;
...@@ -176,6 +171,7 @@ static block_t *DVRRead( void ) ...@@ -176,6 +171,7 @@ static block_t *DVRRead( void )
{ {
int i, i_len; int i, i_len;
block_t *p_ts, **pp_current = &p_ts; block_t *p_ts, **pp_current = &p_ts;
int i_read_once = output_Count() * NB_BLOCKS;
struct iovec p_iov[i_read_once]; struct iovec p_iov[i_read_once];
for ( i = 0; i < i_read_once; i++ ) for ( i = 0; i < i_read_once; i++ )
...@@ -194,8 +190,6 @@ static block_t *DVRRead( void ) ...@@ -194,8 +190,6 @@ static block_t *DVRRead( void )
} }
i_len /= TS_SIZE; i_len /= TS_SIZE;
//msg_Err( NULL, "Meuuh %d %d", i_len, i_read_once );
pp_current = &p_ts; pp_current = &p_ts;
while ( i_len && *pp_current ) while ( i_len && *pp_current )
{ {
...@@ -206,27 +200,6 @@ static block_t *DVRRead( void ) ...@@ -206,27 +200,6 @@ static block_t *DVRRead( void )
block_DeleteChain( *pp_current ); block_DeleteChain( *pp_current );
*pp_current = NULL; *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; return p_ts;
} }
......
...@@ -149,6 +149,18 @@ void output_Put( output_t *p_output, block_t *p_block ); ...@@ -149,6 +149,18 @@ void output_Put( output_t *p_output, block_t *p_block );
void comm_Open( void ); void comm_Open( void );
void comm_Read( 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 * 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