Skip to content

Commit

Permalink
variables: remove write-only variable default value
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Denis-Courmont committed Oct 22, 2016
1 parent 7c3221d commit 8583c1e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 37 deletions.
1 change: 0 additions & 1 deletion include/vlc_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
#define VLC_VAR_ADDCHOICE 0x0020
#define VLC_VAR_DELCHOICE 0x0021
#define VLC_VAR_CLEARCHOICES 0x0022
#define VLC_VAR_SETDEFAULT 0x0023
#define VLC_VAR_GETCHOICES 0x0024

#define VLC_VAR_CHOICESCOUNT 0x0026
Expand Down
10 changes: 0 additions & 10 deletions modules/access/v4l2/controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,6 @@ static vlc_v4l2_ctrl_t *ControlAddInteger (vlc_object_t *obj, int fd,
val.i_int = query->step;
var_Change (obj, c->name, VLC_VAR_SETSTEP, &val, NULL);
}
val.i_int = query->default_value;
var_Change (obj, c->name, VLC_VAR_SETDEFAULT, &val, NULL);
return c;
}

Expand Down Expand Up @@ -433,8 +431,6 @@ static vlc_v4l2_ctrl_t *ControlAddBoolean (vlc_object_t *obj, int fd,
val.b_bool = ctrl.value;
var_Change (obj, c->name, VLC_VAR_SETVALUE, &val, NULL);
}
val.b_bool = query->default_value;
var_Change (obj, c->name, VLC_VAR_SETDEFAULT, &val, NULL);
return c;
}

Expand Down Expand Up @@ -469,8 +465,6 @@ static vlc_v4l2_ctrl_t *ControlAddMenu (vlc_object_t *obj, int fd,
var_Change (obj, c->name, VLC_VAR_SETMINMAX,
&(vlc_value_t){ .i_int = query->minimum },
&(vlc_value_t){ .i_int = query->maximum } );
val.i_int = query->default_value;
var_Change (obj, c->name, VLC_VAR_SETDEFAULT, &val, NULL);

/* Import menu choices */
for (uint_fast32_t idx = query->minimum;
Expand Down Expand Up @@ -630,8 +624,6 @@ static vlc_v4l2_ctrl_t *ControlAddBitMask (vlc_object_t *obj, int fd,
var_Change (obj, c->name, VLC_VAR_SETMINMAX,
&(vlc_value_t){ .i_int = 0 },
&(vlc_value_t){ .i_int = (uint32_t)query->maximum } );
val.i_int = query->default_value;
var_Change (obj, c->name, VLC_VAR_SETDEFAULT, &val, NULL);
return c;
}

Expand Down Expand Up @@ -666,8 +658,6 @@ static vlc_v4l2_ctrl_t *ControlAddIntMenu (vlc_object_t *obj, int fd,
var_Change (obj, c->name, VLC_VAR_SETMINMAX,
&(vlc_value_t){ .i_int = query->minimum },
&(vlc_value_t){ .i_int = query->maximum } );
val.i_int = query->default_value;
var_Change (obj, c->name, VLC_VAR_SETDEFAULT, &val, NULL);

/* Import menu choices */
for (uint_fast32_t idx = query->minimum;
Expand Down
26 changes: 0 additions & 26 deletions src/misc/variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ struct variable_t
/** If the variable has min/max/step values */
vlc_value_t min, max, step;

/** Index of the default choice, if the variable is to be chosen in
* a list */
int i_default;
/** List of choices */
vlc_list_t choices;
/** List of friendly names for the choices */
Expand Down Expand Up @@ -312,7 +309,6 @@ int var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )

p_var->i_usage = 1;

p_var->i_default = -1;
p_var->choices.i_count = 0;
p_var->choices.p_values = NULL;
p_var->choices_text.i_count = 0;
Expand Down Expand Up @@ -535,11 +531,6 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
return VLC_EGENERIC;
}

if( p_var->i_default > i )
p_var->i_default--;
else if( p_var->i_default == i )
p_var->i_default = -1;

p_var->ops->pf_free( &p_var->choices.p_values[i] );
free( p_var->choices_text.p_values[i].psz_string );
REMOVE_ELEM( p_var->choices.p_values, p_var->choices.i_count, i );
Expand Down Expand Up @@ -567,25 +558,8 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
p_var->choices.p_values = NULL;
p_var->choices_text.i_count = 0;
p_var->choices_text.p_values = NULL;
p_var->i_default = -1;
TriggerListCallback(p_this, p_var, psz_name, VLC_VAR_CLEARCHOICES, NULL);
break;
case VLC_VAR_SETDEFAULT:
{
int i;
/* FIXME: the list is sorted, dude. Use something cleverer. */
for( i = 0 ; i < p_var->choices.i_count ; i++ )
if( p_var->ops->pf_cmp( p_var->choices.p_values[i], *p_val ) == 0 )
break;

if( i == p_var->choices.i_count )
/* Not found */
break;

p_var->i_default = i;
CheckValue( p_var, &p_var->val );
break;
}
case VLC_VAR_SETVALUE:
/* Duplicate data if needed */
newval = *p_val;
Expand Down

0 comments on commit 8583c1e

Please sign in to comment.