Commit 763e765d authored by Thomas Guillem's avatar Thomas Guillem

access: pf_control is not mandatory for directory accesses

parent 7385062d
......@@ -117,7 +117,8 @@ struct access_t
static inline int access_vaControl( access_t *p_access, int i_query, va_list args )
{
if( !p_access ) return VLC_EGENERIC;
return p_access->pf_control( p_access, i_query, args );
return p_access->pf_control ? p_access->pf_control( p_access, i_query, args )
: VLC_EGENERIC;
}
static inline int access_Control( access_t *p_access, int i_query, ... )
......
......@@ -327,7 +327,6 @@ int DirInit (access_t *p_access, DIR *handle)
p_sys->ignored_exts = var_InheritString (p_access, "ignore-filetypes");
p_access->pf_readdir = DirRead;
p_access->pf_control = DirControl;
return VLC_SUCCESS;
......@@ -417,32 +416,3 @@ int DirRead (access_t *p_access, input_item_node_t *p_current_node)
return VLC_SUCCESS;
}
/*****************************************************************************
* Control:
*****************************************************************************/
int DirControl (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:
*va_arg (args, bool*) = false;
break;
case ACCESS_CAN_PAUSE:
case ACCESS_CAN_CONTROL_PACE:
*va_arg (args, bool*) = true;
break;
case ACCESS_GET_PTS_DELAY:
*va_arg (args, int64_t *) = DEFAULT_PTS_DELAY * 1000;
break;
default:
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
......@@ -692,32 +692,6 @@ static int BrowseDirectory( access_t *p_access, input_item_node_t *p_node )
return i_ret;
}
static int BrowserControl( 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:
*va_arg( args, bool* ) = false;
break;
case ACCESS_CAN_PAUSE:
case ACCESS_CAN_CONTROL_PACE:
*va_arg( args, bool* ) = true;
break;
case ACCESS_GET_PTS_DELAY:
*va_arg( args, int64_t * ) = DEFAULT_PTS_DELAY * 1000;
break;
default:
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
static int BrowserInit( access_t *p_access )
{
access_sys_t *p_sys = p_access->p_sys;
......@@ -726,7 +700,6 @@ static int BrowserInit( access_t *p_access )
p_access->pf_readdir = BrowseShare;
else
p_access->pf_readdir = BrowseDirectory;
p_access->pf_control = BrowserControl;
return VLC_SUCCESS;
}
......@@ -272,7 +272,6 @@ static int Open( vlc_object_t* p_this )
p_sys->file = libssh2_sftp_opendir( p_sys->sftp_session, url.psz_path );
p_access->pf_readdir = DirRead;
p_access->pf_control = DirControl;
if( p_sys->file )
{
......@@ -506,30 +505,3 @@ static int DirRead (access_t *p_access, input_item_node_t *p_current_node)
free( psz_file );
return VLC_SUCCESS;
}
static int DirControl( 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:
*va_arg( args, bool* ) = false;
break;
case ACCESS_CAN_PAUSE:
case ACCESS_CAN_CONTROL_PACE:
*va_arg( args, bool* ) = true;
break;
case ACCESS_GET_PTS_DELAY:
*va_arg( args, int64_t * ) = DEFAULT_PTS_DELAY * 1000;
break;
default:
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
......@@ -806,36 +806,6 @@ static int ReadDirectory( access_t *p_access, input_item_node_t* p_node )
return VLC_SUCCESS;
}
static int Control( access_t *, int i_query, va_list args )
{
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_SIZE:
{
*va_arg( args, uint64_t * ) = 0;
break;
}
case ACCESS_GET_PTS_DELAY:
*va_arg( args, int64_t * ) = 0;
break;
case ACCESS_SET_PAUSE_STATE:
/* Nothing to do */
break;
default:
return VLC_EGENERIC;
}
return VLC_SUCCESS;
}
static int Open( vlc_object_t *p_this )
{
access_t* p_access = (access_t*)p_this;
......@@ -852,7 +822,6 @@ static int Open( vlc_object_t *p_this )
}
p_access->pf_readdir = ReadDirectory;
ACCESS_SET_CALLBACKS( NULL, NULL, Control, NULL );
return VLC_SUCCESS;
}
......
......@@ -25,6 +25,8 @@
# include "config.h"
#endif
#include <assert.h>
#include "access.h"
#include <libvlc.h>
#include <vlc_url.h>
......@@ -89,6 +91,9 @@ access_t *access_New( vlc_object_t *p_obj, input_thread_t *p_parent_input,
if( p_access->p_module == NULL )
goto error;
/* if access has pf_readdir, pf_control is not mandatory */
assert( p_access->pf_control || p_access->pf_readdir );
return p_access;
error:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment