mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
config: when writing resume config, read options, not properties
This lowers the number of data stored in the resume config a bit further, because some properties can't be read at program start and when e.g. the VO wasn't created yet. Some fields still need to be read from a property (actually only "volume-restore-data", a hack to save the full volume information). So abuse the "options/" property, and make use of the fact that changing things at runtime also changes the options.
This commit is contained in:
@@ -196,39 +196,39 @@ exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *backup_properties[] = {
|
static const char *backup_properties[] = {
|
||||||
"osd-level",
|
"options/osd-level",
|
||||||
//"loop",
|
//"loop",
|
||||||
"speed",
|
"options/speed",
|
||||||
"edition",
|
"options/edition",
|
||||||
"pause",
|
"options/pause",
|
||||||
"volume-restore-data",
|
"volume-restore-data",
|
||||||
"audio-delay",
|
"options/audio-delay",
|
||||||
//"balance",
|
//"balance",
|
||||||
"fullscreen",
|
"options/fullscreen",
|
||||||
"colormatrix",
|
"options/colormatrix",
|
||||||
"colormatrix-input-range",
|
"options/colormatrix-input-range",
|
||||||
"colormatrix-output-range",
|
"options/colormatrix-output-range",
|
||||||
"ontop",
|
"options/ontop",
|
||||||
"border",
|
"options/border",
|
||||||
"gamma",
|
"options/gamma",
|
||||||
"brightness",
|
"options/brightness",
|
||||||
"contrast",
|
"options/contrast",
|
||||||
"saturation",
|
"options/saturation",
|
||||||
"hue",
|
"options/hue",
|
||||||
"deinterlace",
|
"options/deinterlace",
|
||||||
"vf",
|
"options/vf",
|
||||||
"af",
|
"options/af",
|
||||||
"panscan",
|
"options/panscan",
|
||||||
"aid",
|
"options/aid",
|
||||||
"vid",
|
"options/vid",
|
||||||
"sid",
|
"options/sid",
|
||||||
"sub-delay",
|
"options/sub-delay",
|
||||||
"sub-pos",
|
"options/sub-pos",
|
||||||
"sub-visibility",
|
"options/sub-visibility",
|
||||||
"sub-scale",
|
"options/sub-scale",
|
||||||
"ass-use-margins",
|
"options/ass-use-margins",
|
||||||
"ass-vsfilter-aspect-compat",
|
"options/ass-vsfilter-aspect-compat",
|
||||||
"ass-style-override",
|
"options/ass-style-override",
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -241,10 +241,8 @@ void mp_get_resume_defaults(struct MPContext *mpctx)
|
|||||||
talloc_zero_array(mpctx, char*, MP_ARRAY_SIZE(backup_properties));
|
talloc_zero_array(mpctx, char*, MP_ARRAY_SIZE(backup_properties));
|
||||||
for (int i = 0; backup_properties[i]; i++) {
|
for (int i = 0; backup_properties[i]; i++) {
|
||||||
const char *pname = backup_properties[i];
|
const char *pname = backup_properties[i];
|
||||||
char name[80];
|
|
||||||
snprintf(name, sizeof(name), "options/%s", pname);
|
|
||||||
char *val = NULL;
|
char *val = NULL;
|
||||||
int r = mp_property_do(name, M_PROPERTY_GET_STRING, &val, mpctx);
|
int r = mp_property_do(pname, M_PROPERTY_GET_STRING, &val, mpctx);
|
||||||
if (r == M_PROPERTY_OK)
|
if (r == M_PROPERTY_OK)
|
||||||
list[i] = talloc_steal(list, val);
|
list[i] = talloc_steal(list, val);
|
||||||
}
|
}
|
||||||
@@ -292,6 +290,8 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
|
|||||||
char *val = NULL;
|
char *val = NULL;
|
||||||
int r = mp_property_do(pname, M_PROPERTY_GET_STRING, &val, mpctx);
|
int r = mp_property_do(pname, M_PROPERTY_GET_STRING, &val, mpctx);
|
||||||
if (r == M_PROPERTY_OK) {
|
if (r == M_PROPERTY_OK) {
|
||||||
|
if (strncmp(pname, "options/", 8) == 0)
|
||||||
|
pname += 8;
|
||||||
// Only store it if it's different from the initial value.
|
// Only store it if it's different from the initial value.
|
||||||
char *prev = mpctx->resume_defaults[i];
|
char *prev = mpctx->resume_defaults[i];
|
||||||
if (!prev || strcmp(prev, val) != 0) {
|
if (!prev || strcmp(prev, val) != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user