mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 09:02:38 +00:00
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.
This commit is contained in:
parent
11c74068b2
commit
fc574ee563
@ -103,6 +103,9 @@ Interface changes
|
|||||||
of 3D content doesn't justify such an option anyway.
|
of 3D content doesn't justify such an option anyway.
|
||||||
- change cycle-values command to use the current value, instead of an
|
- change cycle-values command to use the current value, instead of an
|
||||||
internal counter that remembered the current position.
|
internal counter that remembered the current position.
|
||||||
|
- ipc: require that "request_id" fields are integers. Other types are still
|
||||||
|
accepted for compatibility, but this will stop in the future. Also, if no
|
||||||
|
request_id is provided, 0 will be assumed.
|
||||||
--- mpv 0.28.0 ---
|
--- mpv 0.28.0 ---
|
||||||
- rename --hwdec=mediacodec option to mediacodec-copy, to reflect
|
- rename --hwdec=mediacodec option to mediacodec-copy, to reflect
|
||||||
conventions followed by other hardware video decoding APIs
|
conventions followed by other hardware video decoding APIs
|
||||||
|
@ -108,7 +108,10 @@ Because events can occur at any time, it may be difficult at times to determine
|
|||||||
which response goes with which command. Commands may optionally include a
|
which response goes with which command. Commands may optionally include a
|
||||||
``request_id`` which, if provided in the command request, will be copied
|
``request_id`` which, if provided in the command request, will be copied
|
||||||
verbatim into the response. mpv does not intrepret the ``request_id`` in any
|
verbatim into the response. mpv does not intrepret the ``request_id`` in any
|
||||||
way; it is solely for the use of the requester.
|
way; it is solely for the use of the requester. The only requirement is that
|
||||||
|
the ``request_id`` field must be an integer (a number without fractional parts
|
||||||
|
in the range ``-2^63..2^63-1``). Using other types is deprecated and will
|
||||||
|
currently show a warning. In the future, this will raise an error.
|
||||||
|
|
||||||
For example, this request:
|
For example, this request:
|
||||||
|
|
||||||
@ -122,6 +125,11 @@ Would generate this response:
|
|||||||
|
|
||||||
{ "error": "success", "data": 1.468135, "request_id": 100 }
|
{ "error": "success", "data": 1.468135, "request_id": 100 }
|
||||||
|
|
||||||
|
If you don't specify a ``request_id``, command replies will set it to 0.
|
||||||
|
|
||||||
|
Commands may run asynchronously in the future, instead of blocking the socket
|
||||||
|
until a reply is sent.
|
||||||
|
|
||||||
All commands, replies, and events are separated from each other with a line
|
All commands, replies, and events are separated from each other with a line
|
||||||
break character (``\n``).
|
break character (``\n``).
|
||||||
|
|
||||||
|
@ -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");
|
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");
|
mpv_node *cmd_node = node_map_get(&msg_node, "command");
|
||||||
if (!cmd_node ||
|
if (!cmd_node ||
|
||||||
@ -404,6 +408,8 @@ error:
|
|||||||
*/
|
*/
|
||||||
if (reqid_node) {
|
if (reqid_node) {
|
||||||
mpv_node_map_add(ta_parent, &reply_node, "request_id", 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));
|
mpv_node_map_add_string(ta_parent, &reply_node, "error", mpv_error_string(rc));
|
||||||
|
Loading…
Reference in New Issue
Block a user