From 70630fb803fde5ddcf9f3bd33ab8d682274d1ee7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 28 Nov 2014 22:07:46 +0100 Subject: player: simplify and fix ordered chapter EOF handling Ordered chapter EOF was handled as special-case of ending the last segment. This broke --kee-open, because it set AT_END_OF_FILE in an "inconvenient" place (after checking for --keep-open, and before the code that exits playback if EOF is reached). We don't actually need to handle the last segment specially. Instead, we remain in the same segment if it ends. The normal playback logic will recognize EOF, because the end of the segment "cuts off" the file. Now timeline_set_from_time() never "fails", and we can remove the old segment EOF handling code in mp_seek(). --- player/loadfile.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'player/loadfile.c') diff --git a/player/loadfile.c b/player/loadfile.c index b27ba94860..3c001ddeaa 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -300,14 +300,17 @@ double timeline_set_from_time(struct MPContext *mpctx, double pts, bool *need_re { if (pts < 0) pts = 0; + + int new = mpctx->num_timeline_parts - 1; for (int i = 0; i < mpctx->num_timeline_parts; i++) { - struct timeline_part *p = mpctx->timeline + i; - if (pts < (p + 1)->start) { - *need_reset = timeline_set_part(mpctx, i, false); - return pts - p->start + p->source_start; + if (pts < mpctx->timeline[i + 1].start) { + new = i; + break; } } - return MP_NOPTS_VALUE; + + *need_reset = timeline_set_part(mpctx, new, false); + return pts - mpctx->timeline[new].start + mpctx->timeline[new].source_start; } static int find_new_tid(struct MPContext *mpctx, enum stream_type t) -- cgit v1.2.3