Commit 609a1146 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Hide internal variables state

parent c5f25910
...@@ -562,11 +562,6 @@ typedef struct vlc_object_internals_t vlc_object_internals_t; ...@@ -562,11 +562,6 @@ typedef struct vlc_object_internals_t vlc_object_internals_t;
volatile vlc_bool_t b_attached; /**< set by the object */ \ volatile vlc_bool_t b_attached; /**< set by the object */ \
vlc_bool_t b_force; /**< set by the outside (eg. module_Need()) */ \ vlc_bool_t b_force; /**< set by the outside (eg. module_Need()) */ \
\ \
/* Object variables */ \
vlc_mutex_t var_lock; \
int i_vars; \
variable_t * p_vars; \
\
/* Stuff related to the libvlc structure */ \ /* Stuff related to the libvlc structure */ \
libvlc_int_t *p_libvlc; /**< (root of all evil) - 1 */ \ libvlc_int_t *p_libvlc; /**< (root of all evil) - 1 */ \
\ \
......
...@@ -82,9 +82,13 @@ uint32_t CPUCapabilities( void ); ...@@ -82,9 +82,13 @@ uint32_t CPUCapabilities( void );
/* Private LibVLC data for each objects */ /* Private LibVLC data for each objects */
struct vlc_object_internals_t struct vlc_object_internals_t
{ {
/* Object variables */
vlc_mutex_t var_lock;
int i_vars;
variable_t * p_vars;
}; };
static inline vlc_object_internals_t *vlc_internals( vlc_object_t *obj ) static inline vlc_object_internals_t *vlc_internals( vlc_object_t *obj )
{ {
return obj->p_internals; return obj->p_internals;
......
...@@ -125,7 +125,6 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size, ...@@ -125,7 +125,6 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
p_new->psz_header = NULL; p_new->psz_header = NULL;
p_new->i_flags = 0;
if( p_this->i_flags & OBJECT_FLAGS_NODBG ) if( p_this->i_flags & OBJECT_FLAGS_NODBG )
p_new->i_flags |= OBJECT_FLAGS_NODBG; p_new->i_flags |= OBJECT_FLAGS_NODBG;
if( p_this->i_flags & OBJECT_FLAGS_QUIET ) if( p_this->i_flags & OBJECT_FLAGS_QUIET )
...@@ -133,10 +132,9 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size, ...@@ -133,10 +132,9 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
if( p_this->i_flags & OBJECT_FLAGS_NOINTERACT ) if( p_this->i_flags & OBJECT_FLAGS_NOINTERACT )
p_new->i_flags |= OBJECT_FLAGS_NOINTERACT; p_new->i_flags |= OBJECT_FLAGS_NOINTERACT;
p_new->i_vars = 0; p_priv->p_vars = calloc( sizeof( variable_t ), 16 );
p_new->p_vars = (variable_t *)malloc( 16 * sizeof( variable_t ) );
if( !p_new->p_vars ) if( !p_priv->p_vars )
{ {
if( i_type != VLC_OBJECT_GLOBAL ) if( i_type != VLC_OBJECT_GLOBAL )
free( p_priv ); free( p_priv );
...@@ -186,7 +184,7 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size, ...@@ -186,7 +184,7 @@ vlc_object_t *vlc_custom_create( vlc_object_t *p_this, size_t i_size,
/* Initialize mutexes and condvars */ /* Initialize mutexes and condvars */
vlc_mutex_init( p_new, &p_new->object_lock ); vlc_mutex_init( p_new, &p_new->object_lock );
vlc_cond_init( p_new, &p_new->object_wait ); vlc_cond_init( p_new, &p_new->object_wait );
vlc_mutex_init( p_new, &p_new->var_lock ); vlc_mutex_init( p_new, &p_priv->var_lock );
if( i_type == VLC_OBJECT_GLOBAL ) if( i_type == VLC_OBJECT_GLOBAL )
{ {
...@@ -390,13 +388,13 @@ void __vlc_object_destroy( vlc_object_t *p_this ) ...@@ -390,13 +388,13 @@ void __vlc_object_destroy( vlc_object_t *p_this )
/* Destroy the associated variables, starting from the end so that /* Destroy the associated variables, starting from the end so that
* no memmove calls have to be done. */ * no memmove calls have to be done. */
while( p_this->i_vars ) while( p_priv->i_vars )
{ {
var_Destroy( p_this, p_this->p_vars[p_this->i_vars - 1].psz_name ); var_Destroy( p_this, p_priv->p_vars[p_priv->i_vars - 1].psz_name );
} }
free( p_this->p_vars ); free( p_priv->p_vars );
vlc_mutex_destroy( &p_this->var_lock ); vlc_mutex_destroy( &p_priv->var_lock );
if( p_this->psz_header ) free( p_this->psz_header ); if( p_this->psz_header ) free( p_this->psz_header );
...@@ -877,11 +875,11 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd, ...@@ -877,11 +875,11 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
PrintObject( p_object, "" ); PrintObject( p_object, "" );
if( !p_object->i_vars ) if( !p_object->p_internals->i_vars )
printf( " `-o No variables\n" ); printf( " `-o No variables\n" );
for( i = 0; i < p_object->i_vars; i++ ) for( i = 0; i < p_object->p_internals->i_vars; i++ )
{ {
variable_t *p_var = p_object->p_vars + i; variable_t *p_var = p_object->p_internals->p_vars + i;
const char *psz_type = "unknown"; const char *psz_type = "unknown";
switch( p_var->i_type & VLC_VAR_TYPE ) switch( p_var->i_type & VLC_VAR_TYPE )
...@@ -907,7 +905,7 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd, ...@@ -907,7 +905,7 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
#undef MYCASE #undef MYCASE
} }
printf( " %c-o \"%s\" (%s", printf( " %c-o \"%s\" (%s",
i + 1 == p_object->i_vars ? '`' : '|', i + 1 == p_object->p_internals->i_vars ? '`' : '|',
p_var->psz_name, psz_type ); p_var->psz_name, psz_type );
if( p_var->psz_text ) if( p_var->psz_text )
printf( ", %s", p_var->psz_text ); printf( ", %s", p_var->psz_text );
......
...@@ -157,46 +157,47 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) ...@@ -157,46 +157,47 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
int i_new; int i_new;
variable_t *p_var; variable_t *p_var;
static vlc_list_t dummy_null_list = {0, NULL, NULL}; static vlc_list_t dummy_null_list = {0, NULL, NULL};
vlc_object_internals_t *p_priv = p_this->p_internals;
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
/* FIXME: if the variable already exists, we don't duplicate it. But we /* FIXME: if the variable already exists, we don't duplicate it. But we
* duplicate the lookups. It's not that serious, but if anyone finds some * duplicate the lookups. It's not that serious, but if anyone finds some
* time to rework Insert() so that only one lookup has to be done, feel * time to rework Insert() so that only one lookup has to be done, feel
* free to do so. */ * free to do so. */
i_new = Lookup( p_this->p_vars, p_this->i_vars, psz_name ); i_new = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
if( i_new >= 0 ) if( i_new >= 0 )
{ {
/* If the types differ, variable creation failed. */ /* If the types differ, variable creation failed. */
if( (i_type & ~(VLC_VAR_DOINHERIT|VLC_VAR_ISCOMMAND)) != p_this->p_vars[i_new].i_type ) if( (i_type & ~(VLC_VAR_DOINHERIT|VLC_VAR_ISCOMMAND)) != p_priv->p_vars[i_new].i_type )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_EBADVAR; return VLC_EBADVAR;
} }
p_this->p_vars[i_new].i_usage++; p_priv->p_vars[i_new].i_usage++;
if( i_type & VLC_VAR_ISCOMMAND ) if( i_type & VLC_VAR_ISCOMMAND )
p_this->p_vars[i_new].i_type |= VLC_VAR_ISCOMMAND; p_priv->p_vars[i_new].i_type |= VLC_VAR_ISCOMMAND;
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
i_new = Insert( p_this->p_vars, p_this->i_vars, psz_name ); i_new = Insert( p_priv->p_vars, p_priv->i_vars, psz_name );
if( (p_this->i_vars & 15) == 15 ) if( (p_priv->i_vars & 15) == 15 )
{ {
p_this->p_vars = realloc( p_this->p_vars, p_priv->p_vars = realloc( p_priv->p_vars,
(p_this->i_vars+17) * sizeof(variable_t) ); (p_priv->i_vars+17) * sizeof(variable_t) );
} }
memmove( p_this->p_vars + i_new + 1, memmove( p_priv->p_vars + i_new + 1,
p_this->p_vars + i_new, p_priv->p_vars + i_new,
(p_this->i_vars - i_new) * sizeof(variable_t) ); (p_priv->i_vars - i_new) * sizeof(variable_t) );
p_this->i_vars++; p_priv->i_vars++;
p_var = &p_this->p_vars[i_new]; p_var = &p_priv->p_vars[i_new];
memset( p_var, 0, sizeof(*p_var) ); memset( p_var, 0, sizeof(*p_var) );
p_var->i_hash = HashString( psz_name ); p_var->i_hash = HashString( psz_name );
...@@ -301,7 +302,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) ...@@ -301,7 +302,7 @@ int __var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
} }
} }
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -319,22 +320,23 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name ) ...@@ -319,22 +320,23 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
{ {
int i_var, i; int i_var, i;
variable_t *p_var; variable_t *p_var;
vlc_object_internals_t *p_priv = p_this->p_internals;
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = GetUnused( p_this, psz_name ); i_var = GetUnused( p_this, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return i_var; return i_var;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
if( p_var->i_usage > 1 ) if( p_var->i_usage > 1 )
{ {
p_var->i_usage--; p_var->i_usage--;
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -363,19 +365,19 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name ) ...@@ -363,19 +365,19 @@ int __var_Destroy( vlc_object_t *p_this, const char *psz_name )
free( p_var->psz_name ); free( p_var->psz_name );
if( p_var->psz_text ) free( p_var->psz_text ); if( p_var->psz_text ) free( p_var->psz_text );
memmove( p_this->p_vars + i_var, memmove( p_priv->p_vars + i_var,
p_this->p_vars + i_var + 1, p_priv->p_vars + i_var + 1,
(p_this->i_vars - i_var - 1) * sizeof(variable_t) ); (p_priv->i_vars - i_var - 1) * sizeof(variable_t) );
if( (p_this->i_vars & 15) == 0 ) if( (p_priv->i_vars & 15) == 0 )
{ {
p_this->p_vars = realloc( p_this->p_vars, p_priv->p_vars = realloc( p_priv->p_vars,
(p_this->i_vars) * sizeof( variable_t ) ); (p_priv->i_vars) * sizeof( variable_t ) );
} }
p_this->i_vars--; p_priv->i_vars--;
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -395,18 +397,19 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, ...@@ -395,18 +397,19 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
int i_var, i; int i_var, i;
variable_t *p_var; variable_t *p_var;
vlc_value_t oldval; vlc_value_t oldval;
vlc_object_internals_t *p_priv = p_this->p_internals;
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name ); i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_ENOVAR; return VLC_ENOVAR;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
switch( i_action ) switch( i_action )
{ {
...@@ -482,7 +485,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, ...@@ -482,7 +485,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
if( i == p_var->choices.i_count ) if( i == p_var->choices.i_count )
{ {
/* Not found */ /* Not found */
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -655,7 +658,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, ...@@ -655,7 +658,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
callback_entry_t *p_entries = p_var->p_entries; callback_entry_t *p_entries = p_var->p_entries;
p_var->b_incallback = VLC_TRUE; p_var->b_incallback = VLC_TRUE;
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
/* The real calls */ /* The real calls */
for( ; i_entries-- ; ) for( ; i_entries-- ; )
...@@ -664,17 +667,17 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, ...@@ -664,17 +667,17 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
p_entries[i_entries].p_data ); p_entries[i_entries].p_data );
} }
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name ); i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
msg_Err( p_this, "variable %s has disappeared", psz_name ); msg_Err( p_this, "variable %s has disappeared", psz_name );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_ENOVAR; return VLC_ENOVAR;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
p_var->b_incallback = VLC_FALSE; p_var->b_incallback = VLC_FALSE;
} }
} }
...@@ -684,7 +687,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, ...@@ -684,7 +687,7 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
break; break;
} }
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -699,20 +702,21 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name, ...@@ -699,20 +702,21 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
int __var_Type( vlc_object_t *p_this, const char *psz_name ) int __var_Type( vlc_object_t *p_this, const char *psz_name )
{ {
int i_var, i_type; int i_var, i_type;
vlc_object_internals_t *p_priv = p_this->p_internals;
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name ); i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return 0; return 0;
} }
i_type = p_this->p_vars[i_var].i_type; i_type = p_priv->p_vars[i_var].i_type;
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return i_type; return i_type;
} }
...@@ -729,17 +733,18 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val ) ...@@ -729,17 +733,18 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
int i_var; int i_var;
variable_t *p_var; variable_t *p_var;
vlc_value_t oldval; vlc_value_t oldval;
vlc_object_internals_t *p_priv = p_this->p_internals;
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = GetUnused( p_this, psz_name ); i_var = GetUnused( p_this, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return i_var; return i_var;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
/* Duplicate data if needed */ /* Duplicate data if needed */
p_var->pf_dup( &val ); p_var->pf_dup( &val );
...@@ -762,7 +767,7 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val ) ...@@ -762,7 +767,7 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
callback_entry_t *p_entries = p_var->p_entries; callback_entry_t *p_entries = p_var->p_entries;
p_var->b_incallback = VLC_TRUE; p_var->b_incallback = VLC_TRUE;
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
/* The real calls */ /* The real calls */
for( ; i_entries-- ; ) for( ; i_entries-- ; )
...@@ -771,24 +776,24 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val ) ...@@ -771,24 +776,24 @@ int __var_Set( vlc_object_t *p_this, const char *psz_name, vlc_value_t val )
p_entries[i_entries].p_data ); p_entries[i_entries].p_data );
} }
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name ); i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
msg_Err( p_this, "variable %s has disappeared", psz_name ); msg_Err( p_this, "variable %s has disappeared", psz_name );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_ENOVAR; return VLC_ENOVAR;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
p_var->b_incallback = VLC_FALSE; p_var->b_incallback = VLC_FALSE;
} }
/* Free data if needed */ /* Free data if needed */
p_var->pf_free( &oldval ); p_var->pf_free( &oldval );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -805,18 +810,19 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val ) ...@@ -805,18 +810,19 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
{ {
int i_var; int i_var;
variable_t *p_var; variable_t *p_var;
vlc_object_internals_t *p_priv = p_this->p_internals;
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name ); i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_ENOVAR; return VLC_ENOVAR;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
/* Really get the variable */ /* Really get the variable */
*p_val = p_var->val; *p_val = p_var->val;
...@@ -824,7 +830,7 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val ) ...@@ -824,7 +830,7 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
/* Duplicate value if needed */ /* Duplicate value if needed */
p_var->pf_dup( p_val ); p_var->pf_dup( p_val );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -868,27 +874,28 @@ int __var_AddCallback( vlc_object_t *p_this, const char *psz_name, ...@@ -868,27 +874,28 @@ int __var_AddCallback( vlc_object_t *p_this, const char *psz_name,
int i_var; int i_var;
variable_t *p_var; variable_t *p_var;
callback_entry_t entry; callback_entry_t entry;
vlc_object_internals_t *p_priv = p_this->p_internals;
entry.pf_callback = pf_callback; entry.pf_callback = pf_callback;
entry.p_data = p_data; entry.p_data = p_data;
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = GetUnused( p_this, psz_name ); i_var = GetUnused( p_this, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return i_var; return i_var;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
INSERT_ELEM( p_var->p_entries, INSERT_ELEM( p_var->p_entries,
p_var->i_entries, p_var->i_entries,
p_var->i_entries, p_var->i_entries,
entry ); entry );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -904,17 +911,18 @@ int __var_DelCallback( vlc_object_t *p_this, const char *psz_name, ...@@ -904,17 +911,18 @@ int __var_DelCallback( vlc_object_t *p_this, const char *psz_name,
{ {
int i_entry, i_var; int i_entry, i_var;
variable_t *p_var; variable_t *p_var;
vlc_object_internals_t *p_priv = p_this->p_internals;
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = GetUnused( p_this, psz_name ); i_var = GetUnused( p_this, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return i_var; return i_var;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
for( i_entry = p_var->i_entries ; i_entry-- ; ) for( i_entry = p_var->i_entries ; i_entry-- ; )
{ {
...@@ -927,13 +935,13 @@ int __var_DelCallback( vlc_object_t *p_this, const char *psz_name, ...@@ -927,13 +935,13 @@ int __var_DelCallback( vlc_object_t *p_this, const char *psz_name,
if( i_entry < 0 ) if( i_entry < 0 )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
REMOVE_ELEM( p_var->p_entries, p_var->i_entries, i_entry ); REMOVE_ELEM( p_var->p_entries, p_var->i_entries, i_entry );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -949,17 +957,18 @@ int __var_TriggerCallback( vlc_object_t *p_this, const char *psz_name ) ...@@ -949,17 +957,18 @@ int __var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
int i_var; int i_var;
variable_t *p_var; variable_t *p_var;
vlc_value_t oldval; vlc_value_t oldval;
vlc_object_internals_t *p_priv = p_this->p_internals;
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = GetUnused( p_this, psz_name ); i_var = GetUnused( p_this, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return i_var; return i_var;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
/* Backup needed stuff */ /* Backup needed stuff */
oldval = p_var->val; oldval = p_var->val;
...@@ -973,7 +982,7 @@ int __var_TriggerCallback( vlc_object_t *p_this, const char *psz_name ) ...@@ -973,7 +982,7 @@ int __var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
callback_entry_t *p_entries = p_var->p_entries; callback_entry_t *p_entries = p_var->p_entries;
p_var->b_incallback = VLC_TRUE; p_var->b_incallback = VLC_TRUE;
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
/* The real calls */ /* The real calls */
for( ; i_entries-- ; ) for( ; i_entries-- ; )
...@@ -982,21 +991,21 @@ int __var_TriggerCallback( vlc_object_t *p_this, const char *psz_name ) ...@@ -982,21 +991,21 @@ int __var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
p_entries[i_entries].p_data ); p_entries[i_entries].p_data );
} }
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name ); i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
msg_Err( p_this, "variable %s has disappeared", psz_name ); msg_Err( p_this, "variable %s has disappeared", psz_name );
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_ENOVAR; return VLC_ENOVAR;
} }
p_var = &p_this->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
p_var->b_incallback = VLC_FALSE; p_var->b_incallback = VLC_FALSE;
} }
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -1141,16 +1150,17 @@ void __var_OptionParse( vlc_object_t *p_obj, const char *psz_option ) ...@@ -1141,16 +1150,17 @@ void __var_OptionParse( vlc_object_t *p_obj, const char *psz_option )
static int GetUnused( vlc_object_t *p_this, const char *psz_name ) static int GetUnused( vlc_object_t *p_this, const char *psz_name )
{ {
int i_var, i_tries = 0; int i_var, i_tries = 0;
vlc_object_internals_t *p_priv = p_this->p_internals;
while( VLC_TRUE ) while( VLC_TRUE )
{ {
i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name ); i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
if( i_var < 0 ) if( i_var < 0 )
{ {
return VLC_ENOVAR; return VLC_ENOVAR;
} }
if( ! p_this->p_vars[i_var].b_incallback ) if( ! p_priv->p_vars[i_var].b_incallback )
{ {
return i_var; return i_var;
} }
...@@ -1161,9 +1171,9 @@ static int GetUnused( vlc_object_t *p_this, const char *psz_name ) ...@@ -1161,9 +1171,9 @@ static int GetUnused( vlc_object_t *p_this, const char *psz_name )
return VLC_ETIMEOUT; return VLC_ETIMEOUT;
} }
vlc_mutex_unlock( &p_this->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
msleep( THREAD_SLEEP ); msleep( THREAD_SLEEP );
vlc_mutex_lock( &p_this->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
} }
} }
...@@ -1481,16 +1491,17 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name, ...@@ -1481,16 +1491,17 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
vlc_object_internals_t *p_priv = p_this->p_parent->p_internals;
/* Look for the variable */ /* Look for the variable */
vlc_mutex_lock( &p_this->p_parent->var_lock ); vlc_mutex_lock( &p_priv->var_lock );
i_var = Lookup( p_this->p_parent->p_vars, p_this->p_parent->i_vars, i_var = Lookup( p_priv->p_vars, p_priv->i_vars, psz_name );
psz_name );
if( i_var >= 0 ) if( i_var >= 0 )
{ {
/* We found it! */ /* We found it! */
p_var = &p_this->p_parent->p_vars[i_var]; p_var = &p_priv->p_vars[i_var];
/* Really get the variable */ /* Really get the variable */
*p_val = p_var->val; *p_val = p_var->val;
...@@ -1498,11 +1509,11 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name, ...@@ -1498,11 +1509,11 @@ static int InheritValue( vlc_object_t *p_this, const char *psz_name,
/* Duplicate value if needed */ /* Duplicate value if needed */
p_var->pf_dup( p_val ); p_var->pf_dup( p_val );
vlc_mutex_unlock( &p_this->p_parent->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
vlc_mutex_unlock( &p_this->p_parent->var_lock ); vlc_mutex_unlock( &p_priv->var_lock );
/* We're still not there */ /* We're still not there */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment