summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-29 20:06:40 +0100
committerwm4 <wm4@nowhere>2020-02-29 21:49:00 +0100
commitc79619f11065bd630b05c191745bf54becd4c3b9 (patch)
tree955f13e3ba9a9e18878aacbac113422942f995eb
parent8fc2bc142211188344ebd73943133b9cb17d4431 (diff)
downloadmpv-c79619f11065bd630b05c191745bf54becd4c3b9.tar.bz2
mpv-c79619f11065bd630b05c191745bf54becd4c3b9.tar.xz
demux: add a way to block reading after seeks
Preparation for a future commit. The demuxer queues might be read from other threads than the one to issue the seek, and passing SEEK_BLOCK with such a seek will provide a convenient way to synchronize this.
-rw-r--r--demux/demux.c5
-rw-r--r--demux/demux.h2
2 files changed, 7 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c
index e5df920c22..68edd029a1 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -3775,6 +3775,9 @@ static bool queue_seek(struct demux_internal *in, double seek_pts, int flags,
bool force_seek = flags & SEEK_FORCE;
flags &= ~(unsigned)SEEK_FORCE;
+ bool block = flags & SEEK_BLOCK;
+ flags &= ~(unsigned)SEEK_BLOCK;
+
struct demux_cached_range *cache_target =
find_cache_seek_range(in, seek_pts, flags);
@@ -3795,6 +3798,8 @@ static bool queue_seek(struct demux_internal *in, double seek_pts, int flags,
clear_reader_state(in, clear_back_state);
+ in->blocked = block;
+
if (cache_target) {
execute_cache_seek(in, cache_target, seek_pts, flags);
} else {
diff --git a/demux/demux.h b/demux/demux.h
index 263b584ad3..f49e6e2a2f 100644
--- a/demux/demux.h
+++ b/demux/demux.h
@@ -63,6 +63,8 @@ struct demux_reader_state {
#define SEEK_SATAN (1 << 4) // enable backward demuxing
#define SEEK_HR (1 << 5) // hr-seek (this is a weak hint only)
#define SEEK_FORCE (1 << 6) // ignore unseekable flag
+#define SEEK_BLOCK (1 << 7) // upon successfully queued seek, block readers
+ // (simplifies syncing multiple reader threads)
// Strictness of the demuxer open format check.
// demux.c will try by default: NORMAL, UNSAFE (in this order)