From 1d1d1fbff9648e9adf7acf571514abf618ffc40f Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Wed, 21 Jul 2021 11:06:41 +0200 Subject: options: add watch-later-options This allows configuring which options are saved by quit-watch-later. Fixes #4126, #4641 and #5567. Toggling a video or audio filter twice would treat the option as changed because the backup value is NULL, and the current value of vf/af is a list with one empty item, so obj_settings_list_equal had to be changed. --- player/configfiles.c | 88 +++++++++------------------------------------------- 1 file changed, 14 insertions(+), 74 deletions(-) (limited to 'player/configfiles.c') diff --git a/player/configfiles.c b/player/configfiles.c index 83aed38d27..65dd9df425 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -37,6 +37,7 @@ #include "misc/ctype.h" #include "options/path.h" #include "options/m_config.h" +#include "options/m_config_frontend.h" #include "options/parse_configfile.h" #include "common/playlist.h" #include "options/options.h" @@ -237,63 +238,6 @@ exit: return res; } -static const char *const backup_properties[] = { - "osd-level", - //"loop", - "speed", - "options/edition", - "pause", - "volume", - "mute", - "audio-delay", - //"balance", - "fullscreen", - "ontop", - "border", - "gamma", - "brightness", - "contrast", - "saturation", - "hue", - "options/deinterlace", - "vf", - "af", - "panscan", - "options/aid", - "options/vid", - "options/sid", - "sub-delay", - "sub-speed", - "sub-pos", - "sub-visibility", - "sub-scale", - "sub-use-margins", - "sub-ass-force-margins", - "sub-ass-vsfilter-aspect-compat", - "sub-ass-override", - "ab-loop-a", - "ab-loop-b", - "options/video-aspect-override", - 0 -}; - -// Used to retrieve default settings, which should not be stored in the -// resume config. Uses backup_properties[] meaning/order of values. -// This explicitly includes values set by config files and command line. -void mp_get_resume_defaults(struct MPContext *mpctx) -{ - char **list = - talloc_zero_array(mpctx, char*, MP_ARRAY_SIZE(backup_properties)); - for (int i = 0; backup_properties[i]; i++) { - const char *pname = backup_properties[i]; - char *val = NULL; - int r = mp_property_do(pname, M_PROPERTY_GET_STRING, &val, mpctx); - if (r == M_PROPERTY_OK) - list[i] = talloc_steal(list, val); - } - mpctx->resume_defaults = list; -} - // Should follow what parser-cfg.c does/needs static bool needs_config_quoting(const char *s) { @@ -368,25 +312,21 @@ void mp_write_watch_later_conf(struct MPContext *mpctx) } else { fprintf(file, "start=%f\n", pos); } - for (int i = 0; backup_properties[i]; i++) { - const char *pname = backup_properties[i]; - char *val = NULL; - int r = mp_property_do(pname, M_PROPERTY_GET_STRING, &val, mpctx); - if (r == M_PROPERTY_OK) { - if (strncmp(pname, "options/", 8) == 0) - pname += 8; - // Only store it if it's different from the initial value. - char *prev = mpctx->resume_defaults[i]; - if (!prev || strcmp(prev, val) != 0) { - if (needs_config_quoting(val)) { - // e.g. '%6%STRING' - fprintf(file, "%s=%%%d%%%s\n", pname, (int)strlen(val), val); - } else { - fprintf(file, "%s=%s\n", pname, val); - } + char **watch_later_options = mpctx->opts->watch_later_options; + for (int i = 0; watch_later_options && watch_later_options[i]; i++) { + char *pname = watch_later_options[i]; + // Only store it if it's different from the initial value. + if (m_config_watch_later_backup_opt_changed(mpctx->mconfig, pname)) { + char *val = NULL; + mp_property_do(pname, M_PROPERTY_GET_STRING, &val, mpctx); + if (needs_config_quoting(val)) { + // e.g. '%6%STRING' + fprintf(file, "%s=%%%d%%%s\n", pname, (int)strlen(val), val); + } else { + fprintf(file, "%s=%s\n", pname, val); } + talloc_free(val); } - talloc_free(val); } fclose(file); -- cgit v1.2.3