From 4291329d563c12dedca4b911accb7cae077225da Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 16 Jun 2019 18:21:04 +0200 Subject: demux: fix backward demuxing not grabbing all audio packets The previous commit broke audio playback (maybe this is what 4. was about?). But it wasn't the fault of the commit; it just exposed pre-existing issues. If the packet queue search can't get all packets, it checked queue->is_bof to see whether there could be previous packets. But obviously, is_bof can be set, even if the search start packet wasn't the first one. This was especially observable with audio, because audio by default needs preroll packets, and plays artifacts if they're missing. Fix by using the BOF playback condition for this purpose too. --- demux/demux.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'demux/demux.c') diff --git a/demux/demux.c b/demux/demux.c index 79e74523c0..2ce9010a86 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1423,9 +1423,12 @@ static void find_backward_restart_pos(struct demux_stream *ds) assert(total >= 1); + bool is_bof = ds->queue->is_bof && + (first == ds->queue->head || ds->back_seek_pos < ds->queue->seek_start); + struct demux_packet *target = NULL; // resume pos // nr. of keyframes, incl. target, excl. restart_pos - int got_total = num_kf < total && ds->queue->is_bof ? num_kf : total; + int got_total = num_kf < total && is_bof ? num_kf : total; int got_preroll = MPMAX(got_total - batch, 0); if (got_total == 1) { @@ -1444,10 +1447,7 @@ static void find_backward_restart_pos(struct demux_stream *ds) } if (!target) { - if (ds->queue->is_bof && - (first == ds->queue->head || - ds->back_seek_pos < ds->queue->seek_start)) - { + if (is_bof) { MP_VERBOSE(in, "BOF for stream %d\n", ds->index); ds->back_restarting = false; ds->back_range_started = false; -- cgit v1.2.3