From c349e2f337693c53687b0bd5e4d8669363e2d79d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 6 May 2018 21:23:28 +0200 Subject: command: make sub-add and audio-add commands async Pretty trivial, since commands can be async now, and the common code even provides convenience like running commands on a worker thread. The only ugly thing is that mp_add_external_file() needs an extra flag for locking. This is because there's still some code which calls this synchronously from the main thread, and unlocking the core makes no sense there. --- player/command.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index 4600e65236..9aa3a9e6d8 100644 --- a/player/command.c +++ b/player/command.c @@ -5520,7 +5520,7 @@ static void cmd_track_add(void *p) return; } } - int first = mp_add_external_file(mpctx, cmd->args[0].v.s, type); + int first = mp_add_external_file(mpctx, cmd->args[0].v.s, type, true); if (first < 0) { cmd->success = false; return; @@ -5584,7 +5584,7 @@ static void cmd_track_reload(void *p) if (t && t->is_external && t->external_filename) { char *filename = talloc_strdup(NULL, t->external_filename); mp_remove_track(mpctx, t); - nt_num = mp_add_external_file(mpctx, filename, type); + nt_num = mp_add_external_file(mpctx, filename, type, false); talloc_free(filename); } @@ -6039,6 +6039,7 @@ const struct mp_cmd_def mp_cmds[] = { OARG_STRING(""), OARG_STRING(""), }, .priv = &(const int){STREAM_SUB}, + .spawn_thread = true, }, { "sub-remove", cmd_track_remove, { OARG_INT(-1) }, .priv = &(const int){STREAM_SUB}, }, @@ -6169,6 +6170,7 @@ const struct mp_cmd_def mp_cmds[] = { OARG_STRING(""), OARG_STRING(""), }, .priv = &(const int){STREAM_AUDIO}, + .spawn_thread = true, }, { "audio-remove", cmd_track_remove, { OARG_INT(-1) }, .priv = &(const int){STREAM_AUDIO}, }, -- cgit v1.2.3