Browse Source

variables: make forth var_Change() argument optional

Most requests do not actually need it.
pull/70/head
Rémi Denis-Courmont 8 years ago
parent
commit
d01c9337a4
  1. 5
      include/vlc_variables.h
  2. 3
      lib/audio.c
  3. 8
      lib/video.c
  4. 3
      modules/gui/ncurses.c
  5. 3
      src/audio_output/output.c
  6. 3
      src/input/input.c
  7. 16
      src/misc/variables.c

5
include/vlc_variables.h

@ -147,10 +147,9 @@ VLC_API void var_Destroy(vlc_object_t *obj, const char *name);
* \param name Variable name * \param name Variable name
* \param action Action to perform. Must be one of \ref var_action * \param action Action to perform. Must be one of \ref var_action
* \param val First action parameter * \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_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. * 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 #ifndef DOC
#define var_Create(a,b,c) var_Create(VLC_OBJECT(a), b, c) #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_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_Type(a,b) var_Type(VLC_OBJECT(a), b)
#define var_Set(a,b,c) var_Set(VLC_OBJECT(a), b, c) #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) #define var_Get(a,b,c) var_Get(VLC_OBJECT(a), b, c)

3
lib/audio.c

@ -387,7 +387,8 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
if( !p_input_thread ) if( !p_input_thread )
return -1; 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++ ) for( int i = 0; i < val_list.p_list->i_count; i++ )
{ {
if( i_track == val_list.p_list->p_values[i].i_int ) if( i_track == val_list.p_list->p_values[i].i_int )

8
lib/video.c

@ -359,7 +359,8 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
if( !p_input_thread ) if( !p_input_thread )
return -1; 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++) for (int i = 0; i < list.p_list->i_count; i++)
{ {
if( i_spu == list.p_list->p_values[i].i_int ) 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; vlc_value_t list;
if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETCHOICES, 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 ) if( list.p_list->i_count > 0 )
var_SetInteger( p_input_thread, "spu-es", 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 ) if( !p_input_thread )
return -1; 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++ ) for( int i = 0; i < val_list.p_list->i_count; i++ )
{ {
if( i_track == val_list.p_list->p_values[i].i_int ) if( i_track == val_list.p_list->p_values[i].i_int )

3
modules/gui/ncurses.c

@ -1530,7 +1530,8 @@ static void CycleESTrack(input_thread_t *input, const char *var)
return; return;
vlc_value_t val; 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; return;
vlc_list_t *list = val.p_list; vlc_list_t *list = val.p_list;

3
src/audio_output/output.c

@ -489,7 +489,8 @@ static void aout_PrepareStereoMode (audio_output_t *aout,
bool mode_available = false; bool mode_available = false;
vlc_value_t vals; 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) for (int i = 0; !mode_available && i < vals.p_list->i_count; ++i)
{ {

3
src/input/input.c

@ -3279,7 +3279,8 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
/* Select the ES */ /* Select the ES */
vlc_value_t list; 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; return VLC_SUCCESS;
if( count.i_int == 0 ) if( count.i_int == 0 )

16
src/misc/variables.c

@ -421,8 +421,9 @@ void var_DestroyAll( vlc_object_t *obj )
} }
int (var_Change)(vlc_object_t *p_this, const char *psz_name, 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; int ret = VLC_SUCCESS;
variable_t *p_var; variable_t *p_var;
vlc_value_t oldval; vlc_value_t oldval;
@ -439,6 +440,7 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name,
return VLC_ENOVAR; return VLC_ENOVAR;
} }
va_start(ap, p_val);
switch( i_action ) switch( i_action )
{ {
case VLC_VAR_GETMIN: 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; *p_val = p_var->max;
break; break;
case VLC_VAR_SETMINMAX: case VLC_VAR_SETMINMAX:
{
const vlc_value_t *p_val2 = va_arg(ap, vlc_value_t *);
assert(p_var->ops->pf_free == FreeDummy); assert(p_var->ops->pf_free == FreeDummy);
p_var->min = *p_val; p_var->min = *p_val;
p_var->max = *p_val2; p_var->max = *p_val2;
break; break;
}
case VLC_VAR_SETSTEP: case VLC_VAR_SETSTEP:
assert(p_var->ops->pf_free == FreeDummy); assert(p_var->ops->pf_free == FreeDummy);
p_var->step = *p_val; p_var->step = *p_val;
@ -476,6 +482,7 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name,
break; break;
case VLC_VAR_ADDCHOICE: case VLC_VAR_ADDCHOICE:
{ {
const vlc_value_t *p_val2 = va_arg(ap, vlc_value_t *);
int i = p_var->choices.i_count; int i = p_var->choices.i_count;
TAB_APPEND(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 ); p_var->ops->pf_free( &oldval );
break; break;
case VLC_VAR_GETCHOICES: 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 = xmalloc( sizeof(vlc_list_t) );
p_val->p_list->p_values = p_val->p_list->p_values =
xmalloc( p_var->choices.i_count * sizeof(vlc_value_t) ); 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; break;
}
case VLC_VAR_SETTEXT: case VLC_VAR_SETTEXT:
free( p_var->psz_text ); free( p_var->psz_text );
if( p_val && p_val->psz_string ) if( p_val && p_val->psz_string )
@ -585,9 +596,8 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name,
default: default:
break; break;
} }
va_end(ap);
vlc_mutex_unlock( &p_priv->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return ret; return ret;
} }

Loading…
Cancel
Save