summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-24 15:12:11 +0100
committerwm4 <wm4@nowhere>2014-12-24 15:12:11 +0100
commitfdb379109f4de60bba03013d7572c6e38a954030 (patch)
tree1bdb2675dd778de120de0ce4505a972cf083e138 /player/playloop.c
parent7593a1f63884db53b9d1c70c4fe0c2a2f8d9db63 (diff)
downloadmpv-fdb379109f4de60bba03013d7572c6e38a954030.tar.bz2
mpv-fdb379109f4de60bba03013d7572c6e38a954030.tar.xz
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.
Diffstat (limited to 'player/playloop.c')
-rw-r--r--player/playloop.c2
1 files changed, 2 insertions, 0 deletions
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.