summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--player/configfiles.c33
-rw-r--r--player/core.h2
-rw-r--r--player/main.c1
3 files changed, 31 insertions, 5 deletions
diff --git a/player/configfiles.c b/player/configfiles.c
index cc5659fa18..3516544dd4 100644
--- a/player/configfiles.c
+++ b/player/configfiles.c
@@ -232,6 +232,25 @@ static const char *backup_properties[] = {
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 name[80];
+ snprintf(name, sizeof(name), "options/%s", pname);
+ char *val = NULL;
+ int r = mp_property_do(name, 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)
{
@@ -273,11 +292,15 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
char *val = NULL;
int r = mp_property_do(pname, M_PROPERTY_GET_STRING, &val, mpctx);
if (r == M_PROPERTY_OK) {
- 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);
+ // 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);
+ }
}
}
talloc_free(val);
diff --git a/player/core.h b/player/core.h
index 58c1e3793c..e14229174e 100644
--- a/player/core.h
+++ b/player/core.h
@@ -184,6 +184,7 @@ typedef struct MPContext {
int quit_custom_rc;
bool has_quit_custom_rc;
bool error_playing;
+ char **resume_defaults;
int64_t shown_vframes, shown_aframes;
@@ -362,6 +363,7 @@ void clear_audio_decode_buffers(struct MPContext *mpctx);
// configfiles.c
bool mp_parse_cfgfiles(struct MPContext *mpctx);
void mp_load_auto_profiles(struct MPContext *mpctx);
+void mp_get_resume_defaults(struct MPContext *mpctx);
void mp_load_playback_resume(struct MPContext *mpctx, const char *file);
void mp_write_watch_later_conf(struct MPContext *mpctx);
struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx,
diff --git a/player/main.c b/player/main.c
index af9ffe8c65..e510081d5b 100644
--- a/player/main.c
+++ b/player/main.c
@@ -412,6 +412,7 @@ int mp_initialize(struct MPContext *mpctx)
// From this point on, all mpctx members are initialized.
mpctx->initialized = true;
+ mp_get_resume_defaults(mpctx);
#if HAVE_COCOA
if (mpctx->is_cplayer)