1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-22 14:52:43 +00:00

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.
This commit is contained in:
wm4 2020-02-29 20:06:40 +01:00
parent 8fc2bc1422
commit c79619f110
2 changed files with 7 additions and 0 deletions

View File

@ -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 {

View File

@ -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)