From 53cf4e27d48c783d4dc0103d9d082597a1266c0f Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 16 May 2019 17:14:34 +0200 Subject: 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. --- demux/demux.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'demux') 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; -- cgit v1.2.3