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.
This commit is contained in:
wm4 2014-12-24 15:12:11 +01:00
parent 7593a1f638
commit fdb379109f
1 changed files with 2 additions and 0 deletions

View File

@ -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.