mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
options: remove some unneeded stuff
No options pointing to global variables are in use anymore, so that part can be removed.
This commit is contained in:
@@ -323,8 +323,6 @@ static void add_negation_option(struct m_config *config,
|
|||||||
.name = opt->name,
|
.name = opt->name,
|
||||||
.type = CONF_TYPE_STORE,
|
.type = CONF_TYPE_STORE,
|
||||||
.flags = opt->flags & (M_OPT_NOCFG | M_OPT_GLOBAL | M_OPT_PRE_PARSE),
|
.flags = opt->flags & (M_OPT_NOCFG | M_OPT_GLOBAL | M_OPT_PRE_PARSE),
|
||||||
.is_new_option = opt->is_new_option,
|
|
||||||
.p = opt->p,
|
|
||||||
.offset = opt->offset,
|
.offset = opt->offset,
|
||||||
.max = value,
|
.max = value,
|
||||||
};
|
};
|
||||||
@@ -371,14 +369,11 @@ static void m_config_add_option(struct m_config *config,
|
|||||||
.name = arg->name,
|
.name = arg->name,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (arg->is_new_option) {
|
if (arg->offset >= 0) {
|
||||||
if (optstruct)
|
if (optstruct)
|
||||||
co.data = (char *)optstruct + arg->offset;
|
co.data = (char *)optstruct + arg->offset;
|
||||||
if (optstruct_def)
|
if (optstruct_def)
|
||||||
co.default_data = (char *)optstruct_def + arg->offset;
|
co.default_data = (char *)optstruct_def + arg->offset;
|
||||||
} else {
|
|
||||||
co.data = arg->p;
|
|
||||||
co.default_data = arg->p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg->defval)
|
if (arg->defval)
|
||||||
@@ -412,7 +407,7 @@ static void m_config_add_option(struct m_config *config,
|
|||||||
add_options(config, co.name, new_optstruct,
|
add_options(config, co.name, new_optstruct,
|
||||||
new_optstruct_def, subopts->opts);
|
new_optstruct_def, subopts->opts);
|
||||||
} else {
|
} else {
|
||||||
const struct m_option *sub = arg->p;
|
const struct m_option *sub = arg->priv;
|
||||||
add_options(config, co.name, optstruct, optstruct_def, sub);
|
add_options(config, co.name, optstruct, optstruct_def, sub);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -307,15 +307,14 @@ struct m_option {
|
|||||||
// Option name.
|
// Option name.
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
// Deprecated field for "old" options which mutate global state.
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
// Option type.
|
// Option type.
|
||||||
const m_option_type_t *type;
|
const m_option_type_t *type;
|
||||||
|
|
||||||
// See \ref OptionFlags.
|
// See \ref OptionFlags.
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
|
||||||
|
int offset;
|
||||||
|
|
||||||
// \brief Mostly useful for numeric types, the \ref M_OPT_MIN flags must
|
// \brief Mostly useful for numeric types, the \ref M_OPT_MIN flags must
|
||||||
// also be set.
|
// also be set.
|
||||||
double min;
|
double min;
|
||||||
@@ -327,10 +326,6 @@ struct m_option {
|
|||||||
// Type dependent data (for all kinds of extended settings).
|
// Type dependent data (for all kinds of extended settings).
|
||||||
void *priv;
|
void *priv;
|
||||||
|
|
||||||
int is_new_option;
|
|
||||||
|
|
||||||
int offset;
|
|
||||||
|
|
||||||
// Initialize variable to given default before parsing options
|
// Initialize variable to given default before parsing options
|
||||||
const void *defval;
|
const void *defval;
|
||||||
};
|
};
|
||||||
@@ -538,12 +533,12 @@ extern const char m_option_path_separator;
|
|||||||
#define OPTDEF_DOUBLE(d) .defval = (void *)&(const double){d}
|
#define OPTDEF_DOUBLE(d) .defval = (void *)&(const double){d}
|
||||||
|
|
||||||
#define OPT_GENERAL(ctype, optname, varname, flagv, ...) \
|
#define OPT_GENERAL(ctype, optname, varname, flagv, ...) \
|
||||||
{.name = optname, .flags = flagv, .is_new_option = 1, \
|
{.name = optname, .flags = flagv, \
|
||||||
.offset = MP_CHECKED_OFFSETOF(OPT_BASE_STRUCT, varname, ctype), \
|
.offset = MP_CHECKED_OFFSETOF(OPT_BASE_STRUCT, varname, ctype), \
|
||||||
__VA_ARGS__}
|
__VA_ARGS__}
|
||||||
|
|
||||||
#define OPT_GENERAL_NOTYPE(optname, varname, flagv, ...) \
|
#define OPT_GENERAL_NOTYPE(optname, varname, flagv, ...) \
|
||||||
{.name = optname, .flags = flagv, .is_new_option = 1, \
|
{.name = optname, .flags = flagv, \
|
||||||
.offset = offsetof(OPT_BASE_STRUCT, varname), \
|
.offset = offsetof(OPT_BASE_STRUCT, varname), \
|
||||||
__VA_ARGS__}
|
__VA_ARGS__}
|
||||||
|
|
||||||
@@ -669,7 +664,8 @@ extern const char m_option_path_separator;
|
|||||||
{.name = optname, \
|
{.name = optname, \
|
||||||
.flags = M_OPT_FIXED | M_OPT_GLOBAL | M_OPT_NOCFG | M_OPT_PRE_PARSE, \
|
.flags = M_OPT_FIXED | M_OPT_GLOBAL | M_OPT_NOCFG | M_OPT_PRE_PARSE, \
|
||||||
.type = &m_option_type_print_fn, \
|
.type = &m_option_type_print_fn, \
|
||||||
.priv = MP_EXPECT_TYPE(m_opt_print_fn, fn)}
|
.priv = MP_EXPECT_TYPE(m_opt_print_fn, fn), \
|
||||||
|
.offset = -1}
|
||||||
|
|
||||||
// subconf must have the type struct m_sub_options.
|
// subconf must have the type struct m_sub_options.
|
||||||
// All sub-options are prefixed with "name-" and are added to the current
|
// All sub-options are prefixed with "name-" and are added to the current
|
||||||
|
|||||||
@@ -88,20 +88,21 @@ static const m_option_t screenshot_conf[] = {
|
|||||||
|
|
||||||
const m_option_t mp_opts[] = {
|
const m_option_t mp_opts[] = {
|
||||||
// handled in command line pre-parser (parse_commandline.c)
|
// handled in command line pre-parser (parse_commandline.c)
|
||||||
{"v", NULL, CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG, 0, 0, NULL},
|
{"v", CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG, .offset = -1},
|
||||||
{"playlist", NULL, CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN | M_OPT_FIXED,
|
{"playlist", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN | M_OPT_FIXED,
|
||||||
1, 0, NULL},
|
.min = 1, .offset = -1},
|
||||||
{"{", NULL, CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, 0, 0, NULL},
|
{"{", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
|
||||||
{"}", NULL, CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, 0, 0, NULL},
|
{"}", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
|
||||||
|
|
||||||
// handled in m_config.c
|
// handled in m_config.c
|
||||||
{ "include", NULL, CONF_TYPE_STRING, M_OPT_FIXED },
|
{ "include", CONF_TYPE_STRING, M_OPT_FIXED, .offset = -1},
|
||||||
{ "profile", NULL, CONF_TYPE_STRING_LIST, M_OPT_FIXED },
|
{ "profile", CONF_TYPE_STRING_LIST, M_OPT_FIXED, .offset = -1},
|
||||||
{ "show-profile", NULL, CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED },
|
{ "show-profile", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
|
||||||
{ "list-options", NULL, CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED },
|
{ "list-options", CONF_TYPE_STORE, CONF_NOCFG | M_OPT_FIXED, .offset = -1},
|
||||||
|
|
||||||
// handled in main.c (looks at the raw argv[])
|
// handled in main.c (looks at the raw argv[])
|
||||||
{"leak-report", NULL, CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG | M_OPT_FIXED },
|
{ "leak-report", CONF_TYPE_STORE, CONF_GLOBAL | CONF_NOCFG | M_OPT_FIXED,
|
||||||
|
.offset = -1 },
|
||||||
|
|
||||||
OPT_FLAG("shuffle", shuffle, CONF_GLOBAL | CONF_NOCFG),
|
OPT_FLAG("shuffle", shuffle, CONF_GLOBAL | CONF_NOCFG),
|
||||||
|
|
||||||
@@ -501,7 +502,8 @@ const m_option_t mp_opts[] = {
|
|||||||
OPT_FLAG("input-terminal", consolecontrols, CONF_GLOBAL),
|
OPT_FLAG("input-terminal", consolecontrols, CONF_GLOBAL),
|
||||||
OPT_FLAG("input-cursor", vo.enable_mouse_movements, CONF_GLOBAL),
|
OPT_FLAG("input-cursor", vo.enable_mouse_movements, CONF_GLOBAL),
|
||||||
|
|
||||||
{"screenshot", (void *) screenshot_conf, CONF_TYPE_SUBCONFIG},
|
{"screenshot", CONF_TYPE_SUBCONFIG, .priv = (void *)screenshot_conf,
|
||||||
|
.offset = -1},
|
||||||
|
|
||||||
OPT_SUBSTRUCT("input", input_opts, input_config, 0),
|
OPT_SUBSTRUCT("input", input_opts, input_config, 0),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user