[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[355] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-11-13 11:51:44
|
Revision: 355 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=355&view=rev Author: nickols_k Date: 2012-11-13 11:51:33 +0000 (Tue, 13 Nov 2012) Log Message: ----------- size optimization Modified Paths: -------------- mplayerxp/cfg-mplayerxp.h mplayerxp/input2/input.c mplayerxp/libmpconf/cfgparser.c mplayerxp/libmpconf/cfgparser.h mplayerxp/libmpconf/m_option.c mplayerxp/libmpconf/m_option.h mplayerxp/mplayerxp.c Modified: mplayerxp/cfg-mplayerxp.h =================================================================== --- mplayerxp/cfg-mplayerxp.h 2012-11-13 10:42:13 UTC (rev 354) +++ mplayerxp/cfg-mplayerxp.h 2012-11-13 11:51:33 UTC (rev 355) @@ -23,19 +23,6 @@ extern af_cfg_t af_cfg; // Configuration for audio filters extern vf_cfg_t vf_cfg; // Configuration for audio filters -/* - * CONF_TYPE_FUNC_FULL : - * allows own implemtations for passing the params - * - * the function receives parameter name and argument (if it does not start with - ) - * useful with a conf.name like 'aa*' to parse several parameters to a function - * return 0 =ok, but we didn't need the param (could be the filename) - * return 1 =ok, we accepted the param - * negative values: see cfgparser.h, ERR_XXX - * - * by Folke - */ - static const config_t xpcore_config[]={ {"xp", &mp_conf.xp, CONF_TYPE_INT, CONF_RANGE, 0, UINT_MAX, "specifies number cpus to use for playback"}, {"dump", &mp_conf.stream_dump, CONF_TYPE_STRING, 0, 0, 0, "specifies dump type and name for the dump of stream"}, @@ -256,7 +243,7 @@ static const config_t mplayer_opts[]={ /* name, pointer, type, flags, min, max, help */ - {"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, ""}, /* this don't need anymore to be the first!!! */ + {"include", NULL, CONF_TYPE_INCLUDE, CONF_NOSAVE, 0, 0, ""}, /* this don't need anymore to be the first!!! */ //---------------------- libao/libvo/mplayer options ------------------------ {"vo", &mp_conf.video_driver, CONF_TYPE_STRING, 0, 0, 0, "select video output driver and optinaly device"}, @@ -268,7 +255,7 @@ {"ac", &mp_conf.audio_codec, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified audio-decoder"}, {"vc", &mp_conf.video_codec, CONF_TYPE_STRING, 0, 0, 0, "forces usage of specified video-decoder"}, /*UD*/ {"verbose", &mp_conf.verbose, CONF_TYPE_INT, CONF_RANGE|CONF_GLOBAL, 0, 100, "verbose output"}, - {"v", cfg_inc_verbose, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOSAVE, 0, 0, "verbose output (more -v means more verbosity)"}, + {"v", &mp_conf.verbose, CONF_TYPE_INC, 0, 0, 0, "verbose output (more -v means more verbosity)"}, {"msgfilter", &mp_conf.msg_filter, CONF_TYPE_INT, CONF_RANGE, 0, 0xFFFFFFFF, "specifies filter for verbosed messages"}, {"core", &xpcore_config, CONF_TYPE_SUBCONFIG, 0, 0, 0, "XP-core related options" }, Modified: mplayerxp/input2/input.c =================================================================== --- mplayerxp/input2/input.c 2012-11-13 10:42:13 UTC (rev 354) +++ mplayerxp/input2/input.c 2012-11-13 11:51:33 UTC (rev 355) @@ -116,8 +116,9 @@ unsigned ar_delay,ar_rate; const char* js_dev; const char* in_file; + int print_key_list,print_cmd_list; }input_conf_t; -static input_conf_t libinput_conf = { 1, 1, 1, 100, 8, "/dev/input/js0", NULL }; +static input_conf_t libinput_conf = { 1, 1, 1, 100, 8, "/dev/input/js0", NULL, 0, 0 }; /// This array defines all know commands. /// The first field is an id used to recognize the command without too many strcmp @@ -420,8 +421,8 @@ void (*mp_input_key_cb)(int code) = NULL; static mp_cmd_t* mp_cmd_clone(mp_cmd_t* cmd); // This create a copy of a command (used by the auto repeat stuff) -static int mp_input_print_key_list(any_t*,const config_t* cfg); -static int mp_input_print_cmd_list(any_t*,const config_t* cfg); +static int mp_input_print_key_list(any_t*); +static int mp_input_print_cmd_list(any_t*); static const config_t joystick_conf[] = { { "on", &libinput_conf.use_joystick, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, "enables using of joystick" }, @@ -436,8 +437,8 @@ { "conf", &config_file, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifies alternative input.conf" }, { "ar-delay", &libinput_conf.ar_delay, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "autorepeate a key delay in milliseconds (0 to disable)" }, { "ar-rate", &libinput_conf.ar_rate, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "number of key-presses per second generating on autorepeat" }, - { "keylist", mp_input_print_key_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, "prints all keys that can be bound to commands" }, - { "cmdlist", mp_input_print_cmd_list, CONF_TYPE_FUNC, CONF_GLOBAL, 0, 0, "prints all commands that can be bound to keys" }, + { "keylist", &libinput_conf.print_key_list, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "prints all keys that can be bound to commands" }, + { "cmdlist", &libinput_conf.print_cmd_list, CONF_TYPE_INT, CONF_GLOBAL, 0, 0, "prints all commands that can be bound to keys" }, { "file", &libinput_conf.in_file, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifes file with commands (useful for FIFO)" }, #ifdef HAVE_LIRC { "lircconf", &lirc_configfile, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, "specifies a config.file for LIRC"}, @@ -1346,6 +1347,8 @@ priv->ar_state=-1; priv->in_file_fd=-1; mp_input_init(priv); + if(libinput_conf.print_key_list) mp_input_print_key_list(priv); + if(libinput_conf.print_cmd_list) mp_input_print_cmd_list(priv); return priv; } @@ -1365,8 +1368,7 @@ for(i= 0; key_names[i].name != NULL ; i++) MSG_INFO("%s\n",key_names[i].name); } -static int mp_input_print_key_list(any_t*handle,const config_t* cfg) { - UNUSED(cfg); +static int mp_input_print_key_list(any_t*handle) { mp_input_print_keys(handle); exit(0); } @@ -1412,8 +1414,7 @@ } } -static int mp_input_print_cmd_list(any_t*handle,const config_t* cfg) { - UNUSED(cfg); +static int mp_input_print_cmd_list(any_t*handle) { mp_input_print_cmds(handle); exit(0); } Modified: mplayerxp/libmpconf/cfgparser.c =================================================================== --- mplayerxp/libmpconf/cfgparser.c 2012-11-13 10:42:13 UTC (rev 354) +++ mplayerxp/libmpconf/cfgparser.c 2012-11-13 11:51:33 UTC (rev 355) @@ -16,6 +16,7 @@ #include <string.h> #include <errno.h> #include "mp_config.h" +#include "osdep/mplib.h" #define COMMAND_LINE 0 #define CONFIG_FILE 1 @@ -90,6 +91,7 @@ switch(conf->type) { case CONF_TYPE_FLAG : + case CONF_TYPE_INC : case CONF_TYPE_INT : save[sl].param.as_int = *((int*)conf->p); break; @@ -99,13 +101,9 @@ case CONF_TYPE_STRING : save[sl].param.as_pointer = *((char**)conf->p); break; - case CONF_TYPE_FUNC_FULL : - if(strcasecmp(conf->name,opt) != 0) save->opt_name = mp_strdup(opt); - case CONF_TYPE_FUNC_PARAM : + case CONF_TYPE_INCLUDE : if(param) save->param.as_pointer = mp_strdup(param); - case CONF_TYPE_FUNC : - break; default : MSG_ERR("Should never append in m_config_save_option : conf->type=%d\n",conf->type); } @@ -129,7 +127,8 @@ MSG_DBG2("Reverting option %s\n",arg); switch(save->opt->type) { - case CONF_TYPE_FLAG : + case CONF_TYPE_FLAG: + case CONF_TYPE_INC : case CONF_TYPE_INT : *((int*)save->opt->p) = save->param.as_int; break; @@ -139,9 +138,7 @@ case CONF_TYPE_STRING : *((char**)save->opt->p) = save->param.as_pointer; break; - case CONF_TYPE_FUNC_PARAM : - case CONF_TYPE_FUNC_FULL : - case CONF_TYPE_FUNC : + case CONF_TYPE_INCLUDE : if(config->cs_level > 0) { for(i = config->cs_level - 1 ; i >= 0 ; i--){ if(config->config_stack[i] == NULL) continue; @@ -159,11 +156,7 @@ if(i < 0) break; arg = iter->opt_name ? iter->opt_name : iter->opt->name; switch(iter->opt->type) { - case CONF_TYPE_FUNC : - if ((((cfg_func_t) iter->opt->p)(iter->opt)) < 0) - return -1; - break; - case CONF_TYPE_FUNC_PARAM : + case CONF_TYPE_INCLUDE : if (iter->param.as_pointer == NULL) { MSG_ERR("We lost param for option %s?\n",iter->opt->name); return -1; @@ -171,16 +164,6 @@ if ((((cfg_func_param_t) iter->opt->p)(iter->opt, (char*)iter->param.as_pointer)) < 0) return -1; break; - case CONF_TYPE_FUNC_FULL : - if (iter->param.as_pointer != NULL && ((char*)iter->param.as_pointer)[0]=='-'){ - if( ((cfg_func_arg_param_t) iter->opt->p)(iter->opt, arg, NULL) < 0) - return -1; - }else { - if (((cfg_func_arg_param_t) save->opt->p)(iter->opt, arg, (char*)iter->param.as_pointer) < 0) - return -1; - - } - break; } break; default : @@ -330,6 +313,12 @@ return 0; } +static MPXP_Rc cfg_include(m_config_t* conf,const char *filename){ + return m_config_parse_config_file(conf, filename); +} + +static int cfg_inc_int(int value){ return ++value; } + static int config_read_option(m_config_t *config,const config_t** conf_list,const char *opt,const char *param) { int i=0,nconf = 0; @@ -344,7 +333,6 @@ assert(conf_list != NULL); assert(opt != NULL); #endif - MSG_DBG3( "read_option: conf=%p opt='%s' param='%s'\n", conf, opt, param); for(nconf = 0 ; conf_list[nconf] != NULL; nconf++) { @@ -507,33 +495,19 @@ MSG_DBG3("assigning %s=%s as string value\n",conf[i].name,param); ret = 1; break; - case CONF_TYPE_FUNC_PARAM: + case CONF_TYPE_INC: + *((int *) conf[i].p) = cfg_inc_int(*((int *) conf[i].p)); + ret = 1; + break; + case CONF_TYPE_INCLUDE: if (param == NULL) goto err_missing_param; - if ((((cfg_func_param_t) conf[i].p)(conf + i, param)) < 0) { + if (cfg_include(config, param) < 0) { ret = ERR_FUNC_ERR; goto out; } ret = 1; break; - case CONF_TYPE_FUNC_FULL: - if (param!=NULL && param[0]=='-'){ - ret=((cfg_func_arg_param_t) conf[i].p)(conf + i, opt, NULL); - if (ret>=0) ret=0; - /* if we return >=0: param is processed again (if there is any) */ - }else{ - ret=((cfg_func_arg_param_t) conf[i].p)(conf + i, opt, param); - /* if we return 0: need no param, precess it again */ - /* if we return 1: accepted param */ - } - break; - case CONF_TYPE_FUNC: - if ((((cfg_func_t) conf[i].p)(conf + i)) < 0) { - ret = ERR_FUNC_ERR; - goto out; - } - ret = 0; - break; #if 0 // we have handled it in other function case CONF_TYPE_SUBCONFIG: @@ -696,7 +670,7 @@ return config_read_option(config,config->opt_list,opt,param); } -MPXP_Rc m_config_parse_config_file(m_config_t *config, char *conffile) +MPXP_Rc m_config_parse_config_file(m_config_t *config,const char *conffile) { #define PRINT_LINENUM MSG_ERR("%s(%d): ", conffile, line_num) #define MAX_LINE_LEN 1000 Modified: mplayerxp/libmpconf/cfgparser.h =================================================================== --- mplayerxp/libmpconf/cfgparser.h 2012-11-13 10:42:13 UTC (rev 354) +++ mplayerxp/libmpconf/cfgparser.h 2012-11-13 11:51:33 UTC (rev 355) @@ -12,10 +12,9 @@ CONF_TYPE_FLOAT =2, CONF_TYPE_STRING =3, CONF_TYPE_PRINT =4, - CONF_TYPE_FUNC =5, - CONF_TYPE_FUNC_PARAM=6, - CONF_TYPE_FUNC_FULL =7, - CONF_TYPE_SUBCONFIG =8 + CONF_TYPE_INC =5, + CONF_TYPE_INCLUDE =6, + CONF_TYPE_SUBCONFIG =7 }; enum { ERR_NOT_AN_OPTION =-1, @@ -82,7 +81,7 @@ * 0 if can't open configfile * 1 on success */ -MPXP_Rc m_config_parse_config_file(m_config_t *config, char *conffile); +MPXP_Rc m_config_parse_config_file(m_config_t *config,const char *conffile); /* parse_command_line returns: * -1 on error (invalid option...) Modified: mplayerxp/libmpconf/m_option.c =================================================================== --- mplayerxp/libmpconf/m_option.c 2012-11-13 10:42:13 UTC (rev 354) +++ mplayerxp/libmpconf/m_option.c 2012-11-13 11:51:33 UTC (rev 355) @@ -691,163 +691,11 @@ #undef VAL #define VAL(x) (*(m_func_save_t**)(x)) -static void free_func_pf(any_t* src) { - m_func_save_t *s,*n; - - if(!src) return; - - s = VAL(src); - - while(s) { - n = s->next; - mp_free(s->name); - if(s->param) mp_free(s->param); - mp_free(s); - s = n; - } - VAL(src) = NULL; -} - -// Parser for func_param and func_full -static int parse_func_pf(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { - m_func_save_t *s,*p; - - if(!dst) - return 1; - - s = mp_calloc(1,sizeof(m_func_save_t)); - s->name = mp_strdup(name); - s->param = param ? mp_strdup(param) : NULL; - - p = VAL(dst); - if(p) { - for( ; p->next != NULL ; p = p->next) - /**/; - p->next = s; - } else - VAL(dst) = s; - - return 1; -} - -static void copy_func_pf(const m_option_t* opt,any_t* dst, any_t* src) { - m_func_save_t *d = NULL, *s,* last = NULL; - - if(!(dst && src)) return; - s = VAL(src); - - if(VAL(dst)) - free_func_pf(dst); - - while(s) { - d = mp_calloc(1,sizeof(m_func_save_t)); - d->name = mp_strdup(s->name); - d->param = s->param ? mp_strdup(s->param) : NULL; - if(last) - last->next = d; - else - VAL(dst) = d; - last = d; - s = s->next; - } - - -} - -/////////////////// Func_param - -static void set_func_param(const m_option_t* opt, any_t* dst, any_t* src) { - m_func_save_t* s; - - if(!src) return; - s = VAL(src); - - if(!s) return; - - // Revert if needed - if(opt->priv) ((m_opt_default_func_t)opt->priv)(opt,opt->name); - for( ; s != NULL ; s = s->next) - ((m_opt_func_param_t) opt->p)(opt,s->param); -} - -const m_option_type_t m_option_type_func_param = { - "Func param", - "", - sizeof(m_func_save_t*), - M_OPT_TYPE_INDIRECT, - parse_func_pf, - NULL, - NULL, // Nothing to do on save - set_func_param, - copy_func_pf, - free_func_pf -}; - -/////////////////// Func_full - -static void set_func_full(const m_option_t* opt, any_t* dst, any_t* src) { - m_func_save_t* s; - - if(!src) return; - - for(s = VAL(src) ; s ; s = s->next) { - // Revert if needed - if(opt->priv) ((m_opt_default_func_t)opt->priv)(opt,s->name); - ((m_opt_func_full_t) opt->p)(opt,s->name,s->param); - } -} - -const m_option_type_t m_option_type_func_full = { - "Func full", - "", - sizeof(m_func_save_t*), - M_OPT_TYPE_ALLOW_WILDCARD|M_OPT_TYPE_INDIRECT, - parse_func_pf, - NULL, - NULL, // Nothing to do on save - set_func_full, - copy_func_pf, - free_func_pf -}; - -/////////////// Func - -#undef VAL -#define VAL(x) (*(int*)(x)) - -static int parse_func(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { - if(dst) - VAL(dst) += 1; - return 0; -} - -static void set_func(const m_option_t* opt,any_t* dst, any_t* src) { - int i; - if(opt->priv) ((m_opt_default_func_t)opt->priv)(opt,opt->name); - for(i = 0 ; i < VAL(src) ; i++) - ((m_opt_func_t) opt->p)(opt); -} - -const m_option_type_t m_option_type_func = { - "Func", - "", - sizeof(int), - M_OPT_TYPE_INDIRECT, - parse_func, - NULL, - NULL, // Nothing to do on save - set_func, - NULL, - NULL -}; - /////////////////// Print static int parse_print(const m_option_t* opt,const char *name, char *param, any_t* dst, int src) { if(opt->type == MCONF_TYPE_PRINT_INDIRECT) MSG_INFO("%s", *(char **) opt->p); - else if(opt->type == MCONF_TYPE_PRINT_FUNC) - return ((m_opt_func_full_t) opt->p)(opt,name,param); else MSG_INFO("%s", (char *) opt->p); Modified: mplayerxp/libmpconf/m_option.h =================================================================== --- mplayerxp/libmpconf/m_option.h 2012-11-13 10:42:13 UTC (rev 354) +++ mplayerxp/libmpconf/m_option.h 2012-11-13 11:51:33 UTC (rev 355) @@ -38,23 +38,9 @@ extern const m_option_type_t m_option_type_imgfmt; extern const m_option_type_t m_option_type_afmt; -// Func-based types -extern const m_option_type_t m_option_type_func_full; -extern const m_option_type_t m_option_type_func_param; -extern const m_option_type_t m_option_type_func; - /// Callback used to reset func options. typedef void (*m_opt_default_func_t)(const m_option_t *, const char*); -/// Callback used by m_option_type_func_full options. -typedef int (*m_opt_func_full_t)(const m_option_t *, const char *, char *); - -/// Callback used by m_option_type_func_param options. -typedef int (*m_opt_func_param_t)(const m_option_t *, const char *); - -/// Callback used by m_option_type_func options. -typedef int (*m_opt_func_t)(const m_option_t *); - enum { END_AT_NONE=0, END_AT_TIME=1, @@ -136,10 +122,7 @@ #define MCONF_TYPE_FLOAT (&m_option_type_float) #define MCONF_TYPE_DOUBLE (&m_option_type_double) #define MCONF_TYPE_STRING (&m_option_type_string) -#define MCONF_TYPE_FUNC (&m_option_type_func) -#define MCONF_TYPE_FUNC_PARAM (&m_option_type_func_param) #define MCONF_TYPE_PRINT (&m_option_type_print) -#define MCONF_TYPE_FUNC_FULL (&m_option_type_func_full) #define MCONF_TYPE_SUBCONFIG (&m_option_type_subconfig) #define MCONF_TYPE_POSITION (&m_option_type_position) #define MCONF_TYPE_IMGFMT (&m_option_type_imgfmt) Modified: mplayerxp/mplayerxp.c =================================================================== --- mplayerxp/mplayerxp.c 2012-11-13 10:42:13 UTC (rev 354) +++ mplayerxp/mplayerxp.c 2012-11-13 11:51:33 UTC (rev 355) @@ -154,12 +154,6 @@ /************************************************************************** Config file **************************************************************************/ -static int cfg_inc_verbose(struct config *conf){ UNUSED(conf); ++mp_conf.verbose; return 0;} - -static MPXP_Rc cfg_include(struct config *conf, char *filename){ - UNUSED(conf); - return m_config_parse_config_file(mp_data->mconfig, filename); -} #include "cfg-mplayerxp.h" /**************************************************************************/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |