1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 17:42:17 +00:00

player: make abort during loading faster if ytdl_hook is used

Basically, the ytdl_hook script will not terminate the script, even if
you change to a new playlist entry. This happens because ytdl_hook keeps
the player core in an early loading stage, and the forceful playback
abort is done only in the ermination code.

This does not handle the "stop" and "quit" commands, which can still
take longer than expected, but on the other hand have some weird special
handling (see below). I'm not doing this out of laziness. Playback
stopping will have to be somewhat redone anyway. Basically we want to
give everything a chance to terminate, and if it doesn't work, we want
to stop loading or playback forcefully after a small timeout. We also
want to remove the mess with input.c's special handling of "quit" and
some other commands (see abort_playback_cb stuff).
This commit is contained in:
wm4 2018-05-06 21:46:40 +02:00
parent 79596113ea
commit 115a9b19f1

View File

@ -1586,6 +1586,13 @@ void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e)
assert(!e || playlist_entry_to_index(mpctx->playlist, e) >= 0);
mpctx->playlist->current = e;
mpctx->playlist->current_was_replaced = false;
// If something is currently loading, abort it a bit more forcefully. This
// will in particular make ytdl_hook kill the script. During normal
// playback, we probably don't want this, because it could upset the
// demuxer or decoders and spam nonsense errors.
if (mpctx->playing && !mpctx->playback_initialized)
mp_abort_playback_async(mpctx);
// Make it pick up the new entry.
if (!mpctx->stop_play)
mpctx->stop_play = PT_CURRENT_ENTRY;
mp_wakeup_core(mpctx);