|author||wm4 <wm4@nowhere>||2018-05-06 21:46:40 +0200|
|committer||wm4 <wm4@nowhere>||2018-05-24 19:56:34 +0200|
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).
1 files changed, 7 insertions, 0 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index e4017a2afa..7acac24f72 100644
@@ -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)
+ // Make it pick up the new entry.
mpctx->stop_play = PT_CURRENT_ENTRY;