Commit 3b6a46b8 authored by Laurent Aimar's avatar Laurent Aimar

* access/*: use var_* helpers.

 * access/vcd/ clean up.
parent e34b5beb
......@@ -46,12 +46,12 @@ static void Close( vlc_object_t * );
vlc_module_begin();
set_description( _("Audio CD input") );
set_capability( "access2", 10 );
set_callbacks( Open, Close );
add_usage_hint( N_("[cdda:][device][@[track]]") );
add_integer( "cdda-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT,
CACHING_LONGTEXT, VLC_TRUE );
set_capability( "access2", 10 );
set_callbacks( Open, Close );
add_shortcut( "cdda" );
add_shortcut( "cddasimple" );
vlc_module_end();
......@@ -98,7 +98,6 @@ static int Open( vlc_object_t *p_this )
int i;
int i_title = 0;
vcddev_t *vcddev;
vlc_value_t val;
/* Command line: cdda://[dev_path][@title] */
if( ( psz = strchr( psz_dup, '@' ) ) )
......@@ -117,10 +116,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
var_Create( p_access, "cd-audio", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "cd-audio", &val );
psz_dup = val.psz_string;
psz_dup = var_CreateGetString( p_access, "cd-audio" );
if( *psz_dup == '\0' )
{
free( psz_dup );
......@@ -361,7 +357,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
int *pi_int;
int64_t *pi_64;
input_title_t ***ppp_title;
vlc_value_t val;
int i;
switch( i_query )
......@@ -383,8 +378,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
var_Get( p_access, "cdda-caching", &val );
*pi_64 = val.i_int * 1000;
*pi_64 = (int64_t)var_GetInteger( p_access, "cdda-caching" ) * I64C(1000);
break;
/* */
......
......@@ -164,8 +164,8 @@ static int ReadNull( access_t *p_access, uint8_t *p_buffer, int i_len)
*****************************************************************************/
static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
{
char *psz_name = 0;
vlc_value_t val;
char *psz_name = NULL;
char *psz;
int i_mode, i_pos;
playlist_t *p_playlist =
......@@ -190,13 +190,12 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
}
/* Initialize structure */
var_Create( p_access, "recursive", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "recursive", &val );
if( *val.psz_string == '\0' || !strncmp( val.psz_string, "none" , 4 ) )
psz = var_CreateGetString( p_access, "recursive" );
if( *psz == '\0' || !strncmp( psz, "none" , 4 ) )
{
i_mode = MODE_NONE;
}
else if( !strncmp( val.psz_string, "collapse", 8 ) )
else if( !strncmp( psz, "collapse", 8 ) )
{
i_mode = MODE_COLLAPSE;
}
......@@ -204,7 +203,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len)
{
i_mode = MODE_EXPAND;
}
free( val.psz_string );
free( psz );
/* Make sure we are deleted when we are done */
p_playlist->pp_items[p_playlist->i_index]->b_autodeletion = VLC_TRUE;
......
......@@ -129,15 +129,14 @@ static int Open( vlc_object_t *p_this )
{
access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys;
char * psz_name = p_access->psz_path;
char *psz_name = p_access->psz_path;
char *psz;
#ifdef HAVE_SYS_STAT_H
int i_stat;
struct stat stat_info;
#endif
vlc_bool_t b_stdin;
vlc_value_t val;
file_entry_t * p_file;
......@@ -251,12 +250,10 @@ static int Open( vlc_object_t *p_this )
p_file->psz_name = strdup( psz_name );
TAB_APPEND( p_sys->i_file, p_sys->file, p_file );
var_Create( p_access, "file-cat", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "file-cat", &val );
if( *val.psz_string )
psz = var_CreateGetString( p_access, "file-cat" );
if( *psz )
{
char *psz_parser = psz_name = val.psz_string;
char *psz_parser = psz_name = psz;
int64_t i_size;
while( psz_name && *psz_name )
......@@ -292,7 +289,7 @@ static int Open( vlc_object_t *p_this )
if( psz_name ) psz_name++;
}
}
free( val.psz_string );
free( psz );
return VLC_SUCCESS;
}
......@@ -515,7 +512,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
vlc_bool_t *pb_bool;
int *pi_int;
int64_t *pi_64;
vlc_value_t val;
switch( i_query )
{
......@@ -540,8 +536,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
var_Get( p_access, "file-caching", &val );
*pi_64 = val.i_int * 1000;
*pi_64 = (int64_t)var_GetInteger( p_access, "file-caching" ) * I64C(1000);
break;
/* */
case ACCESS_SET_PAUSE_STATE:
......
......@@ -94,7 +94,6 @@ static int Open( vlc_object_t *p_this )
access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys;
char *psz;
vlc_value_t val;
int i_answer;
char *psz_arg;
......@@ -158,15 +157,14 @@ static int Open( vlc_object_t *p_this )
msg_Dbg( p_access, "connection accepted (%d)", i_answer );
var_Create( p_access, "ftp-user", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "ftp-user", &val );
if( ftp_SendCommand( p_access, "USER %s", val.psz_string ) < 0 ||
psz = var_CreateGetString( p_access, "ftp-user" );
if( ftp_SendCommand( p_access, "USER %s", psz ) < 0 ||
ftp_ReadCommand( p_access, &i_answer, NULL ) < 0 )
{
if( val.psz_string ) free( val.psz_string );
free( psz );
goto exit_error;
}
if( val.psz_string ) free( val.psz_string );
free( psz );
switch( i_answer / 100 )
{
......@@ -175,15 +173,14 @@ static int Open( vlc_object_t *p_this )
break;
case 3:
msg_Dbg( p_access, "password needed" );
var_Create( p_access, "ftp-pwd", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "ftp-pwd", &val );
if( ftp_SendCommand( p_access, "PASS %s", val.psz_string ) < 0 ||
psz = var_CreateGetString( p_access, "ftp-pwd" );
if( ftp_SendCommand( p_access, "PASS %s", psz ) < 0 ||
ftp_ReadCommand( p_access, &i_answer, NULL ) < 0 )
{
if( val.psz_string ) free( val.psz_string );
free( psz );
goto exit_error;
}
if( val.psz_string ) free( val.psz_string );
free( psz );
switch( i_answer / 100 )
{
......@@ -192,17 +189,15 @@ static int Open( vlc_object_t *p_this )
break;
case 3:
msg_Dbg( p_access, "account needed" );
var_Create( p_access, "ftp-account",
VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "ftp-account", &val );
psz = var_CreateGetString( p_access, "ftp-account" );
if( ftp_SendCommand( p_access, "ACCT %s",
val.psz_string ) < 0 ||
psz ) < 0 ||
ftp_ReadCommand( p_access, &i_answer, NULL ) < 0 )
{
if( val.psz_string ) free( val.psz_string );
free( psz );
goto exit_error;
}
if( val.psz_string ) free( val.psz_string );
free( psz );
if( i_answer / 100 != 2 )
{
......@@ -372,7 +367,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
var_Get( p_access, "ftp-caching", &val );
*pi_64 = val.i_int * 1000;
*pi_64 = (int64_t)var_GetInteger( p_access, "ftp-caching" ) * I64C(1000);
break;
/* */
......
......@@ -129,7 +129,7 @@ static int Open ( vlc_object_t *p_this )
{
access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys;
vlc_value_t val;
char *psz;
/* First set ipv4/ipv6 */
var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
......@@ -137,6 +137,7 @@ static int Open ( vlc_object_t *p_this )
if( *p_access->psz_access )
{
vlc_value_t val;
/* Find out which shortcut was used */
if( !strncmp( p_access->psz_access, "http4", 6 ) )
{
......@@ -191,27 +192,19 @@ static int Open ( vlc_object_t *p_this )
}
if( !p_sys->psz_user || *p_sys->psz_user == '\0' )
{
var_Create( p_access, "http-user", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "http-user", &val );
p_sys->psz_user = val.psz_string;
var_Create( p_access, "http-pwd", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "http-pwd", &val );
p_sys->psz_passwd = val.psz_string;
p_sys->psz_user = var_CreateGetString( p_access, "http-user" );
p_sys->psz_passwd = var_CreateGetString( p_access, "http-pwd" );
}
/* Do user agent */
var_Create( p_access, "http-user-agent", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "http-user-agent", &val );
p_sys->psz_user_agent = val.psz_string;
p_sys->psz_user_agent = var_CreateGetString( p_access, "http-user-agent" );
/* Check proxy */
var_Create( p_access, "http-proxy", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Get( p_access, "http-proxy", &val );
if( val.psz_string && *val.psz_string )
psz = var_CreateGetString( p_access, "http-proxy" );
if( *psz )
{
p_sys->b_proxy = VLC_TRUE;
vlc_UrlParse( &p_sys->proxy, val.psz_string, 0 );
vlc_UrlParse( &p_sys->proxy, psz, 0 );
}
else
{
......@@ -219,17 +212,12 @@ static int Open ( vlc_object_t *p_this )
if( psz_proxy && *psz_proxy )
{
p_sys->b_proxy = VLC_TRUE;
vlc_UrlParse( &p_sys->proxy, val.psz_string, 0 );
vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 );
}
if( psz_proxy )
{
free( psz_proxy );
}
}
if( val.psz_string )
{
free( val.psz_string );
}
free( psz );
if( p_sys->b_proxy )
{
......@@ -497,7 +485,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
var_Get( p_access, "http-caching", &val );
*pi_64 = val.i_int * 1000;
*pi_64 = (int64_t)var_GetInteger( p_access, "http-caching" ) * 1000;
break;
/* */
......
......@@ -66,7 +66,6 @@ int E_(MMSHOpen)( access_t *p_access )
{
access_sys_t *p_sys;
char *psz_location = NULL;
vlc_value_t val;
/* init p_sys */
......@@ -145,9 +144,6 @@ int E_(MMSHOpen)( access_t *p_access )
p_access->info.i_size = p_sys->asfh.i_file_size;
}
/* Update default_pts to a suitable value for mms access */
var_Get( p_access, "mms-caching", &val );
return VLC_SUCCESS;
}
......@@ -171,7 +167,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
vlc_bool_t *pb_bool;
int *pi_int;
int64_t *pi_64;
vlc_value_t val;
switch( i_query )
{
......@@ -195,8 +190,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
var_Get( p_access, "mms-caching", &val );
*pi_64 = val.i_int * 1000;
*pi_64 = (int64_t)var_GetInteger( p_access, "mms-caching" ) * I64C(1000);
break;
/* */
......@@ -531,10 +525,10 @@ static int Describe( access_t *p_access, char **ppsz_location )
p_sys->asfh.i_min_data_packet_size );
E_( asf_StreamSelect)( &p_sys->asfh,
config_GetInt( p_access, "mms-maxbitrate" ),
config_GetInt( p_access, "mms-all" ),
config_GetInt( p_access, "audio" ),
config_GetInt( p_access, "video" ) );
var_CreateGetInteger( p_access, "mms-maxbitrate" ),
var_CreateGetInteger( p_access, "mms-all" ),
var_CreateGetInteger( p_access, "audio" ),
var_CreateGetInteger( p_access, "video" ) );
return VLC_SUCCESS;
......
......@@ -120,7 +120,6 @@ int E_(MMSTUOpen)( access_t *p_access )
access_sys_t *p_sys;
int i_proto;
int i_status;
vlc_value_t val;
/* Set up p_access */
p_access->pf_read = Read;
......@@ -215,10 +214,6 @@ int E_(MMSTUOpen)( access_t *p_access )
vlc_UrlClean( &p_sys->url );
return VLC_EGENERIC;
}
/* Update default_pts to a suitable value for mms access */
var_Get( p_access, "mms-caching", &val );
return VLC_SUCCESS;
}
......@@ -272,7 +267,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
var_Get( p_access, "mms-caching", &val );
*pi_64 = val.i_int * 1000;
*pi_64 = (int64_t)var_GetInteger( p_access, "mms-caching" ) * I64C(1000);
break;
/* */
......@@ -748,10 +743,10 @@ static int MMSOpen( access_t *p_access, vlc_url_t *p_url, int i_proto )
E_( asf_HeaderParse )( &p_sys->asfh,
p_sys->p_header, p_sys->i_header );
E_( asf_StreamSelect)( &p_sys->asfh,
config_GetInt( p_access, "mms-maxbitrate" ),
config_GetInt( p_access, "mms-all" ),
config_GetInt( p_access, "audio" ),
config_GetInt( p_access, "video" ) );
var_CreateGetInteger( p_access, "mms-maxbitrate" ),
var_CreateGetInteger( p_access, "mms-all" ),
var_CreateGetInteger( p_access, "audio" ),
var_CreateGetInteger( p_access, "video" ) );
/* *** now select stream we want to receive *** */
/* TODO take care of stream bitrate TODO */
......
......@@ -172,7 +172,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
vlc_bool_t *pb_bool;
int *pi_int;
int64_t *pi_64;
vlc_value_t val;
switch( i_query )
{
......@@ -199,8 +198,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
var_Get( p_access, "tcp-caching", &val );
*pi_64 = val.i_int * 1000;
*pi_64 = (int64_t)var_GetInteger( p_access, "tcp-caching" ) * I64C(1000);
break;
/* */
......
......@@ -103,7 +103,6 @@ static int Open( vlc_object_t *p_this )
char *psz_bind_port = "";
int i_bind_port = 0;
int i_server_port = 0;
vlc_value_t val;
/* First set ipv4/ipv6 */
......@@ -112,6 +111,7 @@ static int Open( vlc_object_t *p_this )
if( *p_access->psz_access )
{
vlc_value_t val;
/* Find out which shortcut was used */
if( !strncmp( p_access->psz_access, "udp4", 6 ) ||
!strncmp( p_access->psz_access, "rtp4", 6 ))
......@@ -201,9 +201,7 @@ static int Open( vlc_object_t *p_this )
i_server_port = strtol( psz_server_port, NULL, 10 );
if( ( i_bind_port = strtol( psz_bind_port, NULL, 10 ) ) == 0 )
{
var_Create( p_access, "server-port", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_access, "server-port", &val );
i_bind_port = val.i_int;
i_bind_port = var_CreateGetInteger( p_access, "server-port" );
}
msg_Dbg( p_access, "opening server=%s:%d local=%s:%d",
......@@ -234,13 +232,11 @@ static int Open( vlc_object_t *p_this )
free( psz_name );
/* FIXME */
var_Create( p_access, "mtu", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_access, "mtu", &val);
p_sys->i_mtu = val.i_int > 0 ? val.i_int : 1500; /* avoid problem */
p_sys->i_mtu = var_CreateGetInteger( p_access, "mtu" );
if( p_sys->i_mtu <= 1 )
p_sys->i_mtu = 1500; /* Avoid problem */
var_Create( p_access, "udp-auto-mtu", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Get( p_access, "udp-auto-mtu", &val);
p_sys->b_auto_mtu = val.b_bool;
p_sys->b_auto_mtu = var_CreateGetBool( p_access, "udp-auto-mtu" );;
/* Update default_pts to a suitable value for udp access */
var_Create( p_access, "udp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
......@@ -290,7 +286,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * );
var_Get( p_access, "udp-caching", &val );
*pi_64 = val.i_int * 1000;
*pi_64 = var_GetInteger( p_access, "udp-caching" ) * 1000;
break;
/* */
......
This diff is collapsed.
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