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.
This commit is contained in:
wm4 2019-06-16 18:21:04 +02:00
parent f2cee22311
commit 4291329d56
1 changed files with 5 additions and 5 deletions

View File

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