diff options
author | wm4 <wm4@nowhere> | 2018-05-13 12:46:50 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2018-05-24 19:56:34 +0200 |
commit | fc574ee5634112c21ee4b61d8f9b7517ec3192a2 (patch) | |
tree | e01d065f87b1383f0ed6d75fa026d76fa272688e /input/ipc.c | |
parent | 11c74068b2791909dff2b4ef33f11884230166f0 (diff) | |
download | mpv-fc574ee5634112c21ee4b61d8f9b7517ec3192a2.tar.bz2 mpv-fc574ee5634112c21ee4b61d8f9b7517ec3192a2.tar.xz |
ipc: some user-visible changes to prepare for making all commands async
I wanted to put all commands through mpv_command_node_async() instead of
mpv_command_node(). Using synchronous commands over a synchronous
transport doesn't make sense anyway.
This would have used the request_id field in IPC requests as reply ID
for the async commands. But the latter need to be [u]int64, while the
former can be any type. To avoid that we need an extra lookup table for
mapping reply IDs to request_id values, we now require that request_id
fields are integers.
Since this would be an incompatible change, just deprecate non-integers
for now, and plan the change for a later time.
Diffstat (limited to 'input/ipc.c')
-rw-r--r-- | input/ipc.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/input/ipc.c b/input/ipc.c index 5a820c9ad2..6568feacfa 100644 --- a/input/ipc.c +++ b/input/ipc.c @@ -207,6 +207,10 @@ static char *json_execute_command(struct mpv_handle *client, void *ta_parent, } reqid_node = node_map_get(&msg_node, "request_id"); + if (reqid_node && reqid_node->format != MPV_FORMAT_INT64) { + mp_warn(log, "'request_id' must be an integer. Using other types is " + "deprecated and will trigger an error in the future!\n"); + } mpv_node *cmd_node = node_map_get(&msg_node, "command"); if (!cmd_node || @@ -404,6 +408,8 @@ error: */ if (reqid_node) { mpv_node_map_add(ta_parent, &reply_node, "request_id", reqid_node); + } else { + mpv_node_map_add_int64(ta_parent, &reply_node, "request_id", 0); } mpv_node_map_add_string(ta_parent, &reply_node, "error", mpv_error_string(rc)); |