diff options
Diffstat (limited to 'input/cmd.h')
-rw-r--r-- | input/cmd.h | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/input/cmd.h b/input/cmd.h index e09bcaa1c4..2d9c922230 100644 --- a/input/cmd.h +++ b/input/cmd.h @@ -39,9 +39,26 @@ struct mp_cmd_def { bool on_updown; // always emit it on both up and down key events bool vararg; // last argument can be given 0 to multiple times bool scalable; - bool is_abort; - bool is_soft_abort; bool is_ignore; + bool default_async; // default to MP_ASYNC flag if none set by user + // If you set this, handler() must ensure mp_cmd_ctx_complete() is called + // at some point (can be after handler() returns). If you don't set it, the + // common code will call mp_cmd_ctx_complete() when handler() returns. + // You must make sure that the core cannot disappear while you do work. The + // common code keeps the core referenced only until handler() returns. + bool exec_async; + // If set, handler() is run on a separate worker thread. This means you can + // use mp_core_[un]lock() to temporarily unlock and re-lock the core (while + // unlocked, you have no synchronized access to mpctx, but you can do long + // running operations without blocking playback or input handling). + bool spawn_thread; + // If this is set, mp_cmd_ctx.abort is set. Set this if handler() can do + // asynchronous abort of the command, and explicitly uses mp_cmd_ctx.abort. + // (Not setting it when it's not needed can save resources.) + bool can_abort; + // If playback ends, and the command is still running, an abort is + // automatically triggered. + bool abort_on_playback_end; }; enum mp_cmd_flags { @@ -51,7 +68,11 @@ enum mp_cmd_flags { MP_ON_OSD_MSG = 4, // force a message, if applicable MP_EXPAND_PROPERTIES = 8, // expand strings as properties MP_ALLOW_REPEAT = 16, // if used as keybinding, allow key repeat - MP_ASYNC_CMD = 32, + + // Exactly one of the following 2 bits is set. Which one is used depends on + // the command parser (prefixes and mp_cmd_def.default_async). + MP_ASYNC_CMD = 32, // do not wait for command to complete + MP_SYNC_CMD = 64, // block on command completion MP_ON_OSD_FLAGS = MP_ON_OSD_NO | MP_ON_OSD_AUTO | MP_ON_OSD_BAR | MP_ON_OSD_MSG, @@ -64,6 +85,7 @@ struct mp_cmd_arg { const struct m_option *type; union { int i; + int64_t i64; float f; double d; char *s; @@ -73,7 +95,6 @@ struct mp_cmd_arg { }; typedef struct mp_cmd { - int id; char *name; struct mp_cmd_arg *args; int nargs; @@ -98,11 +119,6 @@ typedef struct mp_cmd { extern const struct mp_cmd_def mp_cmds[]; extern const struct mp_cmd_def mp_cmd_list; -// Executing this command will maybe abort playback (play something else, or quit). -bool mp_input_is_maybe_abort_cmd(struct mp_cmd *cmd); -// This command will definitely abort playback. -bool mp_input_is_abort_cmd(struct mp_cmd *cmd); - bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd); bool mp_input_is_scalable_cmd(struct mp_cmd *cmd); |