VLC 4.0.0-dev
Loading...
Searching...
No Matches
variables.c File Reference
Include dependency graph for variables.c:

Data Structures

struct  callback_entry_t
 
struct  variable_ops_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
 

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:
 
static void WaitUnused (vlc_object_t *obj, variable_t *var)
 Waits until the variable is inactive (i.e.
 
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)
 Creates a VLC object variable.
 
void() var_Destroy (vlc_object_t *p_this, const char *psz_name)
 Destroys a VLC object variable.
 
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,...)
 Performs a special action on a variable.
 
int() var_GetAndSet (vlc_object_t *p_this, const char *psz_name, int i_action, vlc_value_t *p_val)
 Perform an atomic read-modify-write of a variable.
 
int() var_Type (vlc_object_t *p_this, const char *psz_name)
 Get the type of a variable.
 
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)
 Sets a variable value.
 
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)
 Gets a variable value.
 
static void AddCallback (vlc_object_t *p_this, const char *psz_name, callback_entry_t *restrict 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)
 Registers a callback for a variable.
 
static void DelCallback (vlc_object_t *p_this, const char *psz_name, const callback_entry_t *restrict match, 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)
 Deregisters a callback from a variable.
 
void() var_TriggerCallback (vlc_object_t *p_this, const char *psz_name)
 Triggers callbacks on a variable.
 
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.
 
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.
 
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.
 
int() var_LocationParse (vlc_object_t *obj, const char *mrl, const char *pref)
 Parses a string with multiple options.
 
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.
 
int() var_InheritURational (vlc_object_t *object, unsigned *num, unsigned *den, const char *var)
 Inherit a string as a fractional value.
 
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.
 

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

◆ variable_ops_t

Enumeration Type Documentation

◆ vlc_callback_type_t

Enumerator
vlc_value_callback 
vlc_list_callback 

Function Documentation

◆ AddCallback()

◆ 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, var, 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

References Destroy(), and var.

Referenced by var_DestroyAll().

◆ 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

References vlc_value_t::b_bool.

◆ CmpFloat()

static int CmpFloat ( vlc_value_t  v,
vlc_value_t  w 
)
static

References vlc_value_t::f_float.

◆ CmpInt()

static int CmpInt ( vlc_value_t  v,
vlc_value_t  w 
)
static

References vlc_value_t::i_int.

◆ CmpString()

static int CmpString ( vlc_value_t  v,
vlc_value_t  w 
)
static

◆ DelCallback()

◆ Destroy()

◆ DupDummy()

static void DupDummy ( vlc_value_t p_val)
static

◆ DupString()

static void DupString ( vlc_value_t p_val)
static

◆ FreeDummy()

static void FreeDummy ( vlc_value_t p_val)
static

Referenced by var_Change().

◆ FreeString()

static void FreeString ( vlc_value_t p_val)
static

◆ Lookup()

◆ 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

◆ TwalkGetNames()

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

◆ var_DestroyAll()

void var_DestroyAll ( vlc_object_t obj)

◆ var_GetAllNames()

char ** var_GetAllNames ( vlc_object_t obj)

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

References ARRAY_APPEND, ARRAY_INIT, DECL_ARRAY, twalk(), twalk_ctx, TwalkGetNames(), vlc_object_internals::var_lock, vlc_object_internals::var_root, vlc_internals, vlc_mutex_lock(), and vlc_mutex_unlock().

Referenced by filter_AddProxyCallbacks(), and filter_DelProxyCallbacks().

◆ 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

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, strcasecmp(), strdup(), strtoll(), var_Create(), var_Set(), vlc_atof_c(), 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 variable_t::psz_name.

Referenced by Lookup(), var_Create(), and var_Destroy().

◆ WaitUnused()

static void WaitUnused ( vlc_object_t obj,
variable_t var 
)
static

Waits until the variable is inactive (i.e.

not executing a callback)

References var, vlc_object_internals::var_lock, vlc_cond_wait(), and vlc_internals.

Referenced by AddCallback(), DelCallback(), var_GetAndSet(), var_SetChecked(), and var_TriggerCallback().

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(), and var_GetAllNames().

◆ void_ops

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

Referenced by var_Create().