mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
player: more option/property consistency fixes
Some properties had a different type from their equivalent options (such as mute, volume, deinterlace, edition). This wasn't really sane, as raw option values should be always within their bounds. On the other hand, these properties use a different type to reflect runtime limits (such as range of available editions), or simply to improve the "UI" (you don't want to cycle throuhg the completely useless "auto" value when cycling the "mute" property). Handle this by making them always return the option type, but also allowing them to provide a "constricted" type, which is used for UI purposes. All M_PROPERTY_GET_CONSTRICTED_TYPE changes are related to this. One consequence is that you can set the volume property to arbitrary high values just like with the --volume option, but using the "add" command it still restricts it to the --volume-max range. Also deprecate --chapter, as it is grossly incompatible to the chapter property. We pondered renaming it to --chapters, or introducing a more powerful --range option, but concluded that --start --end is actually enough. These changes appear to take care of the last gross property/option incompatibilities, although there might still be a few lurking.
This commit is contained in:
@@ -87,9 +87,6 @@ struct m_opt_backup {
|
||||
void *backup;
|
||||
};
|
||||
|
||||
static struct m_config_option *m_config_get_co_raw(const struct m_config *config,
|
||||
struct bstr name);
|
||||
|
||||
static int parse_include(struct m_config *config, struct bstr param, bool set,
|
||||
int flags)
|
||||
{
|
||||
@@ -556,8 +553,8 @@ static void m_config_add_option(struct m_config *config,
|
||||
MP_TARRAY_APPEND(config, config->opts, config->num_opts, co);
|
||||
}
|
||||
|
||||
static struct m_config_option *m_config_get_co_raw(const struct m_config *config,
|
||||
struct bstr name)
|
||||
struct m_config_option *m_config_get_co_raw(const struct m_config *config,
|
||||
struct bstr name)
|
||||
{
|
||||
if (!name.len)
|
||||
return NULL;
|
||||
|
||||
@@ -190,6 +190,8 @@ int m_config_set_option_node(struct m_config *config, bstr name,
|
||||
int m_config_parse_suboptions(struct m_config *config, char *name,
|
||||
char *subopts);
|
||||
|
||||
struct m_config_option *m_config_get_co_raw(const struct m_config *config,
|
||||
struct bstr name);
|
||||
struct m_config_option *m_config_get_co(const struct m_config *config,
|
||||
struct bstr name);
|
||||
|
||||
|
||||
@@ -115,6 +115,10 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list,
|
||||
M_PROPERTY_NOT_IMPLEMENTED)
|
||||
return r;
|
||||
// Fallback to m_option
|
||||
r = do_action(prop_list, name, M_PROPERTY_GET_CONSTRICTED_TYPE, &opt, ctx);
|
||||
if (r <= 0)
|
||||
return r;
|
||||
assert(opt.type);
|
||||
if (!opt.type->add)
|
||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||
if ((r = do_action(prop_list, name, M_PROPERTY_GET, &val, ctx)) <= 0)
|
||||
@@ -124,6 +128,13 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list,
|
||||
m_option_free(&opt, &val);
|
||||
return r;
|
||||
}
|
||||
case M_PROPERTY_GET_CONSTRICTED_TYPE: {
|
||||
if ((r = do_action(prop_list, name, action, arg, ctx)) >= 0)
|
||||
return r;
|
||||
if ((r = do_action(prop_list, name, M_PROPERTY_GET_TYPE, arg, ctx)) >= 0)
|
||||
return r;
|
||||
return M_PROPERTY_NOT_IMPLEMENTED;
|
||||
}
|
||||
case M_PROPERTY_SET: {
|
||||
return do_action(prop_list, name, M_PROPERTY_SET, arg, ctx);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ enum mp_property_action {
|
||||
// arg: char**
|
||||
M_PROPERTY_PRINT,
|
||||
|
||||
// Like M_PROPERTY_GET_TYPE, but get a type that is compatible to the real
|
||||
// type, but reflect practical limits, such as runtime-available values.
|
||||
// This is mostly used for "UI" related things.
|
||||
// (Example: volume property.)
|
||||
M_PROPERTY_GET_CONSTRICTED_TYPE,
|
||||
|
||||
// Switch the property up/down by a given value.
|
||||
// If unimplemented, the property wrapper uses the property type as
|
||||
// fallback.
|
||||
|
||||
@@ -296,7 +296,8 @@ const m_option_t mp_opts[] = {
|
||||
#if HAVE_DVDREAD || HAVE_DVDNAV
|
||||
OPT_SUBSTRUCT("", dvd_opts, dvd_conf, 0),
|
||||
#endif /* HAVE_DVDREAD */
|
||||
OPT_INTPAIR("chapter", chapterrange, 0),
|
||||
OPT_INTPAIR("chapter", chapterrange, 0, .deprecation_message = "instead of "
|
||||
"--chapter=A-B use --start=#A --end=#B+1"),
|
||||
OPT_CHOICE_OR_INT("edition", edition_id, 0, 0, 8190,
|
||||
({"auto", -1})),
|
||||
#if HAVE_LIBBLURAY
|
||||
|
||||
Reference in New Issue
Block a user