diff options
Diffstat (limited to 'player/command.h')
-rw-r--r-- | player/command.h | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/player/command.h b/player/command.h index b6ccffe80f..ae3af82886 100644 --- a/player/command.h +++ b/player/command.h @@ -20,6 +20,8 @@ #include <stdbool.h> +#include "libmpv/client.h" + struct MPContext; struct mp_cmd; struct mp_log; @@ -43,12 +45,31 @@ struct mp_cmd_ctx { bool bar_osd; // OSD bar requested bool seek_msg_osd; // same as above, but for seek commands bool seek_bar_osd; - // Return values + // If mp_cmd_def.can_abort is set, this will be set. + struct mp_abort_entry *abort; + // Return values (to be set by command implementation, read by the + // completion callback). bool success; // true by default - struct mpv_node *result; + struct mpv_node result; + // Command handlers can set this to false if returning from the command + // handler does not complete the command. It stops the common command code + // from signaling the completion automatically, and you can call + // mp_cmd_ctx_complete() to invoke on_completion() properly (including all + // the bookkeeping). + /// (Note that in no case you can call mp_cmd_ctx_complete() from within + // the command handler, because it frees the mp_cmd_ctx.) + bool completed; // true by default + // This is managed by the common command code. For rules about how and where + // this is called see run_command() comments. + void (*on_completion)(struct mp_cmd_ctx *cmd); + void *on_completion_priv; // for free use by on_completion callback }; -int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *res); +void run_command(struct MPContext *mpctx, struct mp_cmd *cmd, + struct mp_abort_entry *abort, + void (*on_completion)(struct mp_cmd_ctx *cmd), + void *on_completion_priv); +void mp_cmd_ctx_complete(struct mp_cmd_ctx *cmd); char *mp_property_expand_string(struct MPContext *mpctx, const char *str); char *mp_property_expand_escaped_string(struct MPContext *mpctx, const char *str); void property_print_help(struct MPContext *mpctx); |