summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorChris Down <chris@chrisdown.name>2019-11-09 18:24:16 +0000
committerwm4 <1387750+wm4@users.noreply.github.com>2019-11-20 15:11:33 +0100
commite143966a76a259e4e83fce1b816c8adf86898ab0 (patch)
treed8261a5c7c0c5be7f91d7be9bd3a3d962dfc3ac4 /osdep
parent1649ba15ab60a99db4ee6bd914d614848d8ed044 (diff)
downloadmpv-e143966a76a259e4e83fce1b816c8adf86898ab0.tar.bz2
mpv-e143966a76a259e4e83fce1b816c8adf86898ab0.tar.xz
player: Optionally validate st_mtime when restoring playback state
I often watch sporting events. On many occasions I get files with the same filename for each session. For example, for F1 I might have the following directory structure: F1/ FP1.mkv FP2.mkv FP3.mkv Qualification.mkv Race.mkv Since usually one simply watches one race after the other, I usually just rsync the new event's files over the old ones, so, for example, Race.mkv will be replaced from the file for the last event with the file from the new event. One problem with this is that I like to use --resume-playback for other kinds of media, so I have it on by default. That works great for, say, a movie, but doesn't work so well with this scheme, because you can trivially forget to pass --no-resume-playback on the command line and end up 2 hours in, watching spoilers as the race results scroll down the screen :-) This patch adds a new option, --resume-playback-check-mtime, which validates that the file's mtime hasn't changed since the watch_later configuration was saved. It does this by setting the watch_later configuration to have the same mtime as the file after it is saved. Switching back and forth between checking mtime and not checking mtime works fine, as we only choose whether to compare based on it, but we update the watch_later configuration mtime regardless of its value.
Diffstat (limited to 'osdep')
-rw-r--r--osdep/io.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/osdep/io.h b/osdep/io.h
index 8699fb3e4a..12907e5cc9 100644
--- a/osdep/io.h
+++ b/osdep/io.h
@@ -172,6 +172,9 @@ void mp_globfree(mp_glob_t *pglob);
#undef fstat
#define fstat(...) mp_fstat(__VA_ARGS__)
+#define utime(...) _utime(__VA_ARGS__)
+#define utimbuf _utimbuf
+
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
int munmap(void *addr, size_t length);
int msync(void *addr, size_t length, int flags);