diff options
author | wm4 <wm4@nowhere> | 2014-10-10 23:58:59 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-10-11 00:33:09 +0200 |
commit | 63e2b6c4aef2afd5879b3cfb2b172ee05f17f765 (patch) | |
tree | 2fafba7b4af07814aa1ff74624b78b338d3b203e /player/client.c | |
parent | 84a126b5b5f957c9ea59f962f6472569e8b3c253 (diff) | |
download | mpv-63e2b6c4aef2afd5879b3cfb2b172ee05f17f765.tar.bz2 mpv-63e2b6c4aef2afd5879b3cfb2b172ee05f17f765.tar.xz |
client API: add mpv_command_node[_async]
Allows passing native types as arguments.
Also some minor doc improvements, including giving some (natural)
improvements to mpv_free_node_contents().
Note: mpv_command_node_async() is completely untested.
Diffstat (limited to 'player/client.c')
-rw-r--r-- | player/client.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/player/client.c b/player/client.c index d1bdec001e..6bb9b18160 100644 --- a/player/client.c +++ b/player/client.c @@ -880,18 +880,24 @@ int mpv_command(mpv_handle *ctx, const char **args) return run_client_command(ctx, mp_input_parse_cmd_strv(ctx->log, args)); } +int mpv_command_node(mpv_handle *ctx, mpv_node *args, mpv_node *result) +{ + int r = run_client_command(ctx, mp_input_parse_cmd_node(ctx->log, args)); + if (r >= 0) + *result = (mpv_node){.format = MPV_FORMAT_NONE}; + return r; +} + int mpv_command_string(mpv_handle *ctx, const char *args) { return run_client_command(ctx, mp_input_parse_cmd(ctx->mpctx->input, bstr0((char*)args), ctx->name)); } -int mpv_command_async(mpv_handle *ctx, uint64_t ud, const char **args) +static int run_cmd_async(mpv_handle *ctx, uint64_t ud, struct mp_cmd *cmd) { if (!ctx->mpctx->initialized) return MPV_ERROR_UNINITIALIZED; - - struct mp_cmd *cmd = mp_input_parse_cmd_strv(ctx->log, args); if (!cmd) return MPV_ERROR_INVALID_PARAMETER; @@ -905,6 +911,16 @@ int mpv_command_async(mpv_handle *ctx, uint64_t ud, const char **args) return run_async(ctx, cmd_fn, req); } +int mpv_command_async(mpv_handle *ctx, uint64_t ud, const char **args) +{ + return run_cmd_async(ctx, ud, mp_input_parse_cmd_strv(ctx->log, args)); +} + +int mpv_command_node_async(mpv_handle *ctx, uint64_t ud, mpv_node *args) +{ + return run_cmd_async(ctx, ud, mp_input_parse_cmd_node(ctx->log, args)); +} + static int translate_property_error(int errc) { switch (errc) { |