Changeset 4684a91eafdc7a56414208681294ecccaac9b83c

Show
Ignore:
Timestamp:
24/07/03 00:01:25 (5 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1058997685 +0000
git-parent:

[5b165b7369efb2c31466e0ed0a120ef16a838cc6]

git-author:
Gildas Bazin <gbazin@videolan.org> 1058997685 +0000
Message:

* include/variables.h, src/misc/variables.c: you can now use var_Create() directly to create an object variable with an inherited value.

eg. var_Create( p_vout, "zoom", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
Beware, the object in which you create the var must be attached to a parent for this to work (otherwise we can't navigate the parents hierarchy to find the value to inherit).

* src/input/input.c, src/input/input_programs.c, src/video_output/video_output.c: converted more config_GetFoo() into var_Create()/var_Get();

Files:

Legend:

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

    r66815e2 r4684a91  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: variables.h,v 1.14 2003/05/24 23:40:11 gbazin Exp $ 
     5 * $Id: variables.h,v 1.15 2003/07/23 22:01:25 gbazin Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    9797#define VLC_VAR_ISCONFIG  0x2000 
    9898 
     99/* Creation flag */ 
     100#define VLC_VAR_DOINHERIT 0x8000 
     101 
    99102/***************************************************************************** 
    100103 * Variable actions 
  • src/input/input.c

    reb505a2 r4684a91  
    55 ***************************************************************************** 
    66 * Copyright (C) 1998-2002 VideoLAN 
    7  * $Id: input.c,v 1.234 2003/07/23 01:13:48 gbazin Exp $ 
     7 * $Id: input.c,v 1.235 2003/07/23 22:01:25 gbazin Exp $ 
    88 * 
    99 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    8787    } 
    8888 
    89     /* Create a few object variables we'll need later */ 
    90     if( !var_Type( p_input, "sout" ) ) 
    91     { 
    92         var_Create( p_input, "sout", VLC_VAR_STRING ); 
    93         var_Change( p_input, "sout", VLC_VAR_INHERITVALUE, NULL, NULL ); 
    94     } 
    95     if( !var_Type( p_input, "sout-audio" ) ) 
    96     { 
    97         var_Create( p_input, "sout-audio", VLC_VAR_BOOL ); 
    98         var_Change( p_input, "sout-audio", VLC_VAR_INHERITVALUE, NULL, NULL ); 
    99     } 
    100     if( !var_Type( p_input, "sout-video" ) ) 
    101     { 
    102         var_Create( p_input, "sout-video", VLC_VAR_BOOL ); 
    103         var_Change( p_input, "sout-video", VLC_VAR_INHERITVALUE, NULL, NULL ); 
    104     } 
     89    /* Create a few object variables we'll need later on */ 
     90    var_Create( p_input, "video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
     91    var_Create( p_input, "audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
     92    var_Create( p_input, "audio-channel", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); 
     93    var_Create( p_input, "spu-channel", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); 
     94 
     95    var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); 
     96    var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
     97    var_Create( p_input, "sout-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
    10598 
    10699    /* Initialize thread properties */ 
     
    548541    /* Initialize optional stream output. */ 
    549542    var_Get( p_input, "sout", &val ); 
    550     if ( val.psz_string != NULL ) 
     543    if( val.psz_string != NULL ) 
    551544    { 
    552545        if ( *val.psz_string && (p_input->stream.p_sout = 
  • src/input/input_programs.c

    r3f65460 r4684a91  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2002 VideoLAN 
    5  * $Id: input_programs.c,v 1.114 2003/05/18 23:16:57 fenrir Exp $ 
     5 * $Id: input_programs.c,v 1.115 2003/07/23 22:01:25 gbazin Exp $ 
    66 * 
    77 * Authors: Christophe Massiot <massiot@via.ecp.fr> 
     
    428428        } 
    429429    } 
     430 
    430431    /* Get the number of the required audio stream */ 
    431     if( config_GetInt( p_input, "audio" ) ) 
     432    var_Get( p_input, "audio", &val ); 
     433    if( val.b_bool ) 
    432434    { 
    433435        /* Default is the first one */ 
    434         i_required_audio_es = config_GetInt( p_input, "audio-channel" ); 
     436        var_Get( p_input, "audio-channel", &val ); 
     437        i_required_audio_es = val.i_int; 
    435438        if( i_required_audio_es < 0 ) 
    436439        { 
     
    444447 
    445448    /* Same thing for subtitles */ 
    446     if( config_GetInt( p_input, "video" ) ) 
     449    var_Get( p_input, "video", &val ); 
     450    if( val.b_bool ) 
    447451    { 
    448452        /* for spu, default is none */ 
    449         i_required_spu_es = config_GetInt( p_input, "spu-channel" ); 
     453        var_Get( p_input, "spu-channel", &val ); 
     454        i_required_spu_es = val.i_int; 
    450455        if( i_required_spu_es < 0 ) 
    451456        { 
     
    822827    } 
    823828 
    824     if( ((p_es->i_cat == VIDEO_ES) || (p_es->i_cat == SPU_ES)) 
    825         && !config_GetInt( p_input, "video" ) ) 
    826     { 
    827         msg_Dbg( p_input, 
    828                  "video is disabled, not selecting ES 0x%x", p_es->i_id ); 
    829         return -1; 
    830     } 
    831  
    832     if( (p_es->i_cat == AUDIO_ES) && !config_GetInt( p_input, "audio" ) ) 
    833     { 
    834         msg_Dbg( p_input, 
    835                  "audio is disabled, not selecting ES 0x%x", p_es->i_id ); 
    836         return -1; 
     829    if( p_es->i_cat == VIDEO_ES || p_es->i_cat == SPU_ES ) 
     830    { 
     831        var_Get( p_input, "video", &val ); 
     832        if( !val.b_bool ) 
     833        { 
     834            msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x", 
     835                     p_es->i_id ); 
     836            return -1; 
     837        } 
     838    } 
     839 
     840    if( p_es->i_cat == AUDIO_ES ) 
     841    { 
     842        var_Get( p_input, "audio", &val ); 
     843        if( !val.b_bool ) 
     844        { 
     845            msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x", 
     846                     p_es->i_id ); 
     847            return -1; 
     848        } 
    837849    } 
    838850 
  • src/misc/variables.c

    r9a825a7 r4684a91  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: variables.c,v 1.27 2003/07/22 15:59:06 gbazin Exp $ 
     5 * $Id: variables.c,v 1.28 2003/07/23 22:01:25 gbazin Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    160160    { 
    161161        /* If the types differ, variable creation failed. */ 
    162         if( i_type != p_this->p_vars[i_new].i_type ) 
     162        if( (i_type & ~VLC_VAR_DOINHERIT) != p_this->p_vars[i_new].i_type ) 
    163163        { 
    164164            vlc_mutex_unlock( &p_this->var_lock ); 
     
    191191    p_var->psz_text = NULL; 
    192192 
    193     p_var->i_type = i_type
     193    p_var->i_type = i_type & ~VLC_VAR_DOINHERIT
    194194    memset( &p_var->val, 0, sizeof(vlc_value_t) ); 
    195195 
     
    261261    /* Duplicate the default data we stored. */ 
    262262    p_var->pf_dup( &p_var->val ); 
     263 
     264    if( i_type & VLC_VAR_DOINHERIT ) 
     265    { 
     266        vlc_value_t val; 
     267 
     268        if( InheritValue( p_this, psz_name, &val, p_var->i_type ) 
     269            == VLC_SUCCESS ); 
     270        { 
     271            /* Free data if needed */ 
     272            p_var->pf_free( &p_var->val ); 
     273            /* Check boundaries and list */ 
     274            CheckValue( p_var, &val ); 
     275            /* Set the variable */ 
     276            p_var->val = val; 
     277        } 
     278    } 
    263279 
    264280    vlc_mutex_unlock( &p_this->var_lock ); 
     
    11431159 
    11441160        vlc_mutex_unlock( &p_this->p_parent->var_lock ); 
    1145  
    11461161        return VLC_SUCCESS; 
    11471162    } 
  • src/video_output/video_output.c

    r14b3f0c r4684a91  
    66 ***************************************************************************** 
    77 * Copyright (C) 2000-2001 VideoLAN 
    8  * $Id: video_output.c,v 1.229 2003/07/14 21:32:59 sigmunau Exp $ 
     8 * $Id: video_output.c,v 1.230 2003/07/23 22:01:25 gbazin Exp $ 
    99 * 
    1010 * Authors: Vincent Seguin <seguin@via.ecp.fr> 
     
    217217    } 
    218218 
    219     var_Create( p_vout, "intf-change", VLC_VAR_BOOL ); 
    220     val.b_bool = VLC_TRUE; 
    221     var_Set( p_vout, "intf-change", val ); 
    222  
    223     p_vout->b_override_aspect = VLC_FALSE; 
    224  
    225     /* If the parent is not a VOUT object, that means we are at the start of 
    226      * the video output pipe */ 
    227     if( p_parent->i_object_type != VLC_OBJECT_VOUT ) 
    228     { 
    229         char *psz_aspect = config_GetPsz( p_parent, "aspect-ratio" ); 
    230  
    231         /* Check whether the user tried to override aspect ratio */ 
    232         if( psz_aspect ) 
    233         { 
    234             unsigned int i_new_aspect = i_aspect; 
    235             char *psz_parser = strchr( psz_aspect, ':' ); 
    236  
    237             if( psz_parser ) 
    238             { 
    239                 *psz_parser++ = '\0'; 
    240                 i_new_aspect = atoi( psz_aspect ) * VOUT_ASPECT_FACTOR 
    241                                                   / atoi( psz_parser ); 
    242             } 
    243             else 
    244             { 
    245                 i_new_aspect = i_width * VOUT_ASPECT_FACTOR 
    246                                        * atof( psz_aspect ) 
    247                                        / i_height; 
    248             } 
    249  
    250             free( psz_aspect ); 
    251  
    252             if( i_new_aspect && i_new_aspect != i_aspect ) 
    253             { 
    254                 int i_pgcd = ReduceHeight( i_new_aspect ); 
    255  
    256                 msg_Dbg( p_vout, "overriding source aspect ratio to %i:%i", 
    257                          i_new_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd ); 
    258  
    259                 i_aspect = i_new_aspect; 
    260  
    261                 p_vout->b_override_aspect = VLC_TRUE; 
    262             } 
    263         } 
    264  
    265         /* Look for the default filter configuration */ 
    266         p_vout->psz_filter_chain = config_GetPsz( p_parent, "filter" ); 
    267     } 
    268     else 
    269     { 
    270         /* continue the parent's filter chain */ 
    271         char *psz_end; 
    272  
    273         psz_end = strchr( ((vout_thread_t *)p_parent)->psz_filter_chain, ':' ); 
    274         if( psz_end && *(psz_end+1) ) 
    275             p_vout->psz_filter_chain = strdup( psz_end+1 ); 
    276         else p_vout->psz_filter_chain = NULL; 
    277     } 
    278  
    279     /* Choose the video output module */ 
    280     if( !p_vout->psz_filter_chain || !*p_vout->psz_filter_chain ) 
    281     { 
    282         psz_plugin = config_GetPsz( p_parent, "vout" ); 
    283     } 
    284     else 
    285     { 
    286         /* the filter chain is a string list of filters separated by double 
    287          * colons */ 
    288         char *psz_end; 
    289  
    290         psz_end = strchr( p_vout->psz_filter_chain, ':' ); 
    291         if( psz_end ) 
    292             psz_plugin = strndup( p_vout->psz_filter_chain, 
    293                                   psz_end - p_vout->psz_filter_chain ); 
    294         else psz_plugin = strdup( p_vout->psz_filter_chain ); 
    295     } 
    296  
    297219    /* Initialize pictures and subpictures - translation tables and functions 
    298220     * will be initialized later in InitThread */ 
     
    359281    var_Create( p_vout, "key-pressed", VLC_VAR_STRING ); 
    360282 
     283    var_Create( p_vout, "intf-change", VLC_VAR_BOOL ); 
     284    val.b_bool = VLC_TRUE; 
     285    var_Set( p_vout, "intf-change", val ); 
     286 
     287    /* Initialize locks */ 
     288    vlc_mutex_init( p_vout, &p_vout->picture_lock ); 
     289    vlc_mutex_init( p_vout, &p_vout->subpicture_lock ); 
     290    vlc_mutex_init( p_vout, &p_vout->change_lock ); 
     291 
     292    /* Attach the new object now so we can use var inheritance below */ 
     293    vlc_object_attach( p_vout, p_parent ); 
     294 
     295    /* Create a few object variables we'll need later on */ 
     296    var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); 
     297    var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 
     298    var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 
     299    var_Create( p_vout, "zoom", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); 
     300 
     301    p_vout->b_override_aspect = VLC_FALSE; 
     302 
     303    /* If the parent is not a VOUT object, that means we are at the start of 
     304     * the video output pipe */ 
     305    if( p_parent->i_object_type != VLC_OBJECT_VOUT ) 
     306    { 
     307        var_Get( p_vout, "aspect-ratio", &val ); 
     308 
     309        /* Check whether the user tried to override aspect ratio */ 
     310        if( val.psz_string ) 
     311        { 
     312            unsigned int i_new_aspect = i_aspect; 
     313            char *psz_parser = strchr( val.psz_string, ':' ); 
     314 
     315            if( psz_parser ) 
     316            { 
     317                *psz_parser++ = '\0'; 
     318                i_new_aspect = atoi( val.psz_string ) * VOUT_ASPECT_FACTOR 
     319                                                      / atoi( psz_parser ); 
     320            } 
     321            else 
     322            { 
     323                i_new_aspect = i_width * VOUT_ASPECT_FACTOR 
     324                                       * atof( val.psz_string ) 
     325                                       / i_height; 
     326            } 
     327 
     328            free( val.psz_string ); 
     329 
     330            if( i_new_aspect && i_new_aspect != i_aspect ) 
     331            { 
     332                int i_pgcd = ReduceHeight( i_new_aspect ); 
     333 
     334                msg_Dbg( p_vout, "overriding source aspect ratio to %i:%i", 
     335                         i_new_aspect / i_pgcd, VOUT_ASPECT_FACTOR / i_pgcd ); 
     336 
     337                p_vout->render.i_aspect = i_new_aspect; 
     338 
     339                p_vout->b_override_aspect = VLC_TRUE; 
     340            } 
     341        } 
     342 
     343        /* Look for the default filter configuration */ 
     344        var_Create( p_vout, "filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); 
     345        var_Get( p_vout, "filter", &val ); 
     346        p_vout->psz_filter_chain = val.psz_string; 
     347    } 
     348    else 
     349    { 
     350        /* continue the parent's filter chain */ 
     351        char *psz_end; 
     352 
     353        psz_end = strchr( ((vout_thread_t *)p_parent)->psz_filter_chain, ':' ); 
     354        if( psz_end && *(psz_end+1) ) 
     355            p_vout->psz_filter_chain = strdup( psz_end+1 ); 
     356        else p_vout->psz_filter_chain = NULL; 
     357    } 
     358 
     359    /* Choose the video output module */ 
     360    if( !p_vout->psz_filter_chain || !*p_vout->psz_filter_chain ) 
     361    { 
     362        var_Create( p_vout, "vout", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); 
     363        var_Get( p_vout, "vout", &val ); 
     364        psz_plugin = val.psz_string; 
     365    } 
     366    else 
     367    { 
     368        /* the filter chain is a string list of filters separated by double 
     369         * colons */ 
     370        char *psz_end; 
     371 
     372        psz_end = strchr( p_vout->psz_filter_chain, ':' ); 
     373        if( psz_end ) 
     374            psz_plugin = strndup( p_vout->psz_filter_chain, 
     375                                  psz_end - p_vout->psz_filter_chain ); 
     376        else psz_plugin = strdup( p_vout->psz_filter_chain ); 
     377    } 
     378 
    361379    /* Initialize the dimensions of the video window */ 
    362380    InitWindowSize( p_vout, &p_vout->i_window_width, 
    363381                    &p_vout->i_window_height ); 
    364382 
    365     /* Create thread and set locks */ 
    366     vlc_mutex_init( p_vout, &p_vout->picture_lock ); 
    367     vlc_mutex_init( p_vout, &p_vout->subpicture_lock ); 
    368     vlc_mutex_init( p_vout, &p_vout->change_lock ); 
    369  
    370     vlc_object_attach( p_vout, p_parent ); 
    371  
     383    /* Create the vout thread */ 
    372384    p_vout->p_module = module_Need( p_vout, 
    373385                           ( p_vout->psz_filter_chain && 
     
    11581170                            int *pi_height ) 
    11591171{ 
     1172    vlc_value_t val; 
    11601173    int i_width, i_height; 
    11611174    uint64_t ll_zoom; 
     
    11631176#define FP_FACTOR 1000                             /* our fixed point factor */ 
    11641177 
    1165     i_width = config_GetInt( p_vout, "width" ); 
    1166     i_height = config_GetInt( p_vout, "height" ); 
    1167     ll_zoom = (uint64_t)( FP_FACTOR * config_GetFloat( p_vout, "zoom" ) ); 
     1178    var_Get( p_vout, "width", &val ); 
     1179    i_width = val.i_int; 
     1180    var_Get( p_vout, "height", &val ); 
     1181    i_height = val.i_int; 
     1182    var_Get( p_vout, "zoom", &val ); 
     1183    ll_zoom = (uint64_t)( FP_FACTOR * val.f_float ); 
    11681184 
    11691185    if( i_width > 0 && i_height > 0)