}
static const struct variable_ops_t
+void_ops = { NULL, DupDummy, FreeDummy, },
addr_ops = { CmpAddress, DupDummy, FreeDummy, },
bool_ops = { CmpBool, DupDummy, FreeDummy, },
float_ops = { CmpFloat, DupDummy, FreeDummy, },
p_var->ops = &list_ops;
p_var->val.p_list = &dummy_null_list;
break;
+ default:
+ p_var->ops = &void_ops;
+ break;
}
/* Duplicate the default data we stored. */
}
-#undef var_AcquireMutex
-/**
- * Finds a process-wide mutex, creates it if needed, and locks it.
- * Unlock with vlc_mutex_unlock().
- */
-vlc_mutex_t *var_AcquireMutex( const char *name )
-{
- libvlc_global_data_t *p_global = vlc_global();
- vlc_value_t val;
-
- if( var_Create( p_global, name, VLC_VAR_MUTEX ) )
- return NULL;
-
- var_Get( p_global, name, &val );
- vlc_mutex_lock( val.p_address );
- return val.p_address;
-}
-
-
/**
* Register a callback in a variable
*
{
msg_Err( p_obj, "unsafe option \"%s\" has been ignored for "
"security reasons", psz_name );
+ free( psz_name );
return;
}
}
var_Set( p_obj, psz_name, val );
+ // If that's a list, remove all elements allocated
+ if( i_type == VLC_VAR_LIST )
+ FreeList( &val );
+
cleanup:
free( psz_name );
}
/*****************************************************************************
* InheritValue: try to inherit the value of this variable from the same one
- * in our closest parent.
+ * in our closest parent, libvlc or ultimately from the configuration.
+ * The function should always be entered with the object var_lock locked.
*****************************************************************************/
static int InheritValue( vlc_object_t *p_this, const char *psz_name,
vlc_value_t *p_val, int i_type )
{
int i_var;
variable_t *p_var;
- vlc_object_internals_t *p_priv;
-
- /* No need to take the structure lock,
- * we are only looking for our parents */
- if( !p_this->p_parent && !p_this->p_libvlc )
+ if( p_this->p_parent || ( p_this->p_libvlc && p_this != p_this->p_libvlc ) )
{
- switch( i_type & VLC_VAR_CLASS )
+ vlc_object_internals_t *p_priv;
+
+ if( p_this->p_parent )
+ p_priv = vlc_internals( p_this->p_parent );
+ else
+ p_priv = vlc_internals( p_this->p_libvlc );
+
+ i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
+
+ if( i_var >= 0 )
{
+ /* We found it! */
+ p_var = &p_priv->p_vars[i_var];
+
+ /* Really get the variable */
+ *p_val = p_var->val;
+
+ /* Duplicate value if needed */
+ p_var->ops->pf_dup( p_val );
+
+ return VLC_SUCCESS;
+ }
+ else if ( p_this->p_parent ) /* We are still not there */
+ return InheritValue( p_this->p_parent, psz_name, p_val, i_type );
+
+ /* else take value from config */
+ }
+
+
+ switch( i_type & VLC_VAR_CLASS )
+ {
case VLC_VAR_STRING:
p_val->psz_string = config_GetPsz( p_this, psz_name );
if( !p_val->psz_string ) p_val->psz_string = strdup("");
default:
return VLC_ENOOBJ;
break;
- }
-
- return VLC_SUCCESS;
}
-
- if( !p_this->p_parent )
- p_priv = vlc_internals( p_this->p_libvlc );
- else
- p_priv = vlc_internals( p_this->p_parent );
-
- /* Look for the variable */
- vlc_mutex_lock( &p_priv->var_lock );
-
- i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
-
- if( i_var >= 0 )
- {
- /* We found it! */
- p_var = &p_priv->p_vars[i_var];
-
- /* Really get the variable */
- *p_val = p_var->val;
-
- /* Duplicate value if needed */
- p_var->ops->pf_dup( p_val );
-
- vlc_mutex_unlock( &p_priv->var_lock );
- return VLC_SUCCESS;
- }
-
- vlc_mutex_unlock( &p_priv->var_lock );
-
- /* We're still not there */
-
- return InheritValue( p_this->p_parent, psz_name, p_val, i_type );
+ return VLC_SUCCESS;
}
/**********************************************************************