[vlc-devel] [PATCH] access: add a default pf_control for directory accesses
Thomas Guillem
thomas at gllm.fr
Thu Jun 4 09:34:02 CEST 2015
On Wed, Jun 3, 2015, at 19:28, Rémi Denis-Courmont wrote:
> Why inline? demux_vaControlHelper() is not inline.
Because there were other static inline function in the header, it seemed
to be a good place. I'll put access_vaDirectortyControlHelper in
src/input/access.c
>
> (Not a huge fan of the macro either)
OK, I don't know what to think about these kind of macro either. Less
code but less understandable too.
>
> Le mercredi 03 juin 2015, 12:00:21 Thomas Guillem a écrit :
> > ---
> > include/vlc_access.h | 28 ++++++++++++++++++++++++++++
> > modules/access/directory.c | 2 +-
> > modules/access/dsm/access.c | 4 ++--
> > modules/access/ftp.c | 2 +-
> > modules/access/sftp.c | 2 +-
> > modules/access/smb.c | 2 +-
> > modules/services_discovery/upnp.cpp | 2 +-
> > 7 files changed, 35 insertions(+), 7 deletions(-)
> >
> > diff --git a/include/vlc_access.h b/include/vlc_access.h
> > index 1adf669..94c1e70 100644
> > --- a/include/vlc_access.h
> > +++ b/include/vlc_access.h
> > @@ -186,6 +186,34 @@ VLC_API input_thread_t * access_GetParentInput(
> > access_t *p_access ) VLC_USED; if( !p_sys ) return VLC_ENOMEM; \
> > } while(0);
> >
> > +static inline int DirectoryControl( access_t *p_access, int i_query,
> > + va_list args )
> > +{
> > + VLC_UNUSED( p_access );
> > +
> > + switch( i_query )
> > + {
> > + case ACCESS_CAN_SEEK:
> > + case ACCESS_CAN_FASTSEEK:
> > + case ACCESS_CAN_PAUSE:
> > + case ACCESS_CAN_CONTROL_PACE:
> > + *va_arg( args, bool* ) = false;
> > + break;
> > + case ACCESS_GET_PTS_DELAY:
> > + *va_arg( args, int64_t * ) = 0;
> > + break;
> > + default:
> > + return VLC_EGENERIC;
> > + }
> > + return VLC_SUCCESS;
> > +}
> > +
> > +#define ACCESS_SET_DIRECTORY_CALLBACK( readdir ) \
> > + do { \
> > + p_access->pf_readdir = readdir; \
> > + p_access->pf_control = DirectoryControl; \
> > + } while(0)
> > +
> > /**
> > * @}
> > */
> > diff --git a/modules/access/directory.c b/modules/access/directory.c
> > index 87b5b33..5814b78 100644
> > --- a/modules/access/directory.c
> > +++ b/modules/access/directory.c
> > @@ -92,7 +92,7 @@ int DirOpen (vlc_object_t *p_this)
> > }
> > p_access->p_sys->p_dir = p_dir;
> > p_access->p_sys->psz_base_uri = psz_base_uri;
> > - p_access->pf_readdir = DirRead;
> > + ACCESS_SET_DIRECTORY_CALLBACK( DirRead );
> >
> > return VLC_SUCCESS;
> > }
> > diff --git a/modules/access/dsm/access.c b/modules/access/dsm/access.c
> > index 8e7fcdd..1b2d6ce 100644
> > --- a/modules/access/dsm/access.c
> > +++ b/modules/access/dsm/access.c
> > @@ -699,10 +699,10 @@ static int BrowserInit( access_t *p_access )
> > access_sys_t *p_sys = p_access->p_sys;
> >
> > if( p_sys->psz_share == NULL )
> > - p_access->pf_readdir = BrowseShare;
> > + ACCESS_SET_DIRECTORY_CALLBACK( BrowseShare );
> > else
> > {
> > - p_access->pf_readdir = BrowseDirectory;
> > + ACCESS_SET_DIRECTORY_CALLBACK( BrowseDirectory );
> > p_access->info.b_dir_can_loop = true;
> > }
> >
> > diff --git a/modules/access/ftp.c b/modules/access/ftp.c
> > index 096d54c..9642a06 100644
> > --- a/modules/access/ftp.c
> > +++ b/modules/access/ftp.c
> > @@ -667,7 +667,7 @@ static int InOpen( vlc_object_t *p_this )
> >
> > if( b_directory )
> > {
> > - p_access->pf_readdir = DirRead;
> > + ACCESS_SET_DIRECTORY_CALLBACK( DirRead );
> > p_access->info.b_dir_can_loop = true;
> > } else
> > ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \
> > diff --git a/modules/access/sftp.c b/modules/access/sftp.c
> > index 740da6b..7d2e913 100644
> > --- a/modules/access/sftp.c
> > +++ b/modules/access/sftp.c
> > @@ -295,7 +295,7 @@ static int Open( vlc_object_t* p_this )
> > /* Open the given directory */
> > p_sys->file = libssh2_sftp_opendir( p_sys->sftp_session, psz_path
> > );
> >
> > - p_access->pf_readdir = DirRead;
> > + ACCESS_SET_DIRECTORY_CALLBACK( DirRead );
> > p_access->info.b_dir_can_loop = true;
> >
> > if( p_sys->file )
> > diff --git a/modules/access/smb.c b/modules/access/smb.c
> > index 3aa9902..e3cca52 100644
> > --- a/modules/access/smb.c
> > +++ b/modules/access/smb.c
> > @@ -252,7 +252,7 @@ static int Open( vlc_object_t *p_this )
> > #ifdef _WIN32
> > return VLC_EGENERIC;
> > #else
> > - p_access->pf_readdir = DirRead;
> > + ACCESS_SET_DIRECTORY_CALLBACK( DirRead );
> > p_access->info.b_dir_can_loop = true;
> > i_smb = smbc_opendir( psz_uri );
> > i_size = 0;
> > diff --git a/modules/services_discovery/upnp.cpp
> > b/modules/services_discovery/upnp.cpp index 4f5aaf8..4dbd619 100644
> > --- a/modules/services_discovery/upnp.cpp
> > +++ b/modules/services_discovery/upnp.cpp
> > @@ -838,7 +838,7 @@ static int Open( vlc_object_t *p_this )
> > return VLC_EGENERIC;
> > }
> >
> > - p_access->pf_readdir = ReadDirectory;
> > + ACCESS_SET_DIRECTORY_CALLBACK( ReadDirectory );
> > p_access->info.b_dir_sorted = true;
> > p_access->info.b_dir_can_loop = true;
>
> --
> 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