From fdb379109f4de60bba03013d7572c6e38a954030 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 24 Dec 2014 15:12:11 +0100 Subject: player: hack against --keep-open misbehaving with broken files If a file (or a demuxer) is broken, seeking close to the end of the file doesn't work, and seek_to_last_frame() will be called over and over again, burning CPU for no reason. Observed with incomplete mp4 files. That this can happen was already mentioned in commit 090f6cfc, but I guess now I'll do something against it. hrseek_lastframe is cleared by reset_playback_state(), so it's only set if seek_to_last_frame() was called, and no other seek happened since then. If finding the last frame succeeds, no EOF will happen (unless the user unpauses, but then it will simply remain at the last frame). If it fails, then it will return immediately, without retrying. --- player/playloop.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'player') diff --git a/player/playloop.c b/player/playloop.c index 25ab5ae0f9..1a0f8fbdd5 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -783,6 +783,8 @@ void seek_to_last_frame(struct MPContext *mpctx) { if (!mpctx->d_video) return; + if (mpctx->hrseek_lastframe) // exit if we already tried this + return; MP_VERBOSE(mpctx, "seeking to last frame...\n"); // Approximately seek close to the end of the file. // Usually, it will seek some seconds before end. -- cgit v1.2.3