⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 core.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 2 页
字号:
 * config_PutInt: set the integer value of an int variable ***************************************************************************** * This function is used to set the value of variables which are internally * represented by an integer (CONFIG_ITEM_INTEGER and * CONFIG_ITEM_BOOL). *****************************************************************************/void __config_PutInt( vlc_object_t *p_this, const char *psz_name, int i_value ){    module_config_t *p_config;    vlc_value_t oldval, val;    p_config = config_FindConfig( p_this, psz_name );    /* sanity checks */    if( !p_config )    {        msg_Warn( p_this, "option %s does not exist", psz_name );        return;    }    if (!IsConfigIntegerType (p_config->i_type))    {        msg_Err( p_this, "option %s does not refer to an int", psz_name );        return;    }    /* backup old value */    oldval.i_int = p_config->value.i;    /* if i_min == i_max == 0, then do not use them */    if ((p_config->min.i == 0) && (p_config->max.i == 0))    {        p_config->value.i = i_value;    }    else if (i_value < p_config->min.i)    {        p_config->value.i = p_config->min.i;    }    else if (i_value > p_config->max.i)    {        p_config->value.i = p_config->max.i;    }    else    {        p_config->value.i = i_value;    }    p_config->b_dirty = true;    val.i_int = p_config->value.i;    if( p_config->pf_callback )    {        p_config->pf_callback( p_this, psz_name, oldval, val,                               p_config->p_callback_data );    }}/***************************************************************************** * config_PutFloat: set the value of a float variable ***************************************************************************** * This function is used to set the value of variables which are internally * represented by a float (CONFIG_ITEM_FLOAT). *****************************************************************************/void __config_PutFloat( vlc_object_t *p_this,                        const char *psz_name, float f_value ){    module_config_t *p_config;    vlc_value_t oldval, val;    p_config = config_FindConfig( p_this, psz_name );    /* sanity checks */    if( !p_config )    {        msg_Warn( p_this, "option %s does not exist", psz_name );        return;    }    if (!IsConfigFloatType (p_config->i_type))    {        msg_Err( p_this, "option %s does not refer to a float", psz_name );        return;    }    /* backup old value */    oldval.f_float = p_config->value.f;    /* if f_min == f_max == 0, then do not use them */    if ((p_config->min.f == 0) && (p_config->max.f == 0))    {        p_config->value.f = f_value;    }    else if (f_value < p_config->min.f)    {        p_config->value.f = p_config->min.f;    }    else if (f_value > p_config->max.f)    {        p_config->value.f = p_config->max.f;    }    else    {        p_config->value.f = f_value;    }    p_config->b_dirty = true;    val.f_float = p_config->value.f;    if( p_config->pf_callback )    {        p_config->pf_callback( p_this, psz_name, oldval, val,                               p_config->p_callback_data );    }}/***************************************************************************** * config_FindConfig: find the config structure associated with an option. ***************************************************************************** * FIXME: This function really needs to be optimized. * FIXME: And now even more. *****************************************************************************/module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name ){    vlc_list_t *p_list;    int i_index;    if( !psz_name ) return NULL;    p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );    for( i_index = 0; i_index < p_list->i_count; i_index++ )    {        module_config_t *p_item, *p_end;        module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object;        if( !p_parser->i_config_items )            continue;        for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;             p_item < p_end;             p_item++ )        {            if( p_item->i_type & CONFIG_HINT )                /* ignore hints */                continue;            if( !strcmp( psz_name, p_item->psz_name )             || ( p_item->psz_oldname              && !strcmp( psz_name, p_item->psz_oldname ) ) )            {                vlc_list_release( p_list );                return p_item;            }        }    }    vlc_list_release( p_list );    return NULL;}/***************************************************************************** * config_Free: frees a duplicated module's configuration data. ***************************************************************************** * This function frees all the data duplicated by config_Duplicate. *****************************************************************************/void config_Free( module_t *p_module ){    int i;    for (size_t j = 0; j < p_module->confsize; j++)    {        module_config_t *p_item = p_module->p_config + j;        free( p_item->psz_type );        free( p_item->psz_name );        free( p_item->psz_text );        free( p_item->psz_longtext );        free( p_item->psz_oldname );        if (IsConfigStringType (p_item->i_type))        {            free (p_item->value.psz);            free (p_item->orig.psz);            free (p_item->saved.psz);        }        if( p_item->ppsz_list )            for( i = 0; i < p_item->i_list; i++ )                free( p_item->ppsz_list[i] );        if( p_item->ppsz_list_text )            for( i = 0; i < p_item->i_list; i++ )                free( p_item->ppsz_list_text[i] );        free( p_item->ppsz_list );        free( p_item->ppsz_list_text );        free( p_item->pi_list );        if( p_item->i_action )        {            for( i = 0; i < p_item->i_action; i++ )            {                free( p_item->ppsz_action_text[i] );            }            free( p_item->ppf_action );            free( p_item->ppsz_action_text );        }    }    free (p_module->p_config);    p_module->p_config = NULL;}/***************************************************************************** * config_SetCallbacks: sets callback functions in the duplicate p_config. ***************************************************************************** * Unfortunatly we cannot work directly with the module's config data as * this module might be unloaded from memory at any time (remember HideModule). * This is why we need to duplicate callbacks each time we reload the module. *****************************************************************************/void config_SetCallbacks( module_config_t *p_new, module_config_t *p_orig,                          size_t n ){    for (size_t i = 0; i < n; i++)    {        p_new->pf_callback = p_orig->pf_callback;        p_new++;        p_orig++;    }}/***************************************************************************** * config_UnsetCallbacks: unsets callback functions in the duplicate p_config. ***************************************************************************** * We simply undo what we did in config_SetCallbacks. *****************************************************************************/void config_UnsetCallbacks( module_config_t *p_new, size_t n ){    for (size_t i = 0; i < n; i++)    {        p_new->pf_callback = NULL;        p_new++;    }}/***************************************************************************** * config_ResetAll: reset the configuration data for all the modules. *****************************************************************************/void __config_ResetAll( vlc_object_t *p_this ){    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);    int i_index;    vlc_list_t *p_list;    module_t *p_module;    /* Acquire config file lock */    vlc_mutex_lock( &priv->config_lock );    p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );    for( i_index = 0; i_index < p_list->i_count; i_index++ )    {        p_module = (module_t *)p_list->p_values[i_index].p_object ;        if( p_module->b_submodule ) continue;        for (size_t i = 0; i < p_module->confsize; i++ )        {            if (IsConfigIntegerType (p_module->p_config[i].i_type))                p_module->p_config[i].value.i = p_module->p_config[i].orig.i;            else            if (IsConfigFloatType (p_module->p_config[i].i_type))                p_module->p_config[i].value.f = p_module->p_config[i].orig.f;            else            if (IsConfigStringType (p_module->p_config[i].i_type))            {                free ((char *)p_module->p_config[i].value.psz);                p_module->p_config[i].value.psz =                        strdupnull (p_module->p_config[i].orig.psz);            }        }    }    vlc_list_release( p_list );    vlc_mutex_unlock( &priv->config_lock );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -