diff options
Diffstat (limited to 'options')
-rw-r--r-- | options/m_config_core.c | 58 | ||||
-rw-r--r-- | options/m_config_frontend.c | 1 | ||||
-rw-r--r-- | options/m_option.c | 15 | ||||
-rw-r--r-- | options/m_option.h | 5 | ||||
-rw-r--r-- | options/options.c | 16 | ||||
-rw-r--r-- | options/options.h | 3 | ||||
-rw-r--r-- | options/path.c | 1 |
7 files changed, 74 insertions, 25 deletions
diff --git a/options/m_config_core.c b/options/m_config_core.c index 08a76eb76d..2c9979688a 100644 --- a/options/m_config_core.c +++ b/options/m_config_core.c @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <strings.h> #include "common/common.h" #include "common/global.h" @@ -99,10 +98,17 @@ struct config_cache { void *wakeup_cb_ctx; }; +struct force_update { + char *name; + uint64_t ts; +}; + // Per m_config_data state for each m_config_group. struct m_group_data { - char *udata; // pointer to group user option struct - uint64_t ts; // timestamp of the data copy + char *udata; // pointer to group user option struct + uint64_t ts; // timestamp of the data copy + struct force_update **force_update; // tracks opts that are written with force update + int force_update_len; }; static void add_sub_group(struct m_config_shadow *shadow, const char *name_prefix, @@ -588,6 +594,34 @@ struct m_config_cache *m_config_cache_alloc(void *ta_parent, return m_config_cache_from_shadow(ta_parent, global->config, group); } +static void append_force_update(struct m_config_cache *cache, struct m_group_data *gdata, + const char *opt_name) +{ + for (int i = 0; i < gdata->force_update_len; ++i) { + if (strcmp(opt_name, gdata->force_update[i]->name) == 0) { + gdata->force_update[i]->ts = gdata->ts; + return; + } + } + struct force_update *new_update = talloc_zero(cache, struct force_update); + new_update->name = talloc_strdup(cache, opt_name); + new_update->ts = gdata->ts; + MP_TARRAY_APPEND(cache, gdata->force_update, gdata->force_update_len, new_update); +} + +static bool check_force_update(struct m_group_data *gdata, const char *opt_name, + uint64_t timestamp) +{ + for (int i = 0; i < gdata->force_update_len; ++i) { + if ((strcmp(opt_name, gdata->force_update[i]->name) == 0) && + gdata->force_update[i]->ts == timestamp) + { + return true; + } + } + return false; +} + static void update_next_option(struct m_config_cache *cache, void **p_opt) { struct config_cache *in = cache->internal; @@ -609,16 +643,18 @@ static void update_next_option(struct m_config_cache *cache, void **p_opt) while (opts && opts[in->upd_opt].name) { const struct m_option *opt = &opts[in->upd_opt]; + void *dsrc = gsrc->udata + opt->offset; + void *ddst = gdst->udata + opt->offset; if (opt->offset >= 0 && opt->type->size) { - void *dsrc = gsrc->udata + opt->offset; - void *ddst = gdst->udata + opt->offset; - - if (!m_option_equal(opt, ddst, dsrc)) { + bool opt_equal = m_option_equal(opt, ddst, dsrc); + bool force_update = opt->force_update && + check_force_update(gsrc, opt->name, in->ts); + if (!opt_equal || force_update) { uint64_t ch = get_opt_change_mask(dst->shadow, in->upd_group, dst->group_index, opt); - if (cache->debug) { + if (cache->debug && !opt_equal) { char *vdst = m_option_print(opt, ddst); char *vsrc = m_option_print(opt, dsrc); mp_warn(cache->debug, "Option '%s' changed from " @@ -750,7 +786,8 @@ bool m_config_cache_write_opt(struct m_config_cache *cache, void *ptr) struct m_group_data *gsrc = m_config_gdata(in->src, group_idx); assert(gdst && gsrc); - bool changed = !m_option_equal(opt, gsrc->udata + opt->offset, ptr); + bool changed = !m_option_equal(opt, gsrc->udata + opt->offset, ptr) || + opt->force_update; if (changed) { m_option_copy(opt, gsrc->udata + opt->offset, ptr); @@ -763,6 +800,9 @@ bool m_config_cache_write_opt(struct m_config_cache *cache, void *ptr) } } + if (opt->force_update) + append_force_update(cache, gsrc, opt->name); + mp_mutex_unlock(&shadow->lock); return changed; diff --git a/options/m_config_frontend.c b/options/m_config_frontend.c index d800cdb75d..6f0aa22d3b 100644 --- a/options/m_config_frontend.c +++ b/options/m_config_frontend.c @@ -23,7 +23,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <strings.h> #include "libmpv/client.h" diff --git a/options/m_option.c b/options/m_option.c index 4646510f21..b4bf68fee4 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -28,7 +28,6 @@ #include <stdarg.h> #include <limits.h> #include <inttypes.h> -#include <unistd.h> #include <assert.h> #include <libavutil/common.h> @@ -3166,7 +3165,7 @@ print_help: ; } else if (list->print_unknown_entry_help) { list->print_unknown_entry_help(log, mp_tprintf(80, "%.*s", BSTR_P(name))); } else { - mp_warn(log, "Option %.*s: item %.*s doesn't exist.\n", + mp_warn(log, "Option %.*s: item '%.*s' isn't supported.\n", BSTR_P(opt_name), BSTR_P(name)); } r = M_OPT_EXIT; @@ -3221,7 +3220,7 @@ static int parse_obj_settings(struct mp_log *log, struct bstr opt, int op, int idx = bstrspn(*pstr, NAMECH); str = bstr_splice(*pstr, 0, idx); if (!str.len) { - mp_err(log, "Option %.*s: filter name expected.\n", BSTR_P(opt)); + mp_err(log, "Option %.*s: item name expected.\n", BSTR_P(opt)); return M_OPT_INVALID; } *pstr = bstr_cut(*pstr, idx); @@ -3238,7 +3237,7 @@ static int parse_obj_settings(struct mp_log *log, struct bstr opt, int op, char name[80]; snprintf(name, sizeof(name), "%.*s", BSTR_P(str)); if (list->check_unknown_entry && !list->check_unknown_entry(name)) { - mp_err(log, "Option %.*s: %.*s doesn't exist.\n", + mp_err(log, "Option %.*s: '%.*s' isn't supported.\n", BSTR_P(opt), BSTR_P(str)); return M_OPT_INVALID; } @@ -3332,15 +3331,15 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, " %s-set\n" " Overwrite the old list with the given list\n\n" " %s-append\n" - " Append the given filter to the current list\n\n" + " Append the given item to the current list\n\n" " %s-add\n" " Append the given list to the current list\n\n" " %s-pre\n" " Prepend the given list to the current list\n\n" " %s-remove\n" - " Remove the given filter from the current list\n\n" + " Remove the given item from the current list\n\n" " %s-toggle\n" - " Add the filter to the list, or remove it if it's already added.\n\n" + " Add the item to the list, or remove it if it's already added.\n\n" " %s-clr\n" " Clear the current list.\n\n", opt->name, opt->name, opt->name, opt->name, opt->name, @@ -3420,7 +3419,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, if (op != OP_NONE && res && res[0].name && res[1].name) { if (op == OP_APPEND) { - mp_err(log, "Option %.*s: -append takes only 1 filter (no ',').\n", + mp_err(log, "Option %.*s: -append takes only 1 item (no ',').\n", BSTR_P(name)); free_obj_settings_list(&res); return M_OPT_INVALID; diff --git a/options/m_option.h b/options/m_option.h index 530c0a3d50..9a5058ccaf 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -161,6 +161,8 @@ struct m_obj_list { void (*print_help_list)(struct mp_log *log); // Callback to print help for _unknown_ entries with "vf=entry=help" void (*print_unknown_entry_help)(struct mp_log *log, const char *name); + // Get lavfi filters for option-info/[av]f/choices. + const char **(*get_lavfi_filters)(void *talloc_ctx); }; // Find entry by name @@ -384,6 +386,9 @@ struct m_option { // See \ref OptionFlags. unsigned int flags; + // Always force an option update even if the written value does not change. + bool force_update; + int offset; // Most numeric types restrict the range to [min, max] if min<max (this diff --git a/options/options.c b/options/options.c index 8640ecb27f..4415ed8145 100644 --- a/options/options.c +++ b/options/options.c @@ -123,12 +123,12 @@ static const m_option_t mp_vo_opt_list[] = { {"border", OPT_BOOL(border)}, {"title-bar", OPT_BOOL(title_bar)}, {"on-all-workspaces", OPT_BOOL(all_workspaces)}, - {"geometry", OPT_GEOMETRY(geometry)}, - {"autofit", OPT_SIZE_BOX(autofit)}, - {"autofit-larger", OPT_SIZE_BOX(autofit_larger)}, - {"autofit-smaller", OPT_SIZE_BOX(autofit_smaller)}, + {"geometry", OPT_GEOMETRY(geometry), .force_update = true}, + {"autofit", OPT_SIZE_BOX(autofit), .force_update = true}, + {"autofit-larger", OPT_SIZE_BOX(autofit_larger), .force_update = true}, + {"autofit-smaller", OPT_SIZE_BOX(autofit_smaller), .force_update = true}, {"auto-window-resize", OPT_BOOL(auto_window_resize)}, - {"window-scale", OPT_DOUBLE(window_scale), M_RANGE(0.001, 100)}, + {"window-scale", OPT_DOUBLE(window_scale), M_RANGE(0.001, 100), .force_update = true}, {"window-minimized", OPT_BOOL(window_minimized)}, {"window-maximized", OPT_BOOL(window_maximized)}, {"focus-on-open", OPT_REMOVED("Replaced by --focus-on")}, @@ -169,6 +169,8 @@ static const m_option_t mp_vo_opt_list[] = { {"keepaspect-window", OPT_BOOL(keepaspect_window)}, {"hidpi-window-scale", OPT_BOOL(hidpi_window_scale)}, {"native-fs", OPT_BOOL(native_fs)}, + {"native-touch", OPT_BOOL(native_touch)}, + {"show-in-taskbar", OPT_BOOL(show_in_taskbar)}, {"display-fps-override", OPT_DOUBLE(display_fps_override), M_RANGE(0, DBL_MAX)}, {"video-timing-offset", OPT_DOUBLE(timing_offset), M_RANGE(0.0, 1.0)}, @@ -243,6 +245,7 @@ const struct m_sub_options vo_sub_opts = { .keepaspect_window = true, .native_fs = true, .taskbar_progress = true, + .show_in_taskbar = true, .border = true, .title_bar = true, .appid = "mpv", @@ -307,6 +310,7 @@ const struct m_sub_options mp_subtitle_sub_opts = { {"sub-ass-vsfilter-color-compat", OPT_CHOICE(ass_vsfilter_color_compat, {"no", 0}, {"basic", 1}, {"full", 2}, {"force-601", 3})}, {"sub-ass-vsfilter-blur-compat", OPT_BOOL(ass_vsfilter_blur_compat)}, + {"sub-vsfilter-bidi-compat", OPT_BOOL(sub_vsfilter_bidi_compat)}, {"embeddedfonts", OPT_BOOL(use_embedded_fonts), .flags = UPDATE_SUB_HARD}, {"sub-ass-style-overrides", OPT_STRINGLIST(ass_style_override_list), .flags = UPDATE_SUB_HARD}, @@ -322,7 +326,7 @@ const struct m_sub_options mp_subtitle_sub_opts = { {"sub-ass-scale-with-window", OPT_BOOL(ass_scale_with_window)}, {"sub", OPT_SUBSTRUCT(sub_style, sub_style_conf)}, {"sub-clear-on-seek", OPT_BOOL(sub_clear_on_seek)}, - {"teletext-page", OPT_INT(teletext_page), M_RANGE(-1, 999)}, + {"teletext-page", OPT_INT(teletext_page), M_RANGE(-1, 999), .flags = UPDATE_SUB_FILT}, {"sub-past-video-end", OPT_BOOL(sub_past_video_end)}, {"sub-ass-force-style", OPT_REPLACED("sub-ass-style-overrides")}, {"sub-lavc-o", OPT_KEYVALUELIST(sub_avopts)}, diff --git a/options/options.h b/options/options.h index 69a50b3350..6733fa3161 100644 --- a/options/options.h +++ b/options/options.h @@ -56,6 +56,8 @@ typedef struct mp_vo_opts { bool keepaspect_window; bool hidpi_window_scale; bool native_fs; + bool native_touch; + bool show_in_taskbar; int64_t WinID; @@ -104,6 +106,7 @@ struct mp_subtitle_opts { bool ass_vsfilter_aspect_compat; int ass_vsfilter_color_compat; bool ass_vsfilter_blur_compat; + bool sub_vsfilter_bidi_compat; bool use_embedded_fonts; char **ass_style_override_list; char *ass_styles_file; diff --git a/options/path.c b/options/path.c index 7c7d31c02f..ab6f30f51c 100644 --- a/options/path.c +++ b/options/path.c @@ -24,7 +24,6 @@ #include <stdbool.h> #include <sys/types.h> #include <sys/stat.h> -#include <unistd.h> #include <errno.h> #include "config.h" |