demux_timeline: fix bad EOF reporting

Exposed by commit b56e2efd5f. demux_timeline reported a bogus EOF if
"parallel" streams were used. If a virtual source reported EOF, it was
propagated as global EOF, without serving packets of other virtual
sources that have not ended yet.

Fix this by not reporting global EOF just because a source has not
returned a packet. Instead make the reader retry by returning no packet
and no EOF state, which will call d_read_packet() again with a different
source. Rely on the eof_reached flags to signal global EOF.

Since eof_reached is now more important, set it in a certain other case
when it apparently should have been set. do_read_next_packet()'s return
value is now ignored, so get rid of it.
This commit is contained in:
wm4 2020-02-28 00:08:36 +01:00
parent 1e57f457b0
commit 2b628d4352
1 changed files with 10 additions and 11 deletions

View File

@ -261,15 +261,17 @@ static void switch_segment(struct demuxer *demuxer, struct virtual_source *src,
src->eos_packets = 0;
}
static bool do_read_next_packet(struct demuxer *demuxer,
static void do_read_next_packet(struct demuxer *demuxer,
struct virtual_source *src)
{
if (src->next)
return 1;
return;
struct segment *seg = src->current;
if (!seg || !seg->d)
return 0;
if (!seg || !seg->d) {
src->eof_reached = true;
return;
}
struct demux_packet *pkt = demux_read_any_packet(seg->d);
if (!pkt || (!src->no_clip && pkt->pts >= seg->end))
@ -310,10 +312,10 @@ static bool do_read_next_packet(struct demuxer *demuxer,
}
if (!next) {
src->eof_reached = true;
return false;
return;
}
switch_segment(demuxer, src, next, next->start, 0, true);
return true; // reader will retry
return; // reader will retry
}
if (pkt->stream < 0 || pkt->stream >= seg->num_stream_map)
@ -358,17 +360,15 @@ static bool do_read_next_packet(struct demuxer *demuxer,
pkt->stream = vs->sh->index;
src->next = pkt;
return true;
return;
drop:
talloc_free(pkt);
return true;
}
static bool d_read_packet(struct demuxer *demuxer, struct demux_packet **out_pkt)
{
struct priv *p = demuxer->priv;
struct virtual_source *src = NULL;
for (int x = 0; x < p->num_sources; x++) {
@ -391,8 +391,7 @@ static bool d_read_packet(struct demuxer *demuxer, struct demux_packet **out_pkt
if (!src)
return false;
if (!do_read_next_packet(demuxer, src))
return false;
do_read_next_packet(demuxer, src);
*out_pkt = src->next;
src->next = NULL;
return true;