[vlc-devel] [PATCH] udp: limit the udp buffer to a configurable size
Rémi Denis-Courmont
remi at remlab.net
Fri Aug 16 21:11:04 CEST 2013
Le samedi 17 août 2013 00:48:52 Tzu-Jung Lee a écrit :
> Signed-off-by: Tzu-Jung Lee <tjlee at ambarella.com>
The pacing part needs to be merged in the first patch IMHO.
> ---
> modules/access/udp.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/modules/access/udp.c b/modules/access/udp.c
> index c8bc519..16ff1a3 100644
> --- a/modules/access/udp.c
> +++ b/modules/access/udp.c
> @@ -50,6 +50,11 @@
> static int Open ( vlc_object_t * );
> static void Close( vlc_object_t * );
>
> +#define BUFFER_TEXT N_("UDP buffer size")
> +#define BUFFER_LONGTEXT N_("The UDP access module pulls recieved packets "
> \ + "from socket buffer into a fifo to avoid or "
> \ + "reduce packet loss due to socket buffer " \
> + "overflow. The default size is 4M Bytes" )
> vlc_module_begin ()
> set_shortname( N_("UDP" ) )
> set_description( N_("UDP input") )
> @@ -57,6 +62,7 @@ vlc_module_begin ()
> set_subcategory( SUBCAT_INPUT_ACCESS )
>
> add_obsolete_integer( "server-port" ) /* since 2.0.0 */
> + add_integer( "udp-buffer", 0x400000, BUFFER_TEXT, BUFFER_LONGTEXT, true
> )
>
> set_capability( "access", 0 )
> add_shortcut( "udp", "udpstream", "udp4", "udp6" )
> @@ -67,6 +73,7 @@ vlc_module_end ()
> struct access_sys_t
> {
> int i_handle;
> + int i_fifo_size;
>
> block_fifo_t *p_fifo;
>
> @@ -156,6 +163,7 @@ static int Open( vlc_object_t *p_this )
>
> p_sys->i_handle = i_handle;
> p_sys->p_fifo = block_FifoNew();
> + p_sys->i_fifo_size = var_InheritInteger(p_access, "udp-buffer");
>
> if( vlc_clone( &p_sys->thread, ThreadRead, p_access,
> VLC_THREAD_PRIORITY_HIGHEST ) )
> @@ -241,9 +249,12 @@ static void* ThreadRead( void *data )
> {
> access_t *p_access = (access_t*)data;
> access_sys_t *p_sys = p_access->p_sys;
> + int i_fifo_size = p_sys->i_fifo_size;
>
> for (;;)
> {
> + block_FifoPace(p_sys->p_fifo, SIZE_MAX, i_fifo_size);
> +
> block_t *p_pk = block_Alloc( MTU );
> if( unlikely(p_pk == NULL) )
> return NULL;
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list