diff options
author | wm4 <wm4@nowhere> | 2020-03-26 23:58:09 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-03-26 23:59:44 +0100 |
commit | 1a720377203f7cee2ab949c5aa2bc9e0a2a7e0f2 (patch) | |
tree | bc2028b3823c06d59091797536c32623ebc555a8 /player/command.c | |
parent | 9bda301eb4d8aa75d435f24146c3a66ab74cafea (diff) | |
download | mpv-1a720377203f7cee2ab949c5aa2bc9e0a2a7e0f2.tar.bz2 mpv-1a720377203f7cee2ab949c5aa2bc9e0a2a7e0f2.tar.xz |
scripting: remove race condition when toggling internal scripts
Scripts such as the OSC can be loaded and unloaded at runtime by
toggling the option that enables them. (It even works, although normally
it's only used to control initial loading.)
Unloading was racy because it used the client name; fix this.
The load-script change is an accidental feature. And probably useless.
Diffstat (limited to 'player/command.c')
-rw-r--r-- | player/command.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/player/command.c b/player/command.c index 3098e1d9bf..822a54c4a7 100644 --- a/player/command.c +++ b/player/command.c @@ -5538,8 +5538,14 @@ static void cmd_load_script(void *p) struct MPContext *mpctx = cmd->mpctx; char *script = cmd->args[0].v.s; - if (mp_load_user_script(mpctx, script) < 0) + int64_t id = mp_load_user_script(mpctx, script); + if (id > 0) { + struct mpv_node *res = &cmd->result; + node_init(res, MPV_FORMAT_NODE_MAP, NULL); + node_map_add_int64(res, "client_id", id); + } else { cmd->success = false; + } } static void cache_dump_poll(struct MPContext *mpctx) |