diff options
author | Dudemanguy <random342@airmail.cc> | 2023-08-09 20:11:07 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-08-11 22:28:50 +0000 |
commit | 692ccca3a2eb48810eb1a8abb346be06a9b17d53 (patch) | |
tree | 73e483fd680ac5876a3da854727800c8426b8a6e /player | |
parent | 02a80f850b5403da89fefed7b32b3f3dfb82f647 (diff) | |
download | mpv-692ccca3a2eb48810eb1a8abb346be06a9b17d53.tar.bz2 mpv-692ccca3a2eb48810eb1a8abb346be06a9b17d53.tar.xz |
command: fix some fringe play-dir behavior
This is pretty obscure but if you screw around with the play-dir option
to essentially create a ping-pong loop; mpv will get hit by an assertion
error. What's happening here is that changing the play-dir always
requires a seek. This is handled in player/command along with the other
runtime option changes. However, queue_seek can actually clear the value
of mpctx->stop_play if the file is ending. So while loadfile is
terminating playback and the play-dir gets changed, the value of
mpctx->stop_play gets cleared because of seek. This then hits that
assertion later when mpv tries to finish the file.
The fix is to just add some weird logic to play-dir in player/command.
We have to be sure that mpctx->play_dir matches the new direction
immediately when we get the change so explictly set it here and don't
wait for it later. Secondly, keep the old value of mpctx->stop_play
before the seek and restore it afterwards. This ensures that termination
still happens cleanly and allows the ping-pong loop to work. Fixes #10782
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c index bf30a55968..afacfdea9d 100644 --- a/player/command.c +++ b/player/command.c @@ -6928,8 +6928,14 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags, if (opt_ptr == &opts->play_dir) { if (mpctx->play_dir != opts->play_dir) { + // Some weird things for play_dir. + // 1. The option must be set before we seek. + // 2. queue_seek can change the stop_play value; always keep the old one. + mpctx->play_dir = opts->play_dir; + int old_stop_play = mpctx->stop_play; queue_seek(mpctx, MPSEEK_ABSOLUTE, get_current_time(mpctx), MPSEEK_EXACT, 0); + mpctx->stop_play = old_stop_play; } } |