History

player: don't force saving start in watch-later-options

The watch-later mechanism has always unconditionally wrote start to files to save the playback position. When this was later expanded to watch-later-options, this logic was kept in place. But we don't actually have to unconditionally write this and can allow users to remove the option from the list if they want to. The start value still requires some special handling; it should always be written if possible regardless of the value changing. However, we can just place it within the default set of options for watch-later-options so it can be removed like any other.

Dudemanguy committed 3 years ago

Commit 6471afe1 parent c4ec47a4 files · +15 −6Browse files

Unified · Split

4 files
  1. DOCS/interface-changes.rst +4 −0
  2. DOCS/man/options.rst +3 −4
  3. options/options.c +1 −0
  4. player/configfiles.c +7 −2
DOCS/interface-changes.rst+4−0
@@ -41,6 +41,10 @@ Interface changes · 40 unmodified lines
41 - deprecate `--drm-atomic`41 - deprecate `--drm-atomic`
42 - add `--demuxer-hysteresis-secs`42 - add `--demuxer-hysteresis-secs`
43 - add `--video-sync=display-tempo`43 - add `--video-sync=display-tempo`
44 - the `start` option is no longer unconditionally written by
45 watch-later. It is still written by default but you may
46 need to explictly add `start` depending on how you have
47 `--watch-later-options` configured.
44 --- mpv 0.35.0 ---48 --- mpv 0.35.0 ---
45 - add the `--vo=gpu-next` video output driver, as well as the options49 - add the `--vo=gpu-next` video output driver, as well as the options
46 `--allow-delayed-peak-detect`, `--builtin-scalers`,50 `--allow-delayed-peak-detect`, `--builtin-scalers`,
DOCS/man/options.rst+3−4
@@ -1032,8 +1032,8 @@ Watch Later · 1031 unmodified lines
1032``--watch-later-options=option1,option2,...``1032``--watch-later-options=option1,option2,...``
1033 The options that are saved in "watch later" files if they have been changed1033 The options that are saved in "watch later" files if they have been changed
1034 since when mpv started. These values will be restored the next time the1034 since when mpv started. These values will be restored the next time the
1035 files are played. The playback position is always saved as ``start``, so1035 files are played. Note that the playback position is saved via the ``start``
1036 adding ``start`` to this list has no effect.1036 option.
1037 1037
1038 When removing options, existing watch later data won't be modified and will1038 When removing options, existing watch later data won't be modified and will
1039 still be applied fully, but new watch later data won't contain these1039 still be applied fully, but new watch later data won't contain these
@@ -1049,8 +1049,7 @@ Watch Later · 9 unmodified lines
1049 ``--watch-later-options-remove=mute``1049 ``--watch-later-options-remove=mute``
1050 The volume and mute state won't be saved to watch later files.1050 The volume and mute state won't be saved to watch later files.
1051 - ``--watch-later-options-clr``1051 - ``--watch-later-options-clr``
1052 No option will be saved to watch later files except the starting1052 No option will be saved to watch later files.
1053 position.
1054 1053
1055``--write-filename-in-watch-later-config``1054``--write-filename-in-watch-later-config``
1056 Prepend the watch later config files with the name of the file they refer1055 Prepend the watch later config files with the name of the file they refer
options/options.c+1−0
@@ -1069,6 +1069,7 @@ static const struct MPOpts mp_default_opts = { · 1068 unmodified lines
1069 .cuda_device = -1,1069 .cuda_device = -1,
1070 1070
1071 .watch_later_options = (char **)(const char*[]){1071 .watch_later_options = (char **)(const char*[]){
1072 "start",
1072 "osd-level",1073 "osd-level",
1073 "speed",1074 "speed",
1074 "edition",1075 "edition",
player/configfiles.c+7−2
@@ -303,18 +303,23 @@ void mp_write_watch_later_conf(struct MPContext *mpctx) · 302 unmodified lines
303 303
304 write_filename(mpctx, file, cur->filename);304 write_filename(mpctx, file, cur->filename);
305 305
306 bool write_start = true;
306 double pos = get_current_time(mpctx);307 double pos = get_current_time(mpctx);
307 308
308 if ((demux && (!demux->seekable || demux->partially_seekable)) ||309 if ((demux && (!demux->seekable || demux->partially_seekable)) ||
309 pos == MP_NOPTS_VALUE)310 pos == MP_NOPTS_VALUE)
310 {311 {
312 write_start = false;
311 MP_INFO(mpctx, "Not seekable, or time unknown - not saving position.\n");313 MP_INFO(mpctx, "Not seekable, or time unknown - not saving position.\n");
312 } else {
313 fprintf(file, "start=%f\n", pos);
314 }314 }
315 char **watch_later_options = mpctx->opts->watch_later_options;315 char **watch_later_options = mpctx->opts->watch_later_options;
316 for (int i = 0; watch_later_options && watch_later_options[i]; i++) {316 for (int i = 0; watch_later_options && watch_later_options[i]; i++) {
317 char *pname = watch_later_options[i];317 char *pname = watch_later_options[i];
318 // Always save start if we have it in the array.
319 if (write_start && strcmp(pname, "start") == 0) {
320 fprintf(file, "%s=%f\n", pname, pos);
321 continue;
322 }
318 // Only store it if it's different from the initial value.323 // Only store it if it's different from the initial value.
319 if (m_config_watch_later_backup_opt_changed(mpctx->mconfig, pname)) {324 if (m_config_watch_later_backup_opt_changed(mpctx->mconfig, pname)) {
320 char *val = NULL;325 char *val = NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t