From 76dc5d9aa92f5c91c728004214f7b08c3a85a5f6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 18 May 2018 22:19:10 +0200 Subject: command: make loadlist command async and abortable Don't allow it to freeze everything when loading a playlist from network (although you definitely shouldn't do that, but whatever). This also affects the really obscure --ordered-chapters-files option. The --playlist option on the other hand has no choice but to freeze the shit, because there's no concept of aborting the player during command line parsing. --- player/command.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index fb8f6f14c5..55ad018c8c 100644 --- a/player/command.c +++ b/player/command.c @@ -5387,7 +5387,8 @@ static void cmd_loadlist(void *p) char *filename = cmd->args[0].v.s; bool append = cmd->args[1].v.i; - struct playlist *pl = playlist_parse_file(filename, mpctx->global); + struct playlist *pl = playlist_parse_file(filename, cmd->abort->cancel, + mpctx->global); if (pl) { prepare_playlist(mpctx, pl); struct playlist_entry *new = pl->current; @@ -6196,7 +6197,10 @@ const struct mp_cmd_def mp_cmds[] = { }, { "loadlist", cmd_loadlist, { OPT_STRING("url", v.s, 0), OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG, - ({"replace", 0}, {"append", 1})), }}, + ({"replace", 0}, {"append", 1})), }, + .spawn_thread = true, + .can_abort = true, + }, { "playlist-clear", cmd_playlist_clear }, { "playlist-remove", cmd_playlist_remove, {OPT_CHOICE_OR_INT("index", v.i, MP_CMD_OPT_ARG, 0, INT_MAX, -- cgit v1.2.3