diff options
author | wm4 <wm4@nowhere> | 2019-06-16 18:21:04 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-19 20:37:05 +0200 |
commit | 4291329d563c12dedca4b911accb7cae077225da (patch) | |
tree | 1f3029d2ac0559c018db239259426da2206bcb88 /demux/demux.c | |
parent | f2cee223111435a1a6e8a4754537737665fd5d94 (diff) | |
download | mpv-4291329d563c12dedca4b911accb7cae077225da.tar.bz2 mpv-4291329d563c12dedca4b911accb7cae077225da.tar.xz |
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.
Diffstat (limited to 'demux/demux.c')
-rw-r--r-- | demux/demux.c | 10 |
1 files changed, 5 insertions, 5 deletions
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; |