Commit 3c7d6bbc authored by Christophe Massiot's avatar Christophe Massiot

Some comments for Henri.

parent 9cf26f41
......@@ -65,6 +65,10 @@ int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
p_netlist = (netlist_t *) p_input->p_method_data;
//On a besoin de p_buffers pour p_data. Il faut faire l'initialisation
//p_data->p_buffer = p_buffers + i * i_buffer_size
//p_data->p_payload_start = p_data->p_buffer
//p_data->p_payload_end = p_data->p_buffer + i_buffer_size
/* For the time being, I only handle pes and data. iovec is to come soon
*
p_netlist->p_buffers = malloc(i_buffer_size*i_nb_data)
......@@ -74,6 +78,11 @@ int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
return (-1);
}
*/
//Hum. Remplacer i_buffer_size par sizeof(data_packet_t) et rajouter
//un cast en (data_packet_t *) (c'est un buffer de data_packet_t, quand
//mme.
//D'autre part le INPUT_READ_ONCE n'est l quand dans l'initialisation
//des iovec => virer partout ailleurs.
p_netlist->p_data =
malloc(i_buffer_size*(i_nb_data + INPUT_READ_ONCE));
if ( p_netlist->p_data == NULL )
......@@ -81,6 +90,7 @@ int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
intf_ErrMsg ("Unable to malloc in netlist initialization (2)\n");
return (-1);
}
//Pareil.
p_netlist->p_pes =
malloc(i_buffer_size*(i_nb_pes + INPUT_READ_ONCE));
if ( p_netlist->p_pes == NULL )
......@@ -88,18 +98,22 @@ int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
intf_ErrMsg ("Unable to malloc in netlist initialization (3)\n");
return (-1);
}
//Il faut toujours caster la sortie du malloc (a renvoie void * par
//dfaut)
p_netlist->pp_free_data =
malloc (i_nb_data * sizeof(data_packet_t *) );
if ( p_netlist->pp_free_data == NULL )
{
intf_ErrMsg ("Unable to malloc in netlist initialization (4)\n");
}
//i_nb_pes peut-tre ?
p_netlist->pp_free_pes =
malloc (i_nb_data * sizeof(pes_packet_t *) );
if ( p_netlist->pp_free_pes == NULL )
{
intf_ErrMsg ("Unable to malloc in netlist initialization (5)\n");
}
//p_free_iovec = malloc( (i_nb_data + INPUT_READ_ONCE) * sizeof(...) )
/* Fill the data FIFO */
......@@ -107,6 +121,7 @@ int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
{
p_netlist->pp_free_data[i_loop] =
p_netlist->p_data + i_loop;
//manque l'initialisation de l'intrieur de p_data (cf. supra)
}
/* Fill the PES FIFO */
for ( i_loop = 0; i_loop < i_nb_pes + INPUT_READ_ONCE; i_loop++ )
......@@ -114,6 +129,8 @@ int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
p_netlist->pp_free_pes[i_loop] =
p_netlist->p_pes + i_loop;
}
//p_free_iovec[i_loop].iov_base = p_buffers + i_loop * i_buffer_size
//p_free_iovec[i_loop].iov_len = i_buffer_size
/* vlc_mutex_init */
vlc_mutex_init (&p_netlist->lock);
......@@ -126,6 +143,7 @@ int input_NetlistInit( input_thread_t * p_input, int i_nb_data, int i_nb_pes,
// p_netlist->i_iovec_start = 0;
// p_netlist->i_iovec_end = /* ?? */
//i_nb_data - 1
p_netlist->i_nb_data = i_nb_data;
p_netlist->i_nb_pes = i_nb_pes;
......@@ -140,9 +158,24 @@ struct iovec * input_NetlistGetiovec( void * p_netlist )
{
/* fonction la plus difficile, terminer par celle-la
* je la ferai plus tard :p */
//vrifier i_iovec_end - i_iovec_start > INPUT_READ_ONCE
//la grosse astuce :
//if( i_nb_data - i_iovec_start < INPUT_READ_ONCE )
// memcpy( &p_free_iovec[i_nb_data], p_free_iovec, INPUT_READ_ONCE*... )
//return &p_free_iovec[i_iovec_start];
return ( NULL ); /* nothing yet */
}
//je rajoute celle-l
/*****************************************************************************
* input_NetlistMviovec: move the iovec pointer after a readv() operation
*****************************************************************************/
void input_NetlistMviovec( void * p_netlist, size_t i_nb_iovec )
{
//i_iovec_start += i_nb_iovec
//i_iovec_start %= i_nb_data //oui j'ai bien dit i_nb_data
}
/*****************************************************************************
* input_NetlistNewPacket: returns a free data_packet_t
*****************************************************************************/
......@@ -150,7 +183,8 @@ struct data_packet_s * input_NetlistNewPacket( void * p_netlist )
{
unsigned int i_return;
netlist_t * pt_netlist; /* for a cast */
//pas beau, pt_netlist, j'aurais prfr void * p_method_data et
//netlist_t * p_netlist
pt_netlist = ( netlist_t * ) p_netlist;
/* cast p_netlist -> netlist_t */
......@@ -160,17 +194,23 @@ struct data_packet_s * input_NetlistNewPacket( void * p_netlist )
/* check */
if ( pt_netlist->i_data_start == pt_netlist->i_data_end )
{
//empty peut-tre ?
intf_ErrMsg("Full Data FIFO in netlist - Unable to allocate memory\n");
return ( NULL );
}
i_return = (pt_netlist->i_data_start)++;
pt_netlist->i_data_start %= pt_netlist->i_nb_data;
//i_iovec_start++; i_iovec_start %= i_nb_data //oui j'ai bien dit i_nb_data
/* unlock */
vlc_mutex_unlock (&pt_netlist->lock);
//risque de race condition : que se passe-t-il si aprs avoir rendu
//le lock un autre thread rend un paquet et crase
//pp_free_data[i_return] ?
return ( pt_netlist->pp_free_data[i_return] );
//il faudrait aussi initialiser p_payload_start et p_payload_end
}
/*****************************************************************************
......@@ -181,6 +221,7 @@ struct pes_packet_s * input_NetlistNewPES( void * p_netlist )
unsigned int i_return;
netlist_t * pt_netlist; /* for a cast */
//tout pareil qu'au-dessus
pt_netlist = (netlist_t *)p_netlist;
/* lock */
......@@ -200,6 +241,10 @@ struct pes_packet_s * input_NetlistNewPES( void * p_netlist )
vlc_mutex_unlock (&pt_netlist->lock);
return ( pt_netlist->pp_free_pes[i_return] );
//il faudrait initialiser le pes :
//b_messed_up = b_data_alignment = b_discontinuity = b_has_pts = 0
//i_pes_size = 0
//p_first = NULL
}
/*****************************************************************************
......@@ -216,6 +261,8 @@ void input_NetlistDeletePacket( void * p_netlist, data_packet_t * p_data )
pt_netlist->i_data_end ++;
pt_netlist->i_data_end %= pt_netlist->i_nb_data;
//i_iovec_end++; i_iovec_end %= i_nb_data //oui j'ai bien dit i_nb_data
//p_free_iovec[i_iovec_end].iov_base = p_data->p_buffer
pt_netlist->pp_free_data[pt_netlist->i_data_end] = p_data;
......@@ -246,6 +293,8 @@ void input_NetlistDeletePES( void * p_netlist, pes_packet_t * p_pes )
* Duplicate code avoid many locks */
pt_netlist->i_data_end ++;
pt_netlist->i_data_end %= pt_netlist->i_nb_data;
//i_iovec_end++; i_iovec_end %= i_nb_data //oui j'ai bien dit i_nb_data
//p_free_iovec[i_iovec_end].iov_base = p_data->p_buffer
pt_netlist->pp_free_data[pt_netlist->i_data_end] = p_current_packet;
......@@ -278,4 +327,4 @@ void input_NetlistEnd( input_thread_t * p_input)
free (p_netlist);
}
//sinon c'est bien (c)
......@@ -33,6 +33,7 @@ int input_NetlistInit( struct input_thread_s *,
int i_nb_data, int i_nb_pes,
size_t i_buffer_size );
struct iovec * input_NetlistGetiovec( void * );
void input_NetlistMviovec( void *, size_t );
struct data_packet_s * input_NetlistNewPacket( void * );
struct pes_packet_s * input_NetlistNewPES( void * );
void input_NetlistDeletePacket( void *, struct data_packet_s * );
......
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