[vlc-devel] [PATCH 1/6] Add a pf_readdir callback to access_t modules

Rémi Denis-Courmont remi at remlab.net
Sat Jun 21 10:49:48 CEST 2014


Le vendredi 20 juin 2014, 19:53:03 Julien 'Lta' BALLET a écrit :
> From: Julien 'Lta' BALLET <contact at lta.io>
> 
> ---
>  include/vlc_access.h | 7 ++++---
>  src/input/access.c   | 1 +
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/include/vlc_access.h b/include/vlc_access.h
> index 511278a..9237b2a 100644
> --- a/include/vlc_access.h
> +++ b/include/vlc_access.h
> @@ -88,10 +88,11 @@ struct access_t
>       * (if you fail, this value won't be reseted */
>      char        *psz_demux;
> 
> -    /* pf_read/pf_block is used to read data.
> +    /* pf_read/pf_block/pf_readdir is used to read data.
>       * XXX A access should set one and only one of them */
> -    ssize_t     (*pf_read) ( access_t *, uint8_t *, size_t );  /* Return -1
> if no data yet, 0 if no more data, else real data read */ -    block_t   
> *(*pf_block)( access_t * );                  /* return a block of data in
> his 'natural' size, NULL if not yet data or eof */ +    ssize_t    
> (*pf_read)   ( access_t *, uint8_t *, size_t );  /* Return -1 if no data
> yet, 0 if no more data, else real data read */ +    block_t    *(*pf_block)
>  ( access_t * );                     /* Return a block of data in his
> 'natural' size, NULL if not yet data or eof */ +    int        
> (*pf_readdir)( access_t *, input_item_node_t * );/* Fills the provided
> item_node, return VLC_SUCCESS on success, something else otherwise*/

You should explicitly spell that returning "no data yet" is NOT permitted 
*unlike* with pf_block and pf_read. At least, that is what I understood from 
the rest of the series. Note that while this is a non-issue for local file 
systems (directory file handles cannot block), it may become one for network 
based protocols...

It would be nice to differentiate EOF from I/O error, (even) though we might 
never make use of it. Can we already (re)use b_error for that purpose?

> 
>      /* Called for each seek.
>       * XXX can be null */
> diff --git a/src/input/access.c b/src/input/access.c
> index 850fccd..a9b2804 100644
> --- a/src/input/access.c
> +++ b/src/input/access.c
> @@ -78,6 +78,7 @@ access_t *access_New( vlc_object_t *p_obj, input_thread_t
> *p_parent_input,
> 
>      p_access->pf_read    = NULL;
>      p_access->pf_block   = NULL;
> +    p_access->pf_readdir = NULL;
>      p_access->pf_seek    = NULL;
>      p_access->pf_control = NULL;
>      p_access->p_sys      = NULL;

-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list