summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-06 21:46:40 +0200
committerwm4 <wm4@nowhere>2018-05-24 19:56:34 +0200
commit115a9b19f14e0e8cc6dd5d0732cd39322cbd686c (patch)
treedd134698d40566695b740646055cc71d603b8843
parent79596113ea87460c9280853ae595d16c77b7c4c0 (diff)
downloadmpv-115a9b19f14e0e8cc6dd5d0732cd39322cbd686c.tar.bz2
mpv-115a9b19f14e0e8cc6dd5d0732cd39322cbd686c.tar.xz
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).
-rw-r--r--player/loadfile.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index e4017a2afa..7acac24f72 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -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);