summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-05-31 22:28:28 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:05 +0200
commitd25fbb081387ddb9679a31faf43946ad837c5d66 (patch)
treee8ab634d6d872ae9a8b912b7b93923a0cbcba3e5 /demux/demux.c
parenta88b7bf0fc9f2b4da15aeaf51cfbf35e5776d8ea (diff)
downloadmpv-d25fbb081387ddb9679a31faf43946ad837c5d66.tar.bz2
mpv-d25fbb081387ddb9679a31faf43946ad837c5d66.tar.xz
demux: fix backward playback at EOF with full demuxer cache
Fixes "mpv file.mkv --cache --demuxer-cache-wait --play-dir=backward", and other situations where the demuxer cache contains the entire file, and playback is to start from the end. It also can be triggered when starting playback normally with --cache, and once everything is in the cache, enabling backward playback and seeking past EOF. In all cases, the cache seek will set reader_head=NULL (because you seeked to/past EOF). Then the code (the one modified by this commit) sees that ds->queue->is_bof==true, and thinks we've reached BOF (beginning of file) while searching for a useful packet, i.e. we found nothing and playback really can only end. Obviously this is nonsense, we've found only nothing if we actually searched from the beginning, not some "random" reader_head (== first) value that does not include the entire cache. That means the condition should trigger only if the start of the search (first variable) points to the beginning of the cache (ds->queue->head). Not taking this if means we'll seek to an earlier position and retry. Also, a seek before the beginning of the cache will always end up with reader_head==ds->queue->head, i.e. we'll terminate properly. That comment was quite right.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/demux/demux.c b/demux/demux.c
index f65d606b92..0582ccc661 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1393,9 +1393,7 @@ static void find_backward_restart_pos(struct demux_stream *ds)
}
if (!target) {
- // Note: assume this holds true. You could think of various reasons why
- // this might break.
- if (ds->queue->is_bof) {
+ if (ds->queue->is_bof && first == ds->queue->head) {
MP_VERBOSE(in, "BOF for stream %d\n", ds->index);
ds->back_restarting = false;
ds->back_range_started = false;