Changeset 1114ee5a01e78e259b916dc3e723b81a9347f38e

Show
Ignore:
Timestamp:
09/01/04 21:36:21 (5 years ago)
Author:
Derk-Jan Hartman <hartman@videolan.org>
git-committer:
Derk-Jan Hartman <hartman@videolan.org> 1073680581 +0000
git-parent:

[528a21a0e848b2054077505834b01e89bce2678c]

git-author:
Derk-Jan Hartman <hartman@videolan.org> 1073680581 +0000
Message:

* 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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/variables.h

    r97d84d1 r1114ee5  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: variables.h,v 1.19 2003/12/02 12:57:35 gbazin Exp $ 
     5 * $Id: variables.h,v 1.20 2004/01/09 20:36:21 hartman Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    138138 * \param p_val2 Unused 
    139139 */ 
    140 #define VLC_VAR_SETMIN        0x0010 
     140#define VLC_VAR_SETMIN              0x0010 
    141141/** 
    142142 * Set the maximum value of this variable 
     
    144144 * \param p_val2 Unused 
    145145 */ 
    146 #define VLC_VAR_SETMAX        0x0011 
    147 #define VLC_VAR_SETSTEP       0x0012 
     146#define VLC_VAR_SETMAX              0x0011 
     147#define VLC_VAR_SETSTEP             0x0012 
    148148 
    149149/** 
     
    152152 * \param p_val2 Unused 
    153153 */ 
    154 #define VLC_VAR_SETVALUE      0x0013 
    155  
    156 #define VLC_VAR_SETTEXT       0x0014 
    157 #define VLC_VAR_GETTEXT       0x0015 
    158  
    159 #define VLC_VAR_ADDCHOICE     0x0020 
    160 #define VLC_VAR_DELCHOICE     0x0021 
    161 #define VLC_VAR_CLEARCHOICES  0x0022 
    162 #define VLC_VAR_SETDEFAULT    0x0023 
    163 #define VLC_VAR_GETCHOICES    0x0024 
    164 #define VLC_VAR_FREECHOICES   0x0025 
    165 #define VLC_VAR_GETLIST       0x0026 
    166 #define VLC_VAR_FREELIST      0x0027 
    167 #define VLC_VAR_CHOICESCOUNT  0x0028 
    168  
    169 #define VLC_VAR_INHERITVALUE  0x0030 
     154#define VLC_VAR_SETVALUE            0x0013 
     155 
     156#define VLC_VAR_SETTEXT             0x0014 
     157#define VLC_VAR_GETTEXT             0x0015 
     158 
     159#define VLC_VAR_ADDCHOICE           0x0020 
     160#define VLC_VAR_DELCHOICE           0x0021 
     161#define VLC_VAR_CLEARCHOICES        0x0022 
     162#define VLC_VAR_SETDEFAULT          0x0023 
     163#define VLC_VAR_GETCHOICES          0x0024 
     164#define VLC_VAR_FREECHOICES         0x0025 
     165#define VLC_VAR_GETLIST             0x0026 
     166#define VLC_VAR_FREELIST            0x0027 
     167#define VLC_VAR_CHOICESCOUNT        0x0028 
     168 
     169#define VLC_VAR_INHERITVALUE        0x0030 
     170#define VLC_VAR_TRIGGER_CALLBACKS   0x0035 
    170171/**@}*/ 
    171172 
  • src/libvlc.c

    r25cd132 r1114ee5  
    33 ***************************************************************************** 
    44 * Copyright (C) 1998-2004 VideoLAN 
    5  * $Id: libvlc.c,v 1.109 2004/01/06 12:02:05 zorglub Exp $ 
     5 * $Id: libvlc.c,v 1.110 2004/01/09 20:36:21 hartman Exp $ 
    66 * 
    77 * Authors: Vincent Seguin <seguin@via.ecp.fr> 
     
    100100static int  ConsoleWidth  ( void ); 
    101101 
     102static int  VerboseCallback( vlc_object_t *, char const *, 
     103                             vlc_value_t, vlc_value_t, void * ); 
    102104 
    103105/***************************************************************************** 
     
    498500     * Message queue options 
    499501     */ 
     502 
     503    var_Create( p_vlc, "verbose", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 
    500504    if( config_GetInt( p_vlc, "quiet" ) ) 
    501505    { 
    502         libvlc.i_verbose = -1; 
    503     } 
    504     else 
    505     { 
    506         int i_tmp = config_GetInt( p_vlc, "verbose" ); 
    507         if( i_tmp >= 0 ) 
    508         { 
    509             libvlc.i_verbose = __MIN( i_tmp, 2 ); 
    510         } 
    511     } 
     506        vlc_value_t val; 
     507        val.i_int = -1; 
     508        var_Set( p_vlc, "verbose", val ); 
     509    } 
     510    var_AddCallback( p_vlc, "verbose", VerboseCallback, NULL ); 
     511    var_Change( p_vlc, "verbose", VLC_VAR_TRIGGER_CALLBACKS, NULL, NULL ); 
     512     
    512513    libvlc.b_color = libvlc.b_color && config_GetInt( p_vlc, "color" ); 
    513514 
     
    16311632    return i_width; 
    16321633} 
     1634 
     1635static int VerboseCallback( vlc_object_t *p_this, const char *psz_variable, 
     1636                     vlc_value_t old_val, vlc_value_t new_val, void *param) 
     1637{ 
     1638    vlc_t *p_vlc = (vlc_t *)p_this; 
     1639 
     1640    if( new_val.i_int >= -1 ) 
     1641    { 
     1642        p_vlc->p_libvlc->i_verbose = __MIN( new_val.i_int, 2 ); 
     1643    } 
     1644    return VLC_SUCCESS; 
     1645} 
  • src/misc/variables.c

    r25cd132 r1114ee5  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002-2004 VideoLAN 
    5  * $Id: variables.c,v 1.35 2004/01/06 12:02:06 zorglub Exp $ 
     5 * $Id: variables.c,v 1.36 2004/01/09 20:36:21 hartman Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    615615            } 
    616616            break; 
     617        case VLC_VAR_TRIGGER_CALLBACKS: 
     618            { 
     619                /* Deal with callbacks. Tell we're in a callback, release the lock, 
     620                 * call stored functions, retake the lock. */ 
     621                if( p_var->i_entries ) 
     622                { 
     623                    int i_var; 
     624                    int i_entries = p_var->i_entries; 
     625                    callback_entry_t *p_entries = p_var->p_entries; 
     626 
     627                    p_var->b_incallback = VLC_TRUE; 
     628                    vlc_mutex_unlock( &p_this->var_lock ); 
     629 
     630                    /* The real calls */ 
     631                    for( ; i_entries-- ; ) 
     632                    { 
     633                        p_entries[i_entries].pf_callback( p_this, psz_name, p_var->val, p_var->val, 
     634                                                          p_entries[i_entries].p_data ); 
     635                    } 
     636 
     637                    vlc_mutex_lock( &p_this->var_lock ); 
     638 
     639                    i_var = Lookup( p_this->p_vars, p_this->i_vars, psz_name ); 
     640                    if( i_var < 0 ) 
     641                    { 
     642                        msg_Err( p_this, "variable %s has disappeared", psz_name ); 
     643                        vlc_mutex_unlock( &p_this->var_lock ); 
     644                        return VLC_ENOVAR; 
     645                    } 
     646 
     647                    p_var = &p_this->p_vars[i_var]; 
     648                    p_var->b_incallback = VLC_FALSE; 
     649                } 
     650            } 
     651            break; 
    617652 
    618653        default: