[vlc-devel] [PATCH 1/8] access: refactor pf_readdir

Thomas Guillem thomas at gllm.fr
Thu May 7 14:50:20 CEST 2015



On Thu, May 7, 2015, at 13:31, Rémi Denis-Courmont wrote:
> Le 2015-05-07 13:10, Thomas Guillem a écrit :
> > It behaves more like the readdir_r() posix function.
> >
> > The main advantage is to move the management of the input_item_node_t
> > from all
> > accesses to the directory demux.
> > ---
> >  include/vlc_access.h                |   7 +-
> >  include/vlc_stream.h                |   6 +-
> >  modules/access/archive/stream.c     |   9 ++-
> >  modules/access/directory.c          |  26 ++------
> >  modules/access/dsm/access.c         | 127
> > +++++++++++++++++-------------------
> >  modules/access/fs.h                 |   2 +-
> >  modules/access/ftp.c                |  28 ++++----
> >  modules/access/sftp.c               |  30 ++++-----
> >  modules/demux/playlist/directory.c  |  31 +++++++--
> >  modules/services_discovery/upnp.cpp | 106 
> > ++++++++++++++++++------------
> >  modules/services_discovery/upnp.hpp |  16 +++--
> >  src/input/stream.c                  |  17 +++--
> >  src/input/stream_filter.c           |   4 +-
> >  13 files changed, 224 insertions(+), 185 deletions(-)
> >
> > diff --git a/include/vlc_access.h b/include/vlc_access.h
> > index 1f3cb03..ca107a6 100644
> > --- a/include/vlc_access.h
> > +++ b/include/vlc_access.h
> > @@ -92,7 +92,12 @@ 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 */
> > -    int         (*pf_readdir)( access_t *, input_item_node_t * );/*
> > Fills the provided item_node, see doc/browsing.txt for details */
> > +
> > +    /* pf_readdir: Read the next input_item_t from the stream. It
> > returns 0 on
> > +     * success and returns the next input item in *pp_item. On 
> > error, it
> > +     * returns a VLC error code and *pp_item is no touched. If the
> > end of the
> > +     * directory is reached, it returns 0, and returns NULL in 
> > *pp_item */
> > +    int         (*pf_readdir)( access_t *, input_item_t **pp_item );
> 
> IMHO, returning an item or NULL would be simpler. I think that's how 
> the original proposal was, before recursion was added.

The current behavior is more like readdir_, you prefer something like
vlc_readdir.

The main advantage with the current behavior is that we can identify an
error from an EOF. In case of error in the demux directory, we don't
send items at all. If we decide to behave like vlc_readdir, the demux
will send items even if an error occurred in the middle of the read.

I don't really know which one I prefer, maybe we don't need to identify
an error from an EOF after all...


> 
> >
> >      /* Called for each seek.
> >       * XXX can be null */
> 
> -- 
> Rémi Denis-Courmont
> Remlab T:mi
> http://www.remlab.net/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list