summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-11-28 22:07:46 +0100
committerAlessandro Ghedini <alessandro@ghedini.me>2014-12-01 21:05:53 +0100
commitb82a98722a11f42eab834bdf28b69b86e74a2338 (patch)
tree9da60d6debccb04f52354cbe383b4986e2cc23e6
parent3d6d7012ff0a815333ab1db2c8a791ac0180fad2 (diff)
downloadmpv-b82a98722a11f42eab834bdf28b69b86e74a2338.tar.bz2
mpv-b82a98722a11f42eab834bdf28b69b86e74a2338.tar.xz
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().
-rw-r--r--player/loadfile.c13
-rw-r--r--player/playloop.c15
2 files changed, 11 insertions, 17 deletions
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)
diff --git a/player/playloop.c b/player/playloop.c
index 635c581def..190bc3f98c 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -214,16 +214,6 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
bool need_reset = false;
demuxer_amount = timeline_set_from_time(mpctx, seek.amount,
&need_reset);
- if (demuxer_amount == MP_NOPTS_VALUE) {
- assert(!need_reset);
- mpctx->stop_play = AT_END_OF_FILE;
- // When seeking outside of the file, but not when ending last segment.
- if (!timeline_fallthrough) {
- clear_audio_output_buffers(mpctx);
- reset_playback_state(mpctx);
- }
- return -1;
- }
if (need_reset) {
reinit_video_chain(mpctx);
reinit_audio_chain(mpctx);
@@ -961,10 +951,11 @@ void run_playloop(struct MPContext *mpctx)
mpctx->audio_status == STATUS_EOF &&
mpctx->video_status == STATUS_EOF)
{
- if (end_is_new_segment) {
+ int new_part = mpctx->timeline_part + 1;
+ if (end_is_new_segment && new_part < mpctx->num_timeline_parts) {
mp_seek(mpctx, (struct seek_params){
.type = MPSEEK_ABSOLUTE,
- .amount = mpctx->timeline[mpctx->timeline_part+1].start
+ .amount = mpctx->timeline[new_part].start
}, true);
} else
mpctx->stop_play = AT_END_OF_FILE;