From c79619f11065bd630b05c191745bf54becd4c3b9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 29 Feb 2020 20:06:40 +0100 Subject: 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. --- demux/demux.c | 5 +++++ demux/demux.h | 2 ++ 2 files changed, 7 insertions(+) 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) -- cgit v1.2.3