[vlc-devel] [PATCHv2 01/13] access: re-refactor pf_readdir

Rémi Denis-Courmont remi at remlab.net
Thu May 5 12:04:29 CEST 2016


On Tuesday 03 May 2016 19:02:28 Thomas Guillem wrote:
> This commit changes pf_readdir callback to its original behavior. Accesses
> and streams now add items to a node.
> 
> Archive stream_filters will now be able to add nodes to a node (when an
> archive has directory). This was not possible before.
> 
> This commit also adds an access_fsdir helper to help fs accesses (file, smb,
> nfs, ftp, sftp) adding items to a node. These accesses need the same
> treatment that is now done by this helper:
>  - hide hidden files or not (depending on "show-hiddenfiles" option)
>  - skip some file extensions (depending on "ignore-filetypes" option)
>  - sort items by type and alphabetically (depending on "directory-sort"
>    option).
>  - For a next commit: attach slaves to items
> 
> The directory demux won't do these operations anymore for every
> access/stream.
> 
> This commit doesn't change the interruptible state of the pf_readdir
> function, accesses/streams are still interruptible in the middle of a
> pf_readdir call.
> 
> This partially reverts commit 88ffe1587824c27f35705ee28e607f80ca335b46.
> ---
>  include/vlc_access.h                |  57 +++++++++++++--
>  include/vlc_stream.h                |   6 +-
>  modules/access/archive/stream.c     |  25 ++++---
>  modules/access/directory.c          |  39 ++++++----
>  modules/access/dsm/access.c         | 119 +++++++++++++++---------------
>  modules/access/fs.h                 |   3 +-
>  modules/access/ftp.c                |  57 ++++++++-------
>  modules/access/nfs.c                |  71 ++++++++++--------
>  modules/access/sftp.c               |  38 +++++-----
>  modules/access/smb.c                |  31 ++++----
>  modules/demux/playlist/directory.c  | 137
> ++--------------------------------- modules/services_discovery/upnp.cpp |
> 112 ++++++++++++----------------- modules/services_discovery/upnp.hpp |  14
> ++--
>  modules/stream_filter/inflate.c     |   6 +-
>  modules/stream_filter/prefetch.c    |   6 +-
>  src/input/access.c                  | 140
> ++++++++++++++++++++++++++++++++++-- src/input/stream.c                  | 
>  9 ++-
>  src/input/stream_filter.c           |   4 +-
>  src/libvlccore.sym                  |   3 +
>  19 files changed, 469 insertions(+), 408 deletions(-)
> 
> diff --git a/include/vlc_access.h b/include/vlc_access.h
> index 4578734..ff734eb 100644
> --- a/include/vlc_access.h
> +++ b/include/vlc_access.h
> @@ -88,11 +88,7 @@ struct access_t
>       * 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 */ -
> -    /* pf_readdir: Read the next input_item_t from the directory stream. It
> -     * returns the next input item on success or NULL in case of error or
> end -     * of stream. The item must be released with input_item_Release.
> */ -    input_item_t *(*pf_readdir)( access_t * );
> +    int         (*pf_readdir)( access_t *, input_item_node_t * );/* Fills
> the provided item_node, see doc/browsing.txt for details */
> 
>      /* Called for each seek.
>       * XXX can be null */
> @@ -239,6 +235,11 @@ static inline void access_InitFields( access_t *p_a )
>  }
> 
>  /**
> + * \defgroup access_helper Access Helpers
> + * @{
> + */
> +
> +/**
>   * Default pf_control callback for directory accesses.
>   */
>  VLC_API int access_vaDirectoryControlHelper( access_t *p_access, int
> i_query, va_list args ); @@ -268,7 +269,51 @@ VLC_API int
> access_vaDirectoryControlHelper( access_t *p_access, int i_query, va }
> while(0);
> 
>  /**
> - * @}
> + * Access pf_readdir helper struct
> + * \see access_fsdir_init()
> + * \see access_fsdir_additem()
> + * \see access_fsdir_finish()
> + */
> +struct access_fsdir
> +{
> +    access_t *p_access;

Do you need this pointer? It limits the re-usability of the code, IMO.

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



More information about the vlc-devel mailing list