From 63e2b6c4aef2afd5879b3cfb2b172ee05f17f765 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 10 Oct 2014 23:58:59 +0200 Subject: 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. --- player/client.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'player/client.c') 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) { -- cgit v1.2.3