VLC  3.0.15
Data Structures | Typedefs | Enumerations | Functions | Variables
variables.c File Reference
Include dependency graph for variables.c:

Data Structures

struct  callback_entry_t
 
struct  variable_ops_t
 
struct  callback_table_t
 
struct  variable_t
 The structure describing a variable. More...
 

Typedefs

typedef struct callback_entry_t callback_entry_t
 
typedef struct variable_ops_t variable_ops_t
 
typedef struct callback_table_t callback_table_t
 

Enumerations

enum  vlc_callback_type_t { vlc_value_callback, vlc_list_callback }
 

Functions

static int CmpBool (vlc_value_t v, vlc_value_t w)
 
static int CmpInt (vlc_value_t v, vlc_value_t w)
 
static int CmpString (vlc_value_t v, vlc_value_t w)
 
static int CmpFloat (vlc_value_t v, vlc_value_t w)
 
static int CmpAddress (vlc_value_t v, vlc_value_t w)
 
static void DupDummy (vlc_value_t *p_val)
 
static void DupString (vlc_value_t *p_val)
 
static void FreeDummy (vlc_value_t *p_val)
 
static void FreeString (vlc_value_t *p_val)
 
static int varcmp (const void *a, const void *b)
 
static variable_tLookup (vlc_object_t *obj, const char *psz_name)
 
static void Destroy (variable_t *p_var)
 
static void CheckValue (variable_t *var, vlc_value_t *val)
 Adjusts a value to fit the constraints for a certain variable: More...
 
static void WaitUnused (vlc_object_t *obj, variable_t *var)
 Waits until the variable is inactive (i.e. More...
 
static void TriggerCallback (vlc_object_t *obj, variable_t *var, const char *name, vlc_value_t prev)
 
static void TriggerListCallback (vlc_object_t *obj, variable_t *var, const char *name, int action, vlc_value_t *val)
 
int var_Create (vlc_object_t *p_this, const char *psz_name, int i_type)
 Initialize a vlc variable. More...
 
void() var_Destroy (vlc_object_t *p_this, const char *psz_name)
 Destroy a vlc variable. More...
 
static void CleanupVar (void *var)
 
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)
 Perform an action on a variable. More...
 
int var_GetAndSet (vlc_object_t *p_this, const char *psz_name, int i_action, vlc_value_t *p_val)
 Perform a Get and Set on a variable. More...
 
int var_Type (vlc_object_t *p_this, const char *psz_name)
 Request a variable's type. More...
 
int var_SetChecked (vlc_object_t *p_this, const char *psz_name, int expected_type, vlc_value_t val)
 
int var_Set (vlc_object_t *p_this, const char *psz_name, vlc_value_t val)
 Set a variable's value. More...
 
int var_GetChecked (vlc_object_t *p_this, const char *psz_name, int expected_type, vlc_value_t *p_val)
 
int var_Get (vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val)
 Get a variable's value. More...
 
static void AddCallback (vlc_object_t *p_this, const char *psz_name, callback_entry_t entry, vlc_callback_type_t i_type)
 
void var_AddCallback (vlc_object_t *p_this, const char *psz_name, vlc_callback_t pf_callback, void *p_data)
 Register a callback in a variable. More...
 
static void DelCallback (vlc_object_t *p_this, const char *psz_name, callback_entry_t entry, vlc_callback_type_t i_type)
 
void var_DelCallback (vlc_object_t *p_this, const char *psz_name, vlc_callback_t pf_callback, void *p_data)
 Remove a callback from a variable. More...
 
void var_TriggerCallback (vlc_object_t *p_this, const char *psz_name)
 Trigger callback on a variable. More...
 
void var_AddListCallback (vlc_object_t *p_this, const char *psz_name, vlc_list_callback_t pf_callback, void *p_data)
 Register a callback for a list variable. More...
 
void var_DelListCallback (vlc_object_t *p_this, const char *psz_name, vlc_list_callback_t pf_callback, void *p_data)
 Remove a callback from a list variable. More...
 
void var_OptionParse (vlc_object_t *p_obj, const char *psz_option, bool trusted)
 Parse a stringified option This function parse a string option and create the associated object variable The option must be of the form "[no[-]]foo[=bar]" where foo is the option name and bar is the value of the option. More...
 
int var_LocationParse (vlc_object_t *obj, const char *mrl, const char *pref)
 Parses a set of colon-separated or semicolon-separated name=value pairs. More...
 
int var_Inherit (vlc_object_t *p_this, const char *psz_name, int i_type, vlc_value_t *p_val)
 Finds the value of a variable. More...
 
int() var_InheritURational (vlc_object_t *object, unsigned *num, unsigned *den, const char *var)
 It inherits a string as an unsigned rational number (it also accepts basic float number). More...
 
void var_FreeList (vlc_value_t *p_val, vlc_value_t *p_val2)
 Free a list and the associated strings. More...
 
static void DumpVariable (const void *data, const VISIT which, const int depth)
 
void DumpVariables (vlc_object_t *obj)
 
static void TwalkGetNames (const void *data, const VISIT which, const int depth)
 
char ** var_GetAllNames (vlc_object_t *obj)
 Return a list of all variable names. More...
 

Variables

static const struct variable_ops_t void_ops = { NULL, DupDummy, FreeDummy, }
 
static const struct variable_ops_t addr_ops = { CmpAddress, DupDummy, FreeDummy, }
 
static const struct variable_ops_t bool_ops = { CmpBool, DupDummy, FreeDummy, }
 
static const struct variable_ops_t float_ops = { CmpFloat, DupDummy, FreeDummy, }
 
static const struct variable_ops_t int_ops = { CmpInt, DupDummy, FreeDummy, }
 
static const struct variable_ops_t string_ops = { CmpString, DupString, FreeString, }
 
static const struct variable_ops_t coords_ops = { NULL, DupDummy, FreeDummy, }
 
static thread_local void * twalk_ctx
 

Typedef Documentation

◆ callback_entry_t

◆ callback_table_t

◆ variable_ops_t

Enumeration Type Documentation

◆ vlc_callback_type_t

Enumerator
vlc_value_callback 
vlc_list_callback 

Function Documentation

◆ AddCallback()

static void AddCallback ( vlc_object_t p_this,
const char *  psz_name,
callback_entry_t  entry,
vlc_callback_type_t  i_type 
)
static

◆ CheckValue()

static void CheckValue ( variable_t var,
vlc_value_t val 
)
static

Adjusts a value to fit the constraints for a certain variable:

  • If the value is lower than the minimum, use the minimum.
  • If the value is higher than the maximum, use the maximum.
  • If the variable has steps, round the value to the nearest step.

References vlc_value_t::f_float, vlc_value_t::i_int, variable_t::i_type, variable_t::max, variable_t::min, variable_t::step, VLC_VAR_FLOAT, VLC_VAR_INTEGER, and VLC_VAR_TYPE.

Referenced by var_Change(), var_GetAndSet(), and var_SetChecked().

◆ CleanupVar()

static void CleanupVar ( void *  var)
static

◆ CmpAddress()

static int CmpAddress ( vlc_value_t  v,
vlc_value_t  w 
)
static

◆ CmpBool()

static int CmpBool ( vlc_value_t  v,
vlc_value_t  w 
)
static

◆ CmpFloat()

static int CmpFloat ( vlc_value_t  v,
vlc_value_t  w 
)
static

◆ CmpInt()

static int CmpInt ( vlc_value_t  v,
vlc_value_t  w 
)
static

◆ CmpString()

static int CmpString ( vlc_value_t  v,
vlc_value_t  w 
)
static

◆ DelCallback()

static void DelCallback ( vlc_object_t p_this,
const char *  psz_name,
callback_entry_t  entry,
vlc_callback_type_t  i_type 
)
static

◆ Destroy()

static void Destroy ( variable_t p_var)
static

Referenced by var_Create(), and var_Destroy().

◆ DumpVariable()

static void DumpVariable ( const void *  data,
const VISIT  which,
const int  depth 
)
static

◆ DumpVariables()

void DumpVariables ( vlc_object_t obj)

◆ DupDummy()

static void DupDummy ( vlc_value_t p_val)
static

References vlc_value_t::p_address.

Referenced by varcmp().

◆ DupString()

static void DupString ( vlc_value_t p_val)
static

◆ FreeDummy()

static void FreeDummy ( vlc_value_t p_val)
static

Referenced by var_Change(), and varcmp().

◆ FreeString()

static void FreeString ( vlc_value_t p_val)
static

◆ Lookup()

static variable_t* Lookup ( vlc_object_t obj,
const char *  psz_name 
)
static

◆ TriggerCallback()

static void TriggerCallback ( vlc_object_t obj,
variable_t var,
const char *  name,
vlc_value_t  prev 
)
static

◆ TriggerListCallback()

static void TriggerListCallback ( vlc_object_t obj,
variable_t var,
const char *  name,
int  action,
vlc_value_t val 
)
static

Referenced by var_Change().

◆ TwalkGetNames()

static void TwalkGetNames ( const void *  data,
const VISIT  which,
const int  depth 
)
static

◆ var_Destroy()

void() var_Destroy ( vlc_object_t p_this,
const char *  psz_name 
)

Destroy a vlc variable.

Look for the variable and destroy it if it is found. As in var_Create we do a call to memmove() but we have performance counterparts elsewhere.

Parameters
p_thisThe object that holds the variable
psz_nameThe name of the variable

References variable_t::b_incallback, Destroy(), variable_t::i_usage, Lookup(), msg_Dbg, psz_name, tdelete(), vlc_object_internals::var_lock, vlc_object_internals::var_root, varcmp(), vlc_internals, and vlc_mutex_unlock().

◆ var_DestroyAll()

void var_DestroyAll ( vlc_object_t obj)

Referenced by vlc_object_destroy().

◆ var_GetAllNames()

char** var_GetAllNames ( vlc_object_t )

Return a list of all variable names.

There is no warranty that the returned variables will be still alive after the return of this function.

Returns
a NULL terminated list of char *, each elements and the return value must be freed by the caller

Referenced by filter_AddProxyCallbacks(), and filter_DelProxyCallbacks().

◆ var_InheritURational()

int() var_InheritURational ( vlc_object_t object,
unsigned *  num,
unsigned *  den,
const char *  var 
)

It inherits a string as an unsigned rational number (it also accepts basic float number).

It returns an error if the rational number cannot be parsed (0/0 is valid). The rational is already reduced.

< No error

< Unspecified error

References var_InheritString, VLC_EGENERIC, VLC_SUCCESS, and vlc_ureduce().

◆ var_OptionParse()

void var_OptionParse ( vlc_object_t p_obj,
const char *  psz_option,
bool  trusted 
)

Parse a stringified option This function parse a string option and create the associated object variable The option must be of the form "[no[-]]foo[=bar]" where foo is the option name and bar is the value of the option.

Parameters
p_objthe object in which the variable must be created
psz_optionthe option to parse
trustedwhether the option is set by a trusted input or not
Returns
nothing

References vlc_value_t::b_bool, config_GetType(), config_IsSafe(), vlc_value_t::f_float, vlc_value_t::i_int, i_type, msg_Err, psz_name, vlc_value_t::psz_string, psz_value, strdup(), strtoll(), us_atof(), var_Create(), var_Set(), VLC_VAR_BOOL, VLC_VAR_FLOAT, VLC_VAR_INTEGER, and VLC_VAR_STRING.

Referenced by input_item_ApplyOptions(), and var_LocationParse().

◆ varcmp()

static int varcmp ( const void *  a,
const void *  b 
)
static

References DupDummy(), and FreeDummy().

Referenced by var_Create(), and var_Destroy().

◆ WaitUnused()

static void WaitUnused ( vlc_object_t obj,
variable_t var 
)
static

Variable Documentation

◆ addr_ops

const struct variable_ops_t addr_ops = { CmpAddress, DupDummy, FreeDummy, }
static

Referenced by var_Create().

◆ bool_ops

const struct variable_ops_t bool_ops = { CmpBool, DupDummy, FreeDummy, }
static

Referenced by var_Create().

◆ coords_ops

const struct variable_ops_t coords_ops = { NULL, DupDummy, FreeDummy, }
static

Referenced by var_Create().

◆ float_ops

const struct variable_ops_t float_ops = { CmpFloat, DupDummy, FreeDummy, }
static

Referenced by var_Create().

◆ int_ops

const struct variable_ops_t int_ops = { CmpInt, DupDummy, FreeDummy, }
static

Referenced by var_Create().

◆ string_ops

const struct variable_ops_t string_ops = { CmpString, DupString, FreeString, }
static

Referenced by var_Create().

◆ twalk_ctx

thread_local void* twalk_ctx
static

Referenced by TwalkGetNames().

◆ void_ops

const struct variable_ops_t void_ops = { NULL, DupDummy, FreeDummy, }
static

Referenced by var_Create().