summaryrefslogtreecommitdiffstats
path: root/options/path.h
diff options
context:
space:
mode:
authorGuido Cella <guido@guidocella.xyz>2023-08-27 21:26:44 +0200
committerDudemanguy <random342@airmail.cc>2023-08-28 18:31:17 +0000
commit64959c450ddb05641e860c844e505380980104b7 (patch)
treec029752ee20e5fd3cba583437c32a2accfdffaa0 /options/path.h
parent5a690a168adc964f7454cb2c25b3916be21b1e72 (diff)
downloadmpv-64959c450ddb05641e860c844e505380980104b7.tar.bz2
mpv-64959c450ddb05641e860c844e505380980104b7.tar.xz
player: always write redirect entries for resuming playback
35f43dfacbe added a system to write resume files for redirects, i.e. directories and playlists that mpv expands. It creates a resume file for each redirect, and for the first redirect only, it writes a resume file for each segment of its path, without even converting it to an absolute path if it's relative. This is incomplete: mpv 'Iron Maiden/1982 The Number of the Beast/8 Hallowed Be Thy Name.mp3' This doesn't save any redirect entry. mpv --directory-mode=recursive 'Iron Maiden', then quit-watch-later on Hallowed Be Thy Name This saves a redirect entry for "Iron Maiden", but not for "1982 The Number of the Beast". It doesn't save redirect entries for the directories above "Iron Maiden" either because "Iron Maiden" isn't converted to an absolute path. In both of these cases mpv --directory-mode=lazy 'Iron Maiden' won't resume from "Hallowed Be Thy Name" because "1982 The Number of the Beast" isn't the first subdirectory and there is no redirect entry for it. 503dada42f made mpv recursively expand subdirectories precisely to fix this, and f266eadf1e added back an option not to expand them. But if we fix how redirect entries are stored, we can make the superior --directory-mode=lazy (because it's faster and doesn't result in massive playlists) the default, and also ensure that mpv will resume playback even when you quit-watch-later a file without redirects and then play the directories above it. Fix this by always creating redirect entries for all segments of the absolute path of the file, so that both mpv 'Iron Maiden/1982 The Number of the Beast/8 Hallowed Be Thy Name.mp3' and mpv --directory-mode=lazy 'Iron Maiden' will create redirect entries for /$USER /$USER/music /$USER/music/Iron Maiden /$USER/music/Iron Maiden/1982 The Number of the Beast making mpv --directory-mode=lazy "Iron Maiden" resume from "Hallowed Be Thy Name". This commit also makes mpv delete the redirect entries of parent directories when resuming playback, because if for example you have a playlist with all the songs in a discography: 1980 Iron Maiden/1 Prowler.mp3 1980 Iron Maiden/2 Remember Tomorrow.mp3 ... 1981 Killers/1 The Ides of March.mp3 1981 Killers/2 Wrathchild.mp3 ... Now mpv will eventually create redirect entries for every album. If you later decide to play the directories instead and there are 20 albums, you would have to do mpv * 20 times to clear all the redirect entries.
Diffstat (limited to 'options/path.h')
-rw-r--r--options/path.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/options/path.h b/options/path.h
index 66ddcdc798..7ec8f7b18c 100644
--- a/options/path.h
+++ b/options/path.h
@@ -83,6 +83,8 @@ bool mp_path_is_absolute(struct bstr path);
char *mp_getcwd(void *talloc_ctx);
+char *mp_normalize_path(void *talloc_ctx, const char *path);
+
bool mp_path_exists(const char *path);
bool mp_path_isdir(const char *path);