diff options
author | Dark <dark@volatile.bz> | 2019-07-13 20:36:34 -0400 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-09-21 14:24:42 +0200 |
commit | a41f1a21d67b3d3dd6b173e563176f90074f589e (patch) | |
tree | 48aa95b77ac18bdfe208be6743a8b25d883411ee /player | |
parent | 74b4760aa81222de32147e16fa7605ce55db9922 (diff) | |
download | mpv-a41f1a21d67b3d3dd6b173e563176f90074f589e.tar.bz2 mpv-a41f1a21d67b3d3dd6b173e563176f90074f589e.tar.xz |
client API: add mpv_command_ret
This change adds a version of `mpv_command` that also returns a result.
The main rationale behind this is `mpv_command_node` requires defining
multiple structs before you can even use it, which results in a pretty
painful to use interface just to get the result from a command.
There isn't really a good name for this function, so I'm open to
suggestions on a better name for it.
Diffstat (limited to 'player')
-rw-r--r-- | player/client.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/player/client.c b/player/client.c index 8a22a2cb32..6a45ec7fb6 100644 --- a/player/client.c +++ b/player/client.c @@ -1087,6 +1087,15 @@ int mpv_command_node(mpv_handle *ctx, mpv_node *args, mpv_node *result) return r; } +int mpv_command_ret(mpv_handle *ctx, const char **args, mpv_node *result) +{ + struct mpv_node rn = {.format = MPV_FORMAT_NONE}; + int r = run_client_command(ctx, mp_input_parse_cmd_strv(ctx->log, args), &rn); + if (result && r >= 0) + *result = rn; + return r; +} + int mpv_command_string(mpv_handle *ctx, const char *args) { return run_client_command(ctx, |