Commit 1114ee5a authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* include/variables.h

  src/misc/variables.c: Added a VLC_VAR_TRIGGER_CALLBACKS action
* src/libvlc.c: You can now change verbosity on the fly by using the "verbose"
  variable of p_vlc. -1 == quiet
parent 528a21a0
......@@ -2,7 +2,7 @@
* variables.h: variables handling
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: variables.h,v 1.19 2003/12/02 12:57:35 gbazin Exp $
* $Id: variables.h,v 1.20 2004/01/09 20:36:21 hartman Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -137,36 +137,37 @@ struct variable_t
* \param p_val The new minimum value
* \param p_val2 Unused
*/
#define VLC_VAR_SETMIN 0x0010
#define VLC_VAR_SETMIN 0x0010
/**
* Set the maximum value of this variable
* \param p_val The new maximum value
* \param p_val2 Unused
*/
#define VLC_VAR_SETMAX 0x0011
#define VLC_VAR_SETSTEP 0x0012
#define VLC_VAR_SETMAX 0x0011
#define VLC_VAR_SETSTEP 0x0012
/**
* Set the value of this variable without triggering any callbacks
* \param p_val The new value
* \param p_val2 Unused
*/
#define VLC_VAR_SETVALUE 0x0013
#define VLC_VAR_SETTEXT 0x0014
#define VLC_VAR_GETTEXT 0x0015
#define VLC_VAR_ADDCHOICE 0x0020
#define VLC_VAR_DELCHOICE 0x0021
#define VLC_VAR_CLEARCHOICES 0x0022
#define VLC_VAR_SETDEFAULT 0x0023
#define VLC_VAR_GETCHOICES 0x0024
#define VLC_VAR_FREECHOICES 0x0025
#define VLC_VAR_GETLIST 0x0026
#define VLC_VAR_FREELIST 0x0027
#define VLC_VAR_CHOICESCOUNT 0x0028
#define VLC_VAR_INHERITVALUE 0x0030
#define VLC_VAR_SETVALUE 0x0013
#define VLC_VAR_SETTEXT 0x0014
#define VLC_VAR_GETTEXT 0x0015
#define VLC_VAR_ADDCHOICE 0x0020
#define VLC_VAR_DELCHOICE 0x0021
#define VLC_VAR_CLEARCHOICES 0x0022
#define VLC_VAR_SETDEFAULT 0x0023
#define VLC_VAR_GETCHOICES 0x0024
#define VLC_VAR_FREECHOICES 0x0025
#define VLC_VAR_GETLIST 0x0026
#define VLC_VAR_FREELIST 0x0027
#define VLC_VAR_CHOICESCOUNT 0x0028
#define VLC_VAR_INHERITVALUE 0x0030
#define VLC_VAR_TRIGGER_CALLBACKS 0x0035
/**@}*/
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2004 VideoLAN
* $Id: libvlc.c,v 1.109 2004/01/06 12:02:05 zorglub Exp $
* $Id: libvlc.c,v 1.110 2004/01/09 20:36:21 hartman Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -99,6 +99,8 @@ static void ShowConsole ( void );
#endif
static int ConsoleWidth ( void );
static int VerboseCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* vlc_current_object: return the current object.
......@@ -497,18 +499,17 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
/*
* Message queue options
*/
var_Create( p_vlc, "verbose", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
if( config_GetInt( p_vlc, "quiet" ) )
{
libvlc.i_verbose = -1;
}
else
{
int i_tmp = config_GetInt( p_vlc, "verbose" );
if( i_tmp >= 0 )
{
libvlc.i_verbose = __MIN( i_tmp, 2 );
}
vlc_value_t val;
val.i_int = -1;
var_Set( p_vlc, "verbose", val );
}
var_AddCallback( p_vlc, "verbose", VerboseCallback, NULL );
var_Change( p_vlc, "verbose", VLC_VAR_TRIGGER_CALLBACKS, NULL, NULL );
libvlc.b_color = libvlc.b_color && config_GetInt( p_vlc, "color" );
/*
......@@ -1630,3 +1631,15 @@ static int ConsoleWidth( void )
return i_width;
}
static int VerboseCallback( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val, void *param)
{
vlc_t *p_vlc = (vlc_t *)p_this;
if( new_val.i_int >= -1 )
{
p_vlc->p_libvlc->i_verbose = __MIN( new_val.i_int, 2 );
}
return VLC_SUCCESS;
}
......@@ -2,7 +2,7 @@
* variables.c: routines for object variables handling
*****************************************************************************
* Copyright (C) 2002-2004 VideoLAN
* $Id: variables.c,v 1.35 2004/01/06 12:02:06 zorglub Exp $
* $Id: variables.c,v 1.36 2004/01/09 20:36:21 hartman Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -614,6 +614,41 @@ int __var_Change( vlc_object_t *p_this, const char *psz_name,
}
}
break;
case VLC_VAR_TRIGGER_CALLBACKS:
{
/* Deal with callbacks. Tell we're in a callback, release the lock,
* call stored functions, retake the lock. */
if( p_var->i_entries )
{
int i_var;
int i_entries = p_var->i_entries;
callback_entry_t *p_entries = p_var->p_entries;
p_var->b_incallback = VLC_TRUE;
vlc_mutex_unlock( &p_this->var_lock );
/* The real calls */
for( ; i_entries-- ; )
{
p_entries[i_entries].pf_callback( p_this, psz_name, p_var->val, p_var->val,
p_entries[i_entries].p_data );
}
vlc_mutex_lock( &p_this->var_lock );
i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name );
if( i_var < 0 )
{
msg_Err( p_this, "variable %s has disappeared", psz_name );
vlc_mutex_unlock( &p_this->var_lock );
return VLC_ENOVAR;
}
p_var = &p_this->p_vars[i_var];
p_var->b_incallback = VLC_FALSE;
}
}
break;
default:
break;
......
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