summaryrefslogtreecommitdiffstats
path: root/options/m_option.c
diff options
context:
space:
mode:
Diffstat (limited to 'options/m_option.c')
-rw-r--r--options/m_option.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/options/m_option.c b/options/m_option.c
index 9f2d8758d0..b7b76634f8 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -106,6 +106,21 @@ const m_option_t *m_option_list_find(const m_option_t *list, const char *name)
return m_option_list_findb(list, bstr0(name));
}
+int m_option_set_node_or_string(struct mp_log *log, const m_option_t *opt,
+ const char *name, void *dst, struct mpv_node *src)
+{
+ if (src->format == MPV_FORMAT_STRING) {
+ // The af and vf option unfortunately require this, because the
+ // option name includes the "action".
+ bstr optname = bstr0(name), a, b;
+ if (bstr_split_tok(optname, "/", &a, &b))
+ optname = b;
+ return m_option_parse(log, opt, optname, bstr0(src->u.string), dst);
+ } else {
+ return m_option_set_node(opt, dst, src);
+ }
+}
+
// Default function that just does a memcpy
static void copy_opt(const m_option_t *opt, void *dst, const void *src)
@@ -657,6 +672,8 @@ static int choice_set(const m_option_t *opt, void *dst, struct mpv_node *src)
src_str = buf;
} else if (src->format == MPV_FORMAT_STRING) {
src_str = src->u.string;
+ } else if (src->format == MPV_FORMAT_FLAG) {
+ src_str = src->u.flag ? "yes" : "no";
}
if (!src_str)
return M_OPT_UNKNOWN;
@@ -698,8 +715,19 @@ static int choice_get(const m_option_t *opt, void *ta_parent,
alt = NULL;
}
if (alt) {
- dst->format = MPV_FORMAT_STRING;
- dst->u.string = talloc_strdup(ta_parent, alt->name);
+ int b = -1;
+ if (strcmp(alt->name, "yes") == 0) {
+ b = 1;
+ } else if (strcmp(alt->name, "no") == 0) {
+ b = 0;
+ }
+ if (b >= 0) {
+ dst->format = MPV_FORMAT_FLAG;
+ dst->u.flag = b;
+ } else {
+ dst->format = MPV_FORMAT_STRING;
+ dst->u.string = talloc_strdup(ta_parent, alt->name);
+ }
} else {
dst->format = MPV_FORMAT_INT64;
dst->u.int64 = ival;
@@ -1654,7 +1682,7 @@ static int parse_msglevels(struct mp_log *log, const m_option_t *opt,
struct bstr name, struct bstr param, void *dst)
{
if (bstr_equals0(param, "help")) {
- mp_info(log, "Syntax: --msglevel=module1=level:module2=level:...\n"
+ mp_info(log, "Syntax:\n\n --msglevel=module1=level,module2=level,...\n\n"
"'module' is output prefix as shown with -v, or a prefix\n"
"of it. level is one of:\n\n"
" fatal error warn info status v debug trace\n\n"
@@ -2061,6 +2089,10 @@ void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh,
} else if (!(gm->w > 0) && gm->h > 0) {
*widw = *widh * asp;
}
+ // Center window after resize. If valid x:y values are passed to
+ // geometry, then those values will be overriden.
+ *xpos += prew / 2 - *widw / 2;
+ *ypos += preh / 2 - *widh / 2;
}
if (gm->xy_valid) {
@@ -2287,10 +2319,18 @@ static int parse_chmap(struct mp_log *log, const m_option_t *opt,
return 1;
}
+static char *print_chmap(const m_option_t *opt, const void *val)
+{
+ const struct mp_chmap *chmap = val;
+ return talloc_strdup(NULL, mp_chmap_to_str(chmap));
+}
+
+
const m_option_type_t m_option_type_chmap = {
.name = "Audio channels or channel map",
.size = sizeof(struct mp_chmap),
.parse = parse_chmap,
+ .print = print_chmap,
.copy = copy_opt,
};