diff options
author | wm4 <wm4@nowhere> | 2018-05-10 14:33:10 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2018-05-24 19:56:34 +0200 |
commit | f0678afba010cfd13418641036309b3724cb9f66 (patch) | |
tree | c6cd5b463adfb2f2a43f1d7aae39c1ecb4684ec5 /player | |
parent | 005d3bc81a86dddf458c0d19142815687a303877 (diff) | |
download | mpv-f0678afba010cfd13418641036309b3724cb9f66.tar.bz2 mpv-f0678afba010cfd13418641036309b3724cb9f66.tar.xz |
client API: add returning of data from async commands
This was not done sooner out of laziness.
Diffstat (limited to 'player')
-rw-r--r-- | player/client.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/player/client.c b/player/client.c index 21bb069413..e26ebbd5d9 100644 --- a/player/client.c +++ b/player/client.c @@ -1108,7 +1108,6 @@ int mpv_command_string(mpv_handle *ctx, const char *args) struct async_cmd_request { struct MPContext *mpctx; struct mp_cmd *cmd; - int status; struct mpv_handle *reply_ctx; uint64_t userdata; }; @@ -1117,11 +1116,17 @@ static void async_cmd_complete(struct mp_cmd_ctx *cmd) { struct async_cmd_request *req = cmd->on_completion_priv; - req->status = cmd->success ? 0 : MPV_ERROR_COMMAND; + struct mpv_event_command *data = talloc_zero(NULL, struct mpv_event_command); + data->result = cmd->result; + cmd->result = (mpv_node){0}; + talloc_steal(data, node_get_alloc(&data->result)); - // Async command invocation - send a reply message. - status_reply(req->reply_ctx, MPV_EVENT_COMMAND_REPLY, - req->userdata, req->status); + struct mpv_event reply = { + .event_id = MPV_EVENT_COMMAND_REPLY, + .data = data, + .error = cmd->success ? 0 : MPV_ERROR_COMMAND, + }; + send_reply(req->reply_ctx, req->userdata, &reply); talloc_free(req); } |