summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-05-16 17:14:34 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:04 +0200
commit53cf4e27d48c783d4dc0103d9d082597a1266c0f (patch)
treea5e1102cb7dda9d0182e6bc8ff95fc75bba18d49
parent2d2d96f00b9b055d996bb9ba875be72491a3a74b (diff)
downloadmpv-53cf4e27d48c783d4dc0103d9d082597a1266c0f.tar.bz2
mpv-53cf4e27d48c783d4dc0103d9d082597a1266c0f.tar.xz
demux: adjust reader_head on range joining
I'm not sure about this, but it looks like a bug. If a stream didn't have packets, but the joined range does, the stream should obviously read the packets added by the joined range. Until now, due to reader_head being NULL, reading was only resumed if a _new_ packet was added by actual demuxing (in add_packet_locked()), which means the stream would suddenly skip ahead, past the original end of the joined range. Change it so that it will pick up the new range. Also, clear the skip_to_keyframe flag. Nothing useful can come from this flag being set; in the first place, the first packet of a range (that isn't the current range) should start with a keyframe. Some code probably enforced it (although it's fuzzy). Completely untested.
-rw-r--r--demux/demux.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 1a2495e8a9..e5d7ad27d9 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1297,6 +1297,10 @@ static void attempt_range_joining(struct demux_internal *in)
struct demux_queue *q2 = next->streams[n];
struct demux_stream *ds = in->streams[n]->ds;
+ assert(ds->queue == q1);
+
+ // First new packet that is appended to the current range.
+ struct demux_packet *join_point = q2->head;
if (q2->head) {
if (q1->head) {
@@ -1326,6 +1330,10 @@ static void attempt_range_joining(struct demux_internal *in)
add_index_entry(q1, q2->index[i]);
q2->num_index = 0;
+ if (ds->selected && !ds->reader_head)
+ ds->reader_head = join_point;
+ ds->skip_to_keyframe = false;
+
recompute_buffers(ds);
in->fw_bytes += ds->fw_bytes;