mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
8827a4090e
commit
50db7b7f75
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue