[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[558] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-12-13 13:52:46
|
Revision: 558 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=558&view=rev Author: nickols_k Date: 2012-12-13 13:52:35 +0000 (Thu, 13 Dec 2012) Log Message: ----------- use m_config_t& instead of m_config_t* + constantization Modified Paths: -------------- mplayerxp/input2/input.cpp mplayerxp/libmpcodecs/ad.cpp mplayerxp/libmpcodecs/vd.cpp mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpconf/cfgparser.h mplayerxp/libmpdemux/demuxer.cpp mplayerxp/libmpstream2/cdd.h mplayerxp/libmpstream2/cdda.cpp mplayerxp/libplaytree/asxparser.cpp mplayerxp/libplaytree/playtree.cpp mplayerxp/libplaytree/playtree.h mplayerxp/mplayerxp.cpp mplayerxp/mplayerxp.h mplayerxp/xmpcore/xmp_context.cpp Modified: mplayerxp/input2/input.cpp =================================================================== --- mplayerxp/input2/input.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/input2/input.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -1345,7 +1345,7 @@ delete &handle; } -void mp_input_register_options(m_config_t* cfg) { +void mp_input_register_options(m_config_t& cfg) { m_config_register_options(cfg,mp_input_opts); } Modified: mplayerxp/libmpcodecs/ad.cpp =================================================================== --- mplayerxp/libmpcodecs/ad.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libmpcodecs/ad.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -66,7 +66,7 @@ static unsigned int nddrivers=sizeof(mpcodecs_ad_drivers)/sizeof(ad_functions_t*); -void libmpcodecs_ad_register_options(m_config_t* cfg) +void libmpcodecs_ad_register_options(m_config_t& cfg) { unsigned i; for(i=0;i<nddrivers;i++) { Modified: mplayerxp/libmpcodecs/vd.cpp =================================================================== --- mplayerxp/libmpcodecs/vd.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libmpcodecs/vd.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -73,7 +73,7 @@ }; static unsigned int nddrivers=sizeof(mpcodecs_vd_drivers)/sizeof(vd_functions_t*); -void libmpcodecs_vd_register_options(m_config_t* cfg) +void libmpcodecs_vd_register_options(m_config_t& cfg) { unsigned i; for(i=0;i<nddrivers;i++) { Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libmpconf/cfgparser.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -25,12 +25,6 @@ #define CONFIG_GLOBAL (1<<0) #define CONFIG_RUNNING (1<<1) -#define SET_GLOBAL(c) (c->flags |= CONFIG_GLOBAL) -#define UNSET_GLOBAL(c) (c->flags &= (!CONFIG_GLOBAL)) -#define IS_GLOBAL(c) (c->flags & CONFIG_GLOBAL) -#define SET_RUNNING(c) (c->flags |= CONFIG_RUNNING) -#define IS_RUNNING(c) (c->flags & CONFIG_RUNNING) - #define MAX_RECURSION_DEPTH 8 #ifdef MP_DEBUG @@ -39,21 +33,28 @@ #include "mplayerxp.h" #include "cfgparser.h" +#include "libplaytree/playtree.h" #define MSGT_CLASS MSGT_CFGPARSER #include "mp_msg.h" +inline void SET_GLOBAL(m_config_t& c) { c.flags |= CONFIG_GLOBAL; } +inline void UNSET_GLOBAL(m_config_t& c) { c.flags &= (!CONFIG_GLOBAL); } +inline int IS_GLOBAL(const m_config_t& c) { return c.flags & CONFIG_GLOBAL; } +inline void SET_RUNNING(m_config_t& c) { c.flags |= CONFIG_RUNNING; } +inline int IS_RUNNING(const m_config_t& c) { return c.flags & CONFIG_RUNNING; } + typedef int (*cfg_func_arg_param_t)(const config_t *,const char *,const char *); typedef int (*cfg_func_param_t)(const config_t *,const char *); typedef int (*cfg_func_t)(const config_t *); static void -m_config_save_option(m_config_t* config,const config_t* conf,const char* opt,const char *param) { +m_config_save_option(m_config_t& config,const config_t* conf,const char* opt,const char *param) { config_save_t* save; int sl=0; #ifdef MP_DEBUG assert(config != NULL); - assert(config->cs_level >= 0); + assert(config.cs_level >= 0); assert(conf != NULL); assert(opt != NULL); assert( ! (conf->flags & CONF_NOSAVE)); @@ -69,7 +70,7 @@ MSG_DBG2("Saving option %s\n",opt); - save = config->config_stack[config->cs_level]; + save = config.config_stack[config.cs_level]; if(save) { for(sl = 0; save[sl].opt != NULL; sl++){ @@ -108,17 +109,17 @@ MSG_ERR("Should never append in m_config_save_option : conf->type=%d\n",conf->type); } - config->config_stack[config->cs_level] = save; + config.config_stack[config.cs_level] = save; } -static int m_config_revert_option(m_config_t* config, config_save_t* save) { +static int m_config_revert_option(m_config_t& config, config_save_t* save) { const char* arg = NULL; config_save_t* iter=NULL; int i=-1; #ifdef MP_DEBUG assert(config != NULL); - assert(config->cs_level >= 0); + assert(config.cs_level >= 0); assert(save != NULL); #endif @@ -139,10 +140,10 @@ *((char**)save->opt->p) = reinterpret_cast<char*>(save->param.as_pointer); break; 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; - for(iter = config->config_stack[i]; iter != NULL && iter->opt != NULL ; iter++) { + if(config.cs_level > 0) { + for(i = config.cs_level - 1 ; i >= 0 ; i--){ + if(config.config_stack[i] == NULL) continue; + for(iter = config.config_stack[i]; iter != NULL && iter->opt != NULL ; iter++) { if(iter->opt == save->opt && ((save->param.as_pointer == NULL || iter->param.as_pointer == NULL) || strcasecmp((const char *)save->param.as_pointer,(const char *)iter->param.as_pointer) == 0) && (save->opt_name == NULL || @@ -174,80 +175,68 @@ return 1; } -void m_config_push(m_config_t* config) { +void m_config_push(m_config_t& config) { #ifdef MP_DEBUG assert(config != NULL); - assert(config->cs_level >= 0); + assert(config.cs_level >= 0); #endif - config->cs_level++; - config->config_stack = (config_save_t**)mp_realloc(config->config_stack ,sizeof(config_save_t*)*(config->cs_level+1)); - if(config->config_stack == NULL) { - MSG_ERR( "Can't allocate %d bytes of memory : %s\n",sizeof(config_save_t*)*(config->cs_level+1),strerror(errno)); - config->cs_level = -1; + config.cs_level++; + config.config_stack = (config_save_t**)mp_realloc(config.config_stack ,sizeof(config_save_t*)*(config.cs_level+1)); + if(config.config_stack == NULL) { + MSG_ERR( "Can't allocate %d bytes of memory : %s\n",sizeof(config_save_t*)*(config.cs_level+1),strerror(errno)); + config.cs_level = -1; return; } - config->config_stack[config->cs_level] = NULL; - MSG_DBG2("Config pushed level=%d\n",config->cs_level); + config.config_stack[config.cs_level] = NULL; + MSG_DBG2("Config pushed level=%d\n",config.cs_level); } -int m_config_pop(m_config_t* config) { +int m_config_pop(m_config_t& config) { int i,ret= 1; config_save_t* cs; #ifdef MP_DEBUG assert(config != NULL); - //assert(config->cs_level > 0); + //assert(config.cs_level > 0); #endif - if(config->config_stack[config->cs_level] != NULL) { - cs = config->config_stack[config->cs_level]; + if(config.config_stack[config.cs_level] != NULL) { + cs = config.config_stack[config.cs_level]; for(i=0; cs[i].opt != NULL ; i++ ) { if (m_config_revert_option(config,&cs[i]) < 0) ret = -1; } - delete config->config_stack[config->cs_level]; + delete config.config_stack[config.cs_level]; } - config->config_stack = (config_save_t**)mp_realloc(config->config_stack ,sizeof(config_save_t*)*config->cs_level); - config->cs_level--; - if(config->cs_level > 0 && config->config_stack == NULL) { - MSG_ERR( "Can't allocate %d bytes of memory : %s\n",sizeof(config_save_t*)*config->cs_level,strerror(errno)); - config->cs_level = -1; + config.config_stack = (config_save_t**)mp_realloc(config.config_stack ,sizeof(config_save_t*)*config.cs_level); + config.cs_level--; + if(config.cs_level > 0 && config.config_stack == NULL) { + MSG_ERR( "Can't allocate %d bytes of memory : %s\n",sizeof(config_save_t*)*config.cs_level,strerror(errno)); + config.cs_level = -1; return -1; } - MSG_DBG2("Config poped level=%d\n",config->cs_level); + MSG_DBG2("Config poped level=%d\n",config.cs_level); return ret; } -m_config_t* m_config_new(play_tree_t* pt,libinput_t&libinput) { - m_config_t* config; - +m_config_t& m_config_new(play_tree_t* pt,libinput_t&libinput) { #ifdef MP_DEBUG assert(pt != NULL); #endif - - config = new(zeromem) m_config_t(libinput); - if(config == NULL) { - MSG_ERR( "Can't allocate %d bytes of memory : %s\n",sizeof(m_config_t),strerror(errno)); - return NULL; - } - config->config_stack = (config_save_t**)mp_calloc(1,sizeof(config_save_t*)); - if(config->config_stack == NULL) { - MSG_ERR( "Can't allocate %d bytes of memory : %s\n",sizeof(config_save_t*),strerror(errno)); - delete config; - return NULL; - } + m_config_t& config = *new(zeromem) m_config_t(libinput); + config.config_stack = (config_save_t**)mp_calloc(1,sizeof(config_save_t*)); SET_GLOBAL(config); // We always start with global options - config->pt = pt; + config.pt = pt; return config; } -static void m_config_add_dynamic(m_config_t *conf,any_t*ptr) { - if(!conf->dynasize) conf->dynamics = (any_t**)mp_malloc(sizeof(any_t*)); - else conf->dynamics = (any_t**)mp_realloc(conf->dynamics,(conf->dynasize+1)*sizeof(any_t*)); - conf->dynamics[conf->dynasize] = ptr; - conf->dynasize++; +static void m_config_add_dynamic(m_config_t& conf,any_t*ptr) { + if(!conf.dynasize) conf.dynamics = (any_t**)mp_malloc(sizeof(any_t*)); + else conf.dynamics = (any_t**)mp_realloc(conf.dynamics,(conf.dynasize+1)*sizeof(any_t*)); + conf.dynamics[conf.dynasize] = ptr; + conf.dynasize++; } void m_config_free(m_config_t* config) { @@ -264,36 +253,36 @@ } -static int init_conf(m_config_t *config, int mode) +static int init_conf(m_config_t& config, int mode) { #ifdef MP_DEBUG assert(config != NULL); - assert(config->pt != NULL); - assert(config->last_entry == NULL || config->last_entry->parent == config->pt); + assert(config.pt != NULL); + assert(config.last_entry == NULL || config.last_entry->parent == config.pt); if (mode != COMMAND_LINE && mode != CONFIG_FILE) { MSG_ERR( "init_conf: wrong mode!\n"); return -1; } #endif - config->parser_mode = mode; - config->dynamics=NULL; - config->dynasize=0; + config.parser_mode = mode; + config.dynamics=NULL; + config.dynasize=0; return 1; } -static int config_is_entry_option(m_config_t *config,const char *opt,const char *param) { +static int config_is_entry_option(m_config_t& config,const char *opt,const char *param) { play_tree_t* entry = NULL; #ifdef MP_DEBUG - assert(config->pt != NULL); + assert(config.pt != NULL); #endif if(strcasecmp(opt,"playlist") == 0) { // We handle playlist here if(!param) return ERR_MISSING_PARAM; - entry = parse_playlist_file(config->libinput,param); + entry = parse_playlist_file(config.libinput,param); if(!entry) { MSG_ERR( "Playlist parsing failed: %s\n",param); return 1; @@ -301,25 +290,25 @@ } if(entry) { - if(config->last_entry) - play_tree_append_entry(config->last_entry,entry); + if(config.last_entry) + play_tree_append_entry(config.last_entry,entry); else - play_tree_set_child(config->pt,entry); - config->last_entry = entry; - if(config->parser_mode == COMMAND_LINE) + play_tree_set_child(config.pt,entry); + config.last_entry = entry; + if(config.parser_mode == COMMAND_LINE) UNSET_GLOBAL(config); return 1; } else return 0; } -static MPXP_Rc cfg_include(m_config_t* conf,const char *filename){ +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) +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; long tmp_int; @@ -356,12 +345,12 @@ MSG_DBG3( "read_option: name='%s' p=%p type=%d\n", conf[i].name, conf[i].p, conf[i].type); - if (conf[i].flags & CONF_NOCFG && config->parser_mode == CONFIG_FILE) { + if (conf[i].flags & CONF_NOCFG && config.parser_mode == CONFIG_FILE) { MSG_ERR( "this option can only be used on command line:\n", opt); ret = ERR_NOT_AN_OPTION; goto out; } - if (conf[i].flags & CONF_NOCMD && config->parser_mode == COMMAND_LINE) { + if (conf[i].flags & CONF_NOCMD && config.parser_mode == COMMAND_LINE) { MSG_ERR( "this option can only be used in config file:\n", opt); ret = ERR_NOT_AN_OPTION; goto out; @@ -379,7 +368,7 @@ switch (conf[i].type) { case CONF_TYPE_FLAG: /* flags need a parameter in config file */ - if (config->parser_mode == CONFIG_FILE) { + if (config.parser_mode == CONFIG_FILE) { if (!strcasecmp(param, "yes") || /* any other language? */ !strcasecmp(param, "ja") || !strcasecmp(param, "si") || @@ -531,7 +520,7 @@ sublist[0] = subconf; for (subconf_optnr = 0; subconf[subconf_optnr].name != NULL; subconf_optnr++) /* NOTHING */; - config->sub_conf = opt; + config.sub_conf = opt; token = strtok(p, (char *)&(":")); while(token) { @@ -561,7 +550,7 @@ } token = strtok(NULL, (char *)&(":")); } - config->sub_conf = NULL; + config.sub_conf = NULL; delete subparam; delete subopt; delete p; @@ -578,14 +567,14 @@ } out: if(ret >= 0 && ! IS_RUNNING(config) && ! IS_GLOBAL(config) && ! (conf[i].flags & CONF_GLOBAL) && conf[i].type != CONF_TYPE_SUBCONFIG ) { - play_tree_t* dest = config->last_entry ? config->last_entry : config->last_parent; + play_tree_t* dest = config.last_entry ? config.last_entry : config.last_parent; char* o; #ifdef MP_DEBUG assert(dest != NULL); #endif - if(config->sub_conf) { - o = new char [(strlen(config->sub_conf) + 1 + strlen(opt) + 1)]; - sprintf(o,"%s:%s",config->sub_conf,opt); + if(config.sub_conf) { + o = new char [(strlen(config.sub_conf) + 1 + strlen(opt) + 1)]; + sprintf(o,"%s:%s",config.sub_conf,opt); } else o =mp_strdup(opt); @@ -603,18 +592,18 @@ goto out; } -static const config_t* m_config_find_option(const config_t **list,const char *name); +static const config_t* m_config_find_option(const config_t**list,const char *name); -int m_config_set_option(m_config_t *config,const char *opt,const char *param) { +int m_config_set_option(m_config_t& config,const char *opt,const char *param) { const char *e; - const config_t **clist=config->opt_list; + const config_t**clist=config.opt_list; #ifdef MP_DEBUG assert(config != NULL); - assert(config->opt_list != NULL); + assert(config.opt_list != NULL); assert(opt != NULL); #endif MSG_DBG2( "Setting option %s=%s\n",opt,param); - clist = config->opt_list; + clist = config.opt_list; #if 1 if(strchr(opt,'.')) { int flg,ret; @@ -639,10 +628,10 @@ MSG_DBG2("switching next subconf=%s\n",subconf->name); } }while(1); - flg=config->flags; - config->flags|=CONFIG_GLOBAL; + flg=config.flags; + config.flags|=CONFIG_GLOBAL; ret=config_read_option(config,olist,opt,param); - config->flags=flg; + config.flags=flg; return ret; } #endif @@ -667,10 +656,10 @@ return ret; } - return config_read_option(config,config->opt_list,opt,param); + return config_read_option(config,config.opt_list,opt,param); } -MPXP_Rc m_config_parse_config_file(m_config_t *config,const 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 @@ -693,9 +682,9 @@ assert(config != NULL); // assert(conf_list != NULL); #endif - if (++config->recursion_depth > 1) MSG_INFO("Reading config file: %s", conffile); + if (++config.recursion_depth > 1) MSG_INFO("Reading config file: %s", conffile); - if (config->recursion_depth > MAX_RECURSION_DEPTH) { + if (config.recursion_depth > MAX_RECURSION_DEPTH) { MSG_FATAL(": too deep 'include'. check your configfiles\n"); ret = MPXP_False; goto out; @@ -713,12 +702,12 @@ } if ((fp = fopen(conffile, "r")) == NULL) { - if (config->recursion_depth > 1) MSG_ERR(": %s\n", strerror(errno)); + if (config.recursion_depth > 1) MSG_ERR(": %s\n", strerror(errno)); delete line; ret = MPXP_Ok; goto out; } - if (config->recursion_depth > 1) MSG_FATAL("\n"); + if (config.recursion_depth > 1) MSG_FATAL("\n"); while (fgets(line, MAX_LINE_LEN, fp)) { if (errors >= 16) { @@ -854,11 +843,11 @@ delete line; fclose(fp); out: - --config->recursion_depth; + --config.recursion_depth; return ret; } -MPXP_Rc m_config_parse_command_line(m_config_t *config, int argc, char **argv, char **envp) +MPXP_Rc m_config_parse_command_line(m_config_t& config, int argc, char **argv, char **envp) { int i; int tmp; @@ -868,16 +857,16 @@ #ifdef MP_DEBUG assert(config != NULL); - assert(config->pt != NULL); + assert(config.pt != NULL); assert(argv != NULL); assert(envp != NULL); assert(argc >= 1); #endif if (init_conf(config, COMMAND_LINE) == -1) return MPXP_False; - if(config->last_parent == NULL) config->last_parent = config->pt; + if(config.last_parent == NULL) config.last_parent = config.pt; /* in order to work recursion detection properly in parse_config_file */ - ++config->recursion_depth; + ++config.recursion_depth; for (i = 1; i < argc; i++) { //next: @@ -902,23 +891,23 @@ if((opt[0] == '{') && (opt[1] == '\0')) { play_tree_t* entry = play_tree_new(); UNSET_GLOBAL(config); - if(config->last_entry == NULL) { - play_tree_set_child(config->last_parent,entry); + if(config.last_entry == NULL) { + play_tree_set_child(config.last_parent,entry); } else { - play_tree_append_entry(config->last_entry,entry); - config->last_entry = NULL; + play_tree_append_entry(config.last_entry,entry); + config.last_entry = NULL; } - config->last_parent = entry; + config.last_parent = entry; continue; } if((opt[0] == '}') && (opt[1] == '\0')) { - if( ! config->last_parent || ! config->last_parent->parent) { + if( ! config.last_parent || ! config.last_parent->parent) { MSG_ERR( "too much }-\n"); goto err_out; } - config->last_entry = config->last_parent; - config->last_parent = config->last_entry->parent; + config.last_entry = config.last_parent; + config.last_parent = config.last_entry->parent; continue; } @@ -973,14 +962,14 @@ if(strcasecmp(argv[i],"-") == 0) m_config_set_option(config,"use-stdin",NULL); /* opt is not an option -> treat it as a filename */ UNSET_GLOBAL(config); // We start entry specific options - if(config->last_entry == NULL) play_tree_set_child(config->last_parent,entry); - else play_tree_append_entry(config->last_entry,entry); - config->last_entry = entry; + if(config.last_entry == NULL) play_tree_set_child(config.last_parent,entry); + else play_tree_append_entry(config.last_entry,entry); + config.last_entry = entry; } } - --config->recursion_depth; - if(config->last_parent != config->pt) MSG_ERR("Missing }- ?\n"); + --config.recursion_depth; + if(config.last_parent != config.pt) MSG_ERR("Missing }- ?\n"); UNSET_GLOBAL(config); SET_RUNNING(config); return MPXP_Ok; @@ -989,14 +978,14 @@ MSG_ERR( "can't allocate memory for filenames (%s)\n", strerror(errno)); #endif err_out: - --config->recursion_depth; + --config.recursion_depth; MSG_ERR( "command line: %s\n", argv[i]); return MPXP_False; } -int m_config_register_options(m_config_t *config,const config_t *args) { +int m_config_register_options(m_config_t& config,const config_t *args) { int list_len = 0; - const config_t** conf_list = config->opt_list; + const config_t** conf_list = config.opt_list; #ifdef MP_DEBUG assert(config != NULL); @@ -1016,7 +1005,7 @@ conf_list[list_len] = args; conf_list[list_len+1] = NULL; - config->opt_list = conf_list; + config.opt_list = conf_list; return 1; } @@ -1036,7 +1025,7 @@ return NULL; } -const config_t* m_config_get_option(m_config_t const*config,const char* arg) { +const config_t* m_config_get_option(const m_config_t& config,const char* arg) { const char *e; const config_t **conf_list; const config_t* cl[] = { NULL, NULL }; @@ -1057,11 +1046,11 @@ conf_list = cl; delete s; } else - conf_list = config->opt_list; + conf_list = config.opt_list; return m_config_find_option(conf_list,arg); } -any_t* m_config_get_option_ptr(m_config_t const*config,const char* arg) { +any_t* m_config_get_option_ptr(const m_config_t& config,const char* arg) { const config_t* conf; #ifdef MP_DEBUG @@ -1074,7 +1063,7 @@ return conf->p; } -int m_config_get_int (m_config_t const *config,const char* arg,int* err_ret) { +int m_config_get_int (const m_config_t& config,const char* arg,int* err_ret) { int *ret; #ifdef MP_DEBUG @@ -1093,7 +1082,7 @@ return (*ret); } -float m_config_get_float (m_config_t const *config,const char* arg,int* err_ret) { +float m_config_get_float (const m_config_t& config,const char* arg,int* err_ret) { float *ret; #ifdef MP_DEBUG @@ -1112,9 +1101,10 @@ return (*ret); } -#define AS_INT(c) (*((int*)c->p)) +inline int AS_INT(const config_t* c) { return *((int*)c->p); } +inline void AS_INT(const config_t* c,int val) { *((int*)c->p)=val; } -int m_config_set_int(m_config_t *config,const char* arg,int val) { +int m_config_set_int(m_config_t& config,const char* arg,int val) { const config_t* opt; #ifdef MP_DEBUG @@ -1133,12 +1123,12 @@ return ERR_OUT_OF_RANGE; m_config_save_option(config,opt,arg,NULL); - AS_INT(opt) = val; + AS_INT(opt,val); return 1; } -int m_config_set_float(m_config_t *config,const char* arg,float val) { +int m_config_set_float(m_config_t& config,const char* arg,float val) { const config_t* opt; #ifdef MP_DEBUG @@ -1163,7 +1153,7 @@ } -int m_config_switch_flag(m_config_t *config,const char* opt) { +int m_config_switch_flag(m_config_t& config,const char* opt) { const config_t *conf; #ifdef MP_DEBUG @@ -1173,14 +1163,14 @@ conf = m_config_get_option(config,opt); if(!conf || conf->type != CONF_TYPE_FLAG) return 0; - if( AS_INT(conf) == conf->min) AS_INT(conf) = conf->max; - else if(AS_INT(conf) == conf->max) AS_INT(conf) = conf->min; + if( AS_INT(conf) == conf->min) AS_INT(conf,conf->max); + else if(AS_INT(conf) == conf->max) AS_INT(conf,conf->min); else return 0; return 1; } -int m_config_set_flag(m_config_t* config,const char* opt, int state) { +int m_config_set_flag(m_config_t& config,const char* opt, int state) { const config_t *conf; #ifdef MP_DEBUG @@ -1190,30 +1180,26 @@ conf = m_config_get_option(config,opt); if(!conf || conf->type != CONF_TYPE_FLAG) return 0; - if(state) AS_INT(conf) = conf->max; - else AS_INT(conf) = conf->min; + if(state) AS_INT(conf,conf->max); + else AS_INT(conf,conf->min); return 1; } -int m_config_get_flag(m_config_t const *config,const char* opt) { - const config_t *conf; +int m_config_get_flag(const m_config_t& config,const char* opt) { #ifdef MP_DEBUG assert(config != NULL); assert(opt != NULL); #endif - conf = m_config_get_option(config,opt); + const config_t* conf = m_config_get_option(config,opt); if(!conf || conf->type != CONF_TYPE_FLAG) return -1; - if(AS_INT(conf) == conf->max) - return 1; - else if(AS_INT(conf) == conf->min) - return 0; - else - return -1; + if(AS_INT(conf) == conf->max) return 1; + else if(AS_INT(conf) == conf->min) return 0; + return -1; } -int m_config_is_option_set(m_config_t const*config,const char* arg) { +int m_config_is_option_set(const m_config_t& config,const char* arg) { const config_t* opt; config_save_t* save; int l,i; @@ -1228,8 +1214,8 @@ if(!opt) return -1; - for(l = config->cs_level ; l >= 0 ; l--) { - save = config->config_stack[l]; + for(l = config.cs_level ; l >= 0 ; l--) { + save = config.config_stack[l]; if(!save) continue; for(i = 0 ; save[i].opt != NULL ; i++) { @@ -1330,12 +1316,12 @@ }; } -void m_config_show_options(const m_config_t *args) { +void m_config_show_options(const m_config_t& args) { unsigned j; const config_t *opts; j=0; MSG_INFO("List of available command-line options:\n"); - while((opts=args->opt_list[j])!=NULL) { + while((opts=args.opt_list[j])!=NULL) { __m_config_show_options(2,NULL,opts); j++; }; Modified: mplayerxp/libmpconf/cfgparser.h =================================================================== --- mplayerxp/libmpconf/cfgparser.h 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libmpconf/cfgparser.h 2012-12-13 13:52:35 UTC (rev 558) @@ -8,7 +8,7 @@ namespace mpxp { struct libinput_t; } - +struct play_tree_t; /* config types */ enum { CONF_TYPE_FLAG =0, @@ -40,8 +40,6 @@ typedef struct m_config m_config_t; typedef struct config_save config_save_t; -#include "libplaytree/playtree.h" - struct config_t { const char *name; any_t* const p; @@ -86,31 +84,31 @@ * 0 if can't open configfile * 1 on success */ -MPXP_Rc m_config_parse_config_file(m_config_t *config,const 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...) * 1 otherwise */ -MPXP_Rc m_config_parse_command_line(m_config_t* config, int argc, char **argv, char **envp); +MPXP_Rc m_config_parse_command_line(m_config_t& config, int argc, char **argv, char **envp); -m_config_t* m_config_new(play_tree_t* pt,libinput_t&libinput); +m_config_t& m_config_new(play_tree_t* pt,libinput_t&libinput); void m_config_free(m_config_t* config); -void m_config_push(m_config_t* config); +void m_config_push(m_config_t& config); /* * Return 0 on error 1 on success */ -int m_config_pop(m_config_t* config); +int m_config_pop(m_config_t& config); /* * Return 0 on error 1 on success */ -int m_config_register_options(m_config_t *config,const config_t *args); +int m_config_register_options(m_config_t& config,const config_t *args); -void m_config_show_options(const m_config_t* args); +void m_config_show_options(const m_config_t& args); /* * For all the following function when it's a subconfig option @@ -120,55 +118,55 @@ /** Return 1 on sucess 0 on failure **/ -int m_config_set_option(m_config_t *config,const char *opt,const char *param); +int m_config_set_option(m_config_t& config,const char *opt,const char *param); /** Get the config struct defining an option * @return NULL on error **/ -const config_t* m_config_get_option(m_config_t const *config,const char* arg); +const config_t* m_config_get_option(const m_config_t& config,const char* arg); /** Get the p field of the struct defining an option * @return NULL on error **/ -any_t* m_config_get_option_ptr(m_config_t const *config,const char* arg); +any_t* m_config_get_option_ptr(const m_config_t& config,const char* arg); /** Tell is an option is alredy set or not * @return -1 one error (requested option arg exist) otherwise 0 or 1 **/ -int m_config_is_option_set(m_config_t const*config,const char* arg); +int m_config_is_option_set(const m_config_t& config,const char* arg); /** Return 0 on error 1 on success **/ -int m_config_switch_flag(m_config_t *config,const char* opt); +int m_config_switch_flag(m_config_t& config,const char* opt); /** Return 0 on error 1 on success **/ -int m_config_set_flag(m_config_t *config,const char* opt, int max); +int m_config_set_flag(m_config_t& config,const char* opt, int max); /** Return the value of a flag (O or 1) and -1 on error **/ -int m_config_get_flag(m_config_t const *config,const char* opt); +int m_config_get_flag(const m_config_t& config,const char* opt); /** Set the value of an int option * @return 0 on error 1 on success **/ -int m_config_set_int(m_config_t *config,const char* arg,int val); +int m_config_set_int(m_config_t& config,const char* arg,int val); /** Get the value of an int option * @param err_ret If it is not NULL it's set to 1 on error * @return the option value or -1 on error **/ -int m_config_get_int (m_config_t const *config,const char* arg,int* err_ret); +int m_config_get_int (const m_config_t&,const char* arg,int* err_ret); /** Set the value of a float option * @return 0 on error 1 on success **/ -int m_config_set_float(m_config_t *config,const char* arg,float val); +int m_config_set_float(m_config_t& config,const char* arg,float val); /** Get the value of a float option * @param err_ret If it is not NULL it's set to 1 on error * @return the option value or -1 on error **/ -float m_config_get_float (m_config_t const *config,const char* arg,int* err_ret); +float m_config_get_float (const m_config_t&,const char* arg,int* err_ret); #endif /* __CONFIG_H */ Modified: mplayerxp/libmpdemux/demuxer.cpp =================================================================== --- mplayerxp/libmpdemux/demuxer.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libmpdemux/demuxer.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -119,7 +119,7 @@ const demuxer_driver_t* driver; /**< driver associated with this demuxer */ }; -void libmpdemux_register_options(m_config_t* cfg) +void libmpdemux_register_options(m_config_t& cfg) { unsigned i; for(i=0;ddrivers[i];i++) { @@ -469,7 +469,7 @@ delete ad; ad = NULL; } else if(ad->audio->sh && ((sh_audio_t*)ad->audio->sh)->wtag == 0x55) // MP3 - m_config_set_flag(mpxp_context().mconfig,"mp3.hr-seek",1); // Enable high res seeking + m_config_set_flag(*mpxp_context().mconfig,"mp3.hr-seek",1); // Enable high res seeking } if(ss) { sd = new(zeromem) Demuxer(ss,-2,-2,dvdsub_id); @@ -534,7 +534,7 @@ { NULL, NULL, 0, 0, 0, 0, NULL} }; -void demuxer_register_options(m_config_t* cfg) { +void demuxer_register_options(m_config_t& cfg) { m_config_register_options(cfg,demuxer_opts); } Modified: mplayerxp/libmpstream2/cdd.h =================================================================== --- mplayerxp/libmpstream2/cdd.h 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libmpstream2/cdd.h 2012-12-13 13:52:35 UTC (rev 558) @@ -100,6 +100,6 @@ lsn_t end_sector; }; - void cdda_register_options(m_config_t* cfg); + void cdda_register_options(m_config_t& cfg); } // namespace mpxp #endif // __CDD_H__ Modified: mplayerxp/libmpstream2/cdda.cpp =================================================================== --- mplayerxp/libmpstream2/cdda.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libmpstream2/cdda.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -33,7 +33,7 @@ { NULL,NULL, 0, 0, 0, 0, NULL} }; -void cdda_register_options(m_config_t* cfg) { +void cdda_register_options(m_config_t& cfg) { m_config_register_options(cfg,cdda_conf); } Modified: mplayerxp/libplaytree/asxparser.cpp =================================================================== --- mplayerxp/libplaytree/asxparser.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libplaytree/asxparser.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -299,7 +299,7 @@ return; } val = cattribs.get("VALUE"); - if(m_config_get_option(mpxp_context().mconfig,name.c_str()) == NULL) { + if(m_config_get_option(*mpxp_context().mconfig,name.c_str()) == NULL) { MSG_WARN("Found unknow param in asx: %s",name.c_str()); if(!val.empty())MSG_WARN("=%s\n",val.c_str()); else MSG_WARN("\n"); Modified: mplayerxp/libplaytree/playtree.cpp =================================================================== --- mplayerxp/libplaytree/playtree.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libplaytree/playtree.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -442,7 +442,7 @@ play_tree_t* pt; #ifdef MP_DEBUG assert(iter != NULL); - assert(iter->config != NULL); + assert(*iter->config != NULL); assert(iter->tree != NULL); #endif @@ -450,7 +450,7 @@ // We always push a config because we can set some option // while playing - m_config_push(iter->config); + m_config_push(*iter->config); if(pt->params == NULL) return; @@ -458,7 +458,7 @@ for(n = 0; pt->params[n].name != NULL ; n++) { int e; - if((e = m_config_set_option(iter->config,pt->params[n].name,pt->params[n].value)) < 0) { + if((e = m_config_set_option(*iter->config,pt->params[n].name,pt->params[n].value)) < 0) { MSG_ERR("Error %d while setting option '%s' with value '%s'\n",e, pt->params[n].name,pt->params[n].value); } @@ -470,7 +470,7 @@ } play_tree_iter_t* -play_tree_iter_new(play_tree_t* pt,m_config_t* config) { +play_tree_iter_new(play_tree_t* pt,m_config_t& config) { play_tree_iter_t* iter; #ifdef MP_DEBUG @@ -485,7 +485,7 @@ if(! iter) return NULL; iter->root = pt; iter->tree = NULL; - iter->config = config; + iter->config = &config; if(pt->parent) iter->loop = pt->parent->loop; @@ -562,7 +562,7 @@ if(iter->config && iter->entry_pushed > 0) { iter->entry_pushed = 0; - m_config_pop(iter->config); + m_config_pop(*iter->config); } if(iter->tree->parent && (iter->tree->parent->flags & PLAY_TREE_RND)) @@ -712,7 +712,7 @@ // Pop subtree params if(iter->config) { - m_config_pop(iter->config); + m_config_pop(*iter->config); if(iter->mode == PLAY_TREE_ITER_RND) iter->tree->flags |= PLAY_TREE_RND_PLAYED; } @@ -759,9 +759,9 @@ // This is used as a file name for vcd/tv/dvd char playtree_ret_filename[256]; -char* +const char* play_tree_iter_get_file(play_tree_iter_t* iter, int d) { - char* entry; + const char* entry; #ifdef MP_DEBUG assert(iter != NULL); assert(iter->tree->child == NULL); @@ -794,22 +794,23 @@ case PLAY_TREE_ENTRY_DVD : if(strlen(entry) == 0) entry = "1"; if(iter->config) - m_config_set_option(iter->config,"dvd",entry); + m_config_set_option(*iter->config,"dvd",entry); snprintf(playtree_ret_filename,255,"DVD title %s",entry); return playtree_ret_filename; case PLAY_TREE_ENTRY_VCD : if(strlen(entry) == 0) entry = "1"; if(iter->config) - m_config_set_option(iter->config,"vcd",entry); + m_config_set_option(*iter->config,"vcd",entry); snprintf(playtree_ret_filename,255,"vcd://%s",entry); return playtree_ret_filename; case PLAY_TREE_ENTRY_TV : { if(strlen(entry) != 0) { - char *s,*e, *val = (char*)mp_malloc(strlen(entry) + 11 + 1); + char *s,*val = (char*)mp_malloc(strlen(entry) + 11 + 1); + const char* e; sprintf(val,"on:channel=%s",entry); if(iter->config) - m_config_set_option(iter->config,"tv",val); + m_config_set_option(*iter->config,"tv",val); s = playtree_ret_filename + sprintf(playtree_ret_filename,"TV channel "); e = strchr(entry,':'); if(!e) strncpy(s,entry,255-11); @@ -822,7 +823,7 @@ return playtree_ret_filename; } else { if(iter->config) - m_config_set_option(iter->config,"tv","on"); + m_config_set_option(*iter->config,"tv","on"); return "TV"; } } @@ -895,7 +896,7 @@ // HIGH Level API, by Fabian Franz (mp...@fa...) // -play_tree_iter_t* pt_iter_create(play_tree_t** ppt, m_config_t* config) +play_tree_iter_t* pt_iter_create(play_tree_t** ppt, m_config_t& config) { play_tree_iter_t* r=NULL; #ifdef MP_DEBUG @@ -925,10 +926,10 @@ } } -char* pt_iter_get_file(play_tree_iter_t* iter, int d) +const char* pt_iter_get_file(play_tree_iter_t* iter, int d) { int i=0; - char* r; + const char* r; if (iter==NULL) return NULL; Modified: mplayerxp/libplaytree/playtree.h =================================================================== --- mplayerxp/libplaytree/playtree.h 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/libplaytree/playtree.h 2012-12-13 13:52:35 UTC (rev 558) @@ -37,10 +37,6 @@ /// \defgroup Playtree ///@{ -typedef struct play_tree play_tree_t; -typedef struct play_tree_iter play_tree_iter_t; -typedef struct play_tree_param play_tree_param_t; - #include "libmpconf/cfgparser.h" #if 0 @@ -55,12 +51,12 @@ } #endif -struct play_tree_param { +struct play_tree_param_t { char* name; char* value; }; -struct play_tree { +struct play_tree_t { play_tree_t* parent; play_tree_t* child; play_tree_t* next; @@ -74,18 +70,18 @@ int flags; }; -struct play_tree_iter { - play_tree_t* root; // Iter root tree - play_tree_t* tree; // Current tree - m_config_t* config; - int loop; // Looping status - int file; - int num_files; - int entry_pushed; - int mode; +struct play_tree_iter_t { + play_tree_t* root; // Iter root tree + play_tree_t* tree; // Current tree + m_config_t* config; + int loop; // Looping status + int file; + int num_files; + int entry_pushed; + int mode; - int* status_stack; // loop/valid stack to save/revert status when we go up/down - int stack_size; // status stack size + int* status_stack; // loop/valid stack to save/revert status when we go up/down + int stack_size; // status stack size }; play_tree_t* play_tree_new(void); @@ -145,7 +141,7 @@ /// Iterator play_tree_iter_t* -play_tree_iter_new(play_tree_t* pt, m_config_t* config); +play_tree_iter_new(play_tree_t* pt, m_config_t& config); play_tree_iter_t* play_tree_iter_new_copy(play_tree_iter_t const* old); @@ -165,7 +161,7 @@ int // Enter a node child list play_tree_iter_down_step(play_tree_iter_t* iter, int d,int with_nodes); -char* play_tree_iter_get_file(play_tree_iter_t* iter, int d); +const char* play_tree_iter_get_file(play_tree_iter_t* iter, int d); play_tree_t* parse_playtree(libinput_t& libinput,Stream * stream); @@ -186,11 +182,11 @@ void pt_iter_destroy(play_tree_iter_t** iter); /// Gets the next available file in the direction (d=-1 || d=+1). -char* pt_iter_get_file(play_tree_iter_t* iter, int d); +const char* pt_iter_get_file(play_tree_iter_t* iter, int d); // Two Macros that implement forward and backward direction. -static inline char* pt_iter_get_next_file(play_tree_iter_t* iter) { return pt_iter_get_file(iter, 1); } -static inline char* pt_iter_get_prev_file(play_tree_iter_t* iter) { return pt_iter_get_file(iter, -1); } +static inline const char* pt_iter_get_next_file(play_tree_iter_t* iter) { return pt_iter_get_file(iter, 1); } +static inline const char* pt_iter_get_prev_file(play_tree_iter_t* iter) { return pt_iter_get_file(iter, -1); } /// Inserts entry into the playtree. void pt_iter_insert_entry(play_tree_iter_t* iter, play_tree_t* entry); Modified: mplayerxp/mplayerxp.cpp =================================================================== --- mplayerxp/mplayerxp.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/mplayerxp.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -38,6 +38,7 @@ #include "libmpdemux/demuxer.h" #include "libmpconf/codec-cfg.h" +#include "libplaytree/playtree.h" #include "libmpcodecs/dec_video.h" #include "libmpcodecs/dec_audio.h" @@ -426,7 +427,7 @@ //"nosound=nein" "\n"; -void parse_cfgfiles( m_config_t* conf ) +void parse_cfgfiles( m_config_t& conf ) { char *conffile; int conffile_fd; @@ -604,7 +605,7 @@ void show_long_help(void) { MPXPSystem& MPXPSys=*mpxp_context().engine().MPXPSys; - m_config_show_options(mpxp_context().mconfig); + m_config_show_options(*mpxp_context().mconfig); mp_input_print_binds(MPXPSys.libinput()); Stream::print_drivers(); mpxp_context().video().output->print_help(); @@ -1633,7 +1634,7 @@ int stream_dump_type=0; input_state_t input_state = { 0, 0, 0 }; char *ao_subdevice; - char* filename=NULL; //"MI2-Trailer.avi"; + const char* filename=NULL; //"MI2-Trailer.avi"; int file_format=Demuxer::Type_UNKNOWN; // movie info: @@ -1666,13 +1667,14 @@ MPXPSys.playtree = play_tree_new(); - mpxp_context().mconfig = m_config_new(MPXPSys.playtree,MPXPSys.libinput()); - m_config_register_options(mpxp_context().mconfig,mplayer_opts); + m_config_t& m_config=m_config_new(MPXPSys.playtree,MPXPSys.libinput()); + mpxp_context().mconfig = &m_config; + m_config_register_options(m_config,mplayer_opts); // TODO : add something to let modules register their options - mp_register_options(mpxp_context().mconfig); - parse_cfgfiles(mpxp_context().mconfig); + mp_register_options(m_config); + parse_cfgfiles(m_config); - if(m_config_parse_command_line(mpxp_context().mconfig, argc, argv, envp)!=MPXP_Ok) + if(m_config_parse_command_line(m_config, argc, argv, envp)!=MPXP_Ok) exit_player("Error parse command line"); // error parsing cmdline if(!mp_conf.xp) { @@ -1695,7 +1697,7 @@ MPXPSys.playtree = play_tree_cleanup(MPXPSys.playtree); if(MPXPSys.playtree) { - playtree_iter = play_tree_iter_new(MPXPSys.playtree,mpxp_context().mconfig); + playtree_iter = play_tree_iter_new(MPXPSys.playtree,m_config); if(playtree_iter) { if(play_tree_iter_step(playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY) { play_tree_iter_free(playtree_iter); Modified: mplayerxp/mplayerxp.h =================================================================== --- mplayerxp/mplayerxp.h 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/mplayerxp.h 2012-12-13 13:52:35 UTC (rev 558) @@ -17,6 +17,7 @@ struct audio_decoder_t; struct video_decoder_t; +struct play_tree_iter_t; namespace mpxp { /* List of all modules which require protection by pin-code */ enum { @@ -225,7 +226,7 @@ void mplayer_put_key(int code); - void mp_register_options(m_config_t* cfg); + void mp_register_options(m_config_t& cfg); extern play_tree_iter_t* playtree_iter; } Modified: mplayerxp/xmpcore/xmp_context.cpp =================================================================== --- mplayerxp/xmpcore/xmp_context.cpp 2012-12-13 11:45:25 UTC (rev 557) +++ mplayerxp/xmpcore/xmp_context.cpp 2012-12-13 13:52:35 UTC (rev 558) @@ -272,17 +272,17 @@ const config_t* mplayer_opts=mplayer_options; } // namespace mpxp -extern void libmpcodecs_ad_register_options(m_config_t* cfg); -extern void libmpcodecs_vd_register_options(m_config_t* cfg); +extern void libmpcodecs_ad_register_options(m_config_t& cfg); +extern void libmpcodecs_vd_register_options(m_config_t& cfg); namespace mpxp { #ifdef HAVE_LIBCDIO -extern void cdda_register_options(m_config_t* cfg); +extern void cdda_register_options(m_config_t& cfg); #endif -extern void mp_input_register_options(m_config_t* cfg); -extern void libmpdemux_register_options(m_config_t* cfg); -extern void demuxer_register_options(m_config_t* cfg); -void mp_register_options(m_config_t* cfg) +extern void mp_input_register_options(m_config_t& cfg); +extern void libmpdemux_register_options(m_config_t& cfg); +extern void demuxer_register_options(m_config_t& cfg); +void mp_register_options(m_config_t& cfg) { mp_input_register_options(cfg); libmpdemux_register_options(cfg); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |