Commit 2850821a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

variables: voidify var_TriggerCallback()

The function can only fail if the named variable does not exist. The
only case where the error was actually checked was after another check
that the variable exists (Old RC).
parent 43a771c1
......@@ -173,7 +173,7 @@ VLC_API void var_FreeList( vlc_value_t *, vlc_value_t * );
*****************************************************************************/
VLC_API int var_AddCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
VLC_API int var_DelCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
VLC_API int var_TriggerCallback( vlc_object_t *, const char * );
VLC_API void var_TriggerCallback( vlc_object_t *, const char * );
VLC_API int var_AddListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * );
VLC_API int var_DelListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * );
......
......@@ -605,10 +605,10 @@ static void *Run( void *data )
/* If the user typed a registered local command, try it */
if( var_Type( p_intf, psz_cmd ) & VLC_VAR_ISCOMMAND )
{
int i_ret;
int i_ret = VLC_SUCCESS;
if ((var_Type( p_intf, psz_cmd) & VLC_VAR_CLASS) == VLC_VAR_VOID)
i_ret = var_TriggerCallback( p_intf, psz_cmd );
var_TriggerCallback( p_intf, psz_cmd );
else
i_ret = var_SetString( p_intf, psz_cmd, psz_arg );
msg_rc( "%s: returned %i (%s)",
......@@ -617,12 +617,12 @@ static void *Run( void *data )
/* Or maybe it's a global command */
else if( var_Type( p_intf->p_libvlc, psz_cmd ) & VLC_VAR_ISCOMMAND )
{
int i_ret;
int i_ret = VLC_SUCCESS;
/* FIXME: it's a global command, but we should pass the
* local object as an argument, not p_intf->p_libvlc. */
if ((var_Type( p_intf->p_libvlc, psz_cmd) & VLC_VAR_CLASS) == VLC_VAR_VOID)
i_ret = var_TriggerCallback( p_intf, psz_cmd );
var_TriggerCallback( p_intf, psz_cmd );
else
i_ret = var_SetString( p_intf->p_libvlc, psz_cmd, psz_arg );
if( i_ret != 0 )
......
......@@ -286,7 +286,8 @@ static int vlclua_trigger_callback( lua_State *L )
vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
const char *psz_var = luaL_checkstring( L, 2 );
return vlclua_push_ret( L, var_TriggerCallback( *pp_obj, psz_var ) );
var_TriggerCallback( *pp_obj, psz_var );
return vlclua_push_ret( L, 0 );
}
static int vlclua_inc_integer( lua_State *L )
......
......@@ -1038,29 +1038,19 @@ int var_DelCallback( vlc_object_t *p_this, const char *psz_name,
* \param p_this The object that hold the variable
* \param psz_name The name of the variable
*/
int var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
void var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
{
variable_t *p_var;
assert( p_this );
vlc_object_internals_t *p_priv = vlc_internals( p_this );
p_var = Lookup( p_this, psz_name );
if( p_var == NULL )
variable_t *p_var = Lookup( p_this, psz_name );
if( p_var != NULL )
{
vlc_mutex_unlock( &p_priv->var_lock );
return VLC_ENOVAR;
}
WaitUnused( p_this, p_var );
/* Deal with callbacks. Tell we're in a callback, release the lock,
* call stored functions, retake the lock. */
TriggerCallback( p_this, p_var, psz_name, p_var->val );
WaitUnused( p_this, p_var );
/* Deal with callbacks. Tell we're in a callback, release the lock,
* call stored functions, retake the lock. */
TriggerCallback( p_this, p_var, psz_name, p_var->val );
}
vlc_mutex_unlock( &p_priv->var_lock );
return VLC_SUCCESS;
}
#undef var_AddListCallback
......
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