Commit d01c9337 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

variables: make forth var_Change() argument optional

Most requests do not actually need it.
parent 85cf41f7
......@@ -147,10 +147,9 @@ VLC_API void var_Destroy(vlc_object_t *obj, const char *name);
* \param name Variable name
* \param action Action to perform. Must be one of \ref var_action
* \param val First action parameter
* \param val2 Second action parameter
*/
VLC_API int var_Change(vlc_object_t *obj, const char *name, int action,
vlc_value_t *val, vlc_value_t *val2);
vlc_value_t *val, ...);
/**
* Get the type of a variable.
......@@ -780,7 +779,7 @@ VLC_API int var_LocationParse(vlc_object_t *, const char *mrl, const char *prefi
#ifndef DOC
#define var_Create(a,b,c) var_Create(VLC_OBJECT(a), b, c)
#define var_Destroy(a,b) var_Destroy(VLC_OBJECT(a), b)
#define var_Change(a,b,c,d,e) var_Change(VLC_OBJECT(a), b, c, d, e)
#define var_Change(a,b,c,...) var_Change(VLC_OBJECT(a), b, c, __VA_ARGS__)
#define var_Type(a,b) var_Type(VLC_OBJECT(a), b)
#define var_Set(a,b,c) var_Set(VLC_OBJECT(a), b, c)
#define var_Get(a,b,c) var_Get(VLC_OBJECT(a), b, c)
......
......@@ -387,7 +387,8 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
if( !p_input_thread )
return -1;
var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list,
(vlc_value_t *)NULL );
for( int i = 0; i < val_list.p_list->i_count; i++ )
{
if( i_track == val_list.p_list->p_values[i].i_int )
......
......@@ -359,7 +359,8 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
if( !p_input_thread )
return -1;
var_Change (p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &list, NULL);
var_Change(p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &list,
(vlc_value_t *)NULL);
for (int i = 0; i < list.p_list->i_count; i++)
{
if( i_spu == list.p_list->p_values[i].i_int )
......@@ -452,7 +453,7 @@ static void teletext_enable( input_thread_t *p_input_thread, bool b_enable )
{
vlc_value_t list;
if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETCHOICES,
&list, NULL ) )
&list, (vlc_value_t *)NULL ) )
{
if( list.p_list->i_count > 0 )
var_SetInteger( p_input_thread, "spu-es",
......@@ -573,7 +574,8 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
if( !p_input_thread )
return -1;
var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list,
(vlc_value_t *)NULL );
for( int i = 0; i < val_list.p_list->i_count; i++ )
{
if( i_track == val_list.p_list->p_values[i].i_int )
......
......@@ -1530,7 +1530,8 @@ static void CycleESTrack(input_thread_t *input, const char *var)
return;
vlc_value_t val;
if (var_Change(input, var, VLC_VAR_GETCHOICES, &val, NULL) < 0)
if (var_Change(input, var, VLC_VAR_GETCHOICES, &val,
(vlc_value_t *)NULL) < 0)
return;
vlc_list_t *list = val.p_list;
......
......@@ -489,7 +489,8 @@ static void aout_PrepareStereoMode (audio_output_t *aout,
bool mode_available = false;
vlc_value_t vals;
if (!var_Change(aout, "stereo-mode", VLC_VAR_GETCHOICES, &vals, NULL))
if (!var_Change(aout, "stereo-mode", VLC_VAR_GETCHOICES, &vals,
(vlc_value_t *)NULL))
{
for (int i = 0; !mode_available && i < vals.p_list->i_count; ++i)
{
......
......@@ -3279,7 +3279,8 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
/* Select the ES */
vlc_value_t list;
if( var_Change( p_input, psz_es, VLC_VAR_GETCHOICES, &list, NULL ) )
if( var_Change( p_input, psz_es, VLC_VAR_GETCHOICES, &list,
(vlc_value_t *)NULL ) )
return VLC_SUCCESS;
if( count.i_int == 0 )
......
......@@ -421,8 +421,9 @@ void var_DestroyAll( vlc_object_t *obj )
}
int (var_Change)(vlc_object_t *p_this, const char *psz_name,
int i_action, vlc_value_t *p_val, vlc_value_t *p_val2)
int i_action, vlc_value_t *p_val, ...)
{
va_list ap;
int ret = VLC_SUCCESS;
variable_t *p_var;
vlc_value_t oldval;
......@@ -439,6 +440,7 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name,
return VLC_ENOVAR;
}
va_start(ap, p_val);
switch( i_action )
{
case VLC_VAR_GETMIN:
......@@ -448,10 +450,14 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name,
*p_val = p_var->max;
break;
case VLC_VAR_SETMINMAX:
{
const vlc_value_t *p_val2 = va_arg(ap, vlc_value_t *);
assert(p_var->ops->pf_free == FreeDummy);
p_var->min = *p_val;
p_var->max = *p_val2;
break;
}
case VLC_VAR_SETSTEP:
assert(p_var->ops->pf_free == FreeDummy);
p_var->step = *p_val;
......@@ -476,6 +482,7 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name,
break;
case VLC_VAR_ADDCHOICE:
{
const vlc_value_t *p_val2 = va_arg(ap, vlc_value_t *);
int i = p_var->choices.i_count;
TAB_APPEND(p_var->choices.i_count,
......@@ -546,6 +553,9 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name,
p_var->ops->pf_free( &oldval );
break;
case VLC_VAR_GETCHOICES:
{
vlc_value_t *p_val2 = va_arg(ap, vlc_value_t *);
p_val->p_list = xmalloc( sizeof(vlc_list_t) );
p_val->p_list->p_values =
xmalloc( p_var->choices.i_count * sizeof(vlc_value_t) );
......@@ -571,6 +581,7 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name,
}
}
break;
}
case VLC_VAR_SETTEXT:
free( p_var->psz_text );
if( p_val && p_val->psz_string )
......@@ -585,9 +596,8 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name,
default:
break;
}
va_end(ap);
vlc_mutex_unlock( &p_priv->var_lock );
return ret;
}
......
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