diff options
author | wm4 <wm4@nowhere> | 2012-11-14 13:46:40 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-11-14 13:46:40 +0100 |
commit | 50db7b7f75f2e70b36b1e924bd73cdedc424f2af (patch) | |
tree | afd8301fd9f1ad668ede408de40f75f43b8651c4 /core | |
parent | 8827a4090eb743ffbfeb8e1f1b0480febf48d9fb (diff) | |
download | mpv-50db7b7f75f2e70b36b1e924bd73cdedc424f2af.tar.bz2 mpv-50db7b7f75f2e70b36b1e924bd73cdedc424f2af.tar.xz |
mplayer: do not freeze when trying to loop an unseekable file
Using --loop=inf on an unseekable file would put mpv (and all other
mplayers as well) into an endless loop, trying to seek to the start of
the file on each playback loop iteration. When the seek fails, playback
simply remains in the at-end-of-file state, and tries to issue a new
seek command for looping.
Fix by checking if the seek command fails, and abort looping in this
case. For that, queue_seek() is replaced with seek(). Due to the
circumstances, these two calls happen to be equal in this case: the
seek is absolute (i.e. no seek coalescing done), and the execution of
queued seeks is right after the loop code anyway.
Diffstat (limited to 'core')
-rw-r--r-- | core/mplayer.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index fd260c3a2a..2923d15374 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -3314,13 +3314,25 @@ static void run_playloop(struct MPContext *mpctx) mpctx->stop_play == PT_NEXT_ENTRY)) { mp_msg(MSGT_CPLAYER, MSGL_V, "loop_times = %d\n", opts->loop_times); + int stop_reason = mpctx->stop_play; + if (opts->loop_times > 1) opts->loop_times--; else if (opts->loop_times == 1) opts->loop_times = -1; play_n_frames = play_n_frames_mf; mpctx->stop_play = 0; - queue_seek(mpctx, MPSEEK_ABSOLUTE, opts->seek_to_sec, 0); + mpctx->seek = (struct seek_params) {0}; + struct seek_params sp = { + .type = MPSEEK_ABSOLUTE, + .amount = opts->seek_to_sec, + .exact = 1, + }; + if (seek(mpctx, sp, false) != 0) { + mp_msg(MSGT_CPLAYER, MSGL_ERR, "Can't loop an unseekable file.\n"); + opts->loop_times = -1; + mpctx->stop_play = stop_reason; + } } if (mpctx->seek.type) { |