summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-03-14 21:28:01 +0100
committerwm4 <wm4@nowhere>2020-03-18 19:52:01 +0100
commit26f4f18c0629998a9b91e94722d166866d8b80a3 (patch)
tree16d4891d241d528f63ee99f0017530bba7b3dc8b /player/command.c
parentcdd6eb0994bc6aeb8aeb0326e5d8c61c06eb38eb (diff)
downloadmpv-26f4f18c0629998a9b91e94722d166866d8b80a3.tar.bz2
mpv-26f4f18c0629998a9b91e94722d166866d8b80a3.tar.xz
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option initializer, and instead expand only to a part of it, which sets certain fields. This requires changing almost every option declaration, because they all use these macros. A declaration now always starts with {"name", ... followed by designated initializers only (possibly wrapped in macros). The OPT_* macros now initialize the .offset and .type fields only, sometimes also .priv and others. I think this change makes the option macros less tricky. The old code had to stuff everything into macro arguments (and attempted to allow setting arbitrary fields by letting the user pass designated initializers in the vararg parts). Some of this was made messy due to C99 and C11 not allowing 0-sized varargs with ',' removal. It's also possible that this change is pointless, other than cosmetic preferences. Not too happy about some things. For example, the OPT_CHOICE() indentation I applied looks a bit ugly. Much of this change was done with regex search&replace, but some places required manual editing. In particular, code in "obscure" areas (which I didn't include in compilation) might be broken now. In wayland_common.c the author of some option declarations confused the flags parameter with the default value (though the default value was also properly set below). I fixed this with this change.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c355
1 files changed, 185 insertions, 170 deletions
diff --git a/player/command.c b/player/command.c
index 2c86a0ecb7..d894f28f89 100644
--- a/player/command.c
+++ b/player/command.c
@@ -5592,30 +5592,32 @@ const struct mp_cmd_def mp_cmds[] = {
{ "seek", cmd_seek,
{
- OPT_TIME("target", v.d, 0),
- OPT_FLAGS("flags", v.i, 0,
- ({"relative", 4|0}, {"-", 4|0},
- {"absolute-percent", 4|1},
- {"absolute", 4|2},
- {"relative-percent", 4|3},
- {"keyframes", 32|8},
- {"exact", 32|16}),
- OPTDEF_INT(4|0)),
+ {"target", OPT_TIME(v.d)},
+ {"flags", OPT_FLAGS(v.i,
+ {"relative", 4|0}, {"-", 4|0},
+ {"absolute-percent", 4|1},
+ {"absolute", 4|2},
+ {"relative-percent", 4|3},
+ {"keyframes", 32|8},
+ {"exact", 32|16}),
+ OPTDEF_INT(4|0)},
// backwards compatibility only
- OPT_CHOICE("legacy", v.i, MP_CMD_OPT_ARG,
- ({"unused", 0}, {"default-precise", 0},
- {"keyframes", 32|8},
- {"exact", 32|16})),
+ {"legacy", OPT_CHOICE(v.i,
+ {"unused", 0}, {"default-precise", 0},
+ {"keyframes", 32|8},
+ {"exact", 32|16}),
+ .flags = MP_CMD_OPT_ARG},
},
.allow_auto_repeat = true,
.scalable = true,
},
{ "revert-seek", cmd_revert_seek,
- {OPT_FLAGS("flags", v.i, MP_CMD_OPT_ARG, ({"mark", 1}))},
+ { {"flags", OPT_FLAGS(v.i, {"mark", 1}), .flags = MP_CMD_OPT_ARG} },
},
- { "quit", cmd_quit, { OPT_INT("code", v.i, MP_CMD_OPT_ARG) },
+ { "quit", cmd_quit, { {"code", OPT_INT(v.i), .flags = MP_CMD_OPT_ARG} },
.priv = &(const bool){0} },
- { "quit-watch-later", cmd_quit, { OPT_INT("code", v.i, MP_CMD_OPT_ARG) },
+ { "quit-watch-later", cmd_quit, { {"code", OPT_INT(v.i),
+ .flags = MP_CMD_OPT_ARG} },
.priv = &(const bool){1} },
{ "stop", cmd_stop, },
{ "frame-step", cmd_frame_step, .allow_auto_repeat = true,
@@ -5623,44 +5625,52 @@ const struct mp_cmd_def mp_cmds[] = {
{ "frame-back-step", cmd_frame_back_step, .allow_auto_repeat = true },
{ "playlist-next", cmd_playlist_next_prev,
{
- OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG, ({"weak", 0},
- {"force", 1})),
+ {"flags", OPT_CHOICE(v.i,
+ {"weak", 0},
+ {"force", 1}),
+ .flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){1},
},
{ "playlist-prev", cmd_playlist_next_prev,
{
- OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG, ({"weak", 0},
- {"force", 1})),
+ {"flags", OPT_CHOICE(v.i,
+ {"weak", 0},
+ {"force", 1}),
+ .flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){-1},
},
{ "playlist-shuffle", cmd_playlist_shuffle, },
{ "playlist-unshuffle", cmd_playlist_unshuffle, },
- { "sub-step", cmd_sub_step_seek, { OPT_INT("skip", v.i, 0) },
+ { "sub-step", cmd_sub_step_seek, { {"skip", OPT_INT(v.i)} },
.allow_auto_repeat = true, .priv = &(const bool){true} },
- { "sub-seek", cmd_sub_step_seek, { OPT_INT("skip", v.i, 0) },
+ { "sub-seek", cmd_sub_step_seek, { {"skip", OPT_INT(v.i)} },
.allow_auto_repeat = true, .priv = &(const bool){false} },
- { "print-text", cmd_print_text, { OPT_STRING("text", v.s, 0) },
+ { "print-text", cmd_print_text, { {"text", OPT_STRING(v.s)} },
.is_noisy = true, .allow_auto_repeat = true },
- { "show-text", cmd_show_text, { OPT_STRING("text", v.s, 0),
- OPT_INT("duration", v.i, 0, OPTDEF_INT(-1)),
- OPT_INT("level", v.i, MP_CMD_OPT_ARG), },
+ { "show-text", cmd_show_text,
+ {
+ {"text", OPT_STRING(v.s)},
+ {"duration", OPT_INT(v.i), OPTDEF_INT(-1)},
+ {"level", OPT_INT(v.i), .flags = MP_CMD_OPT_ARG},
+ },
.is_noisy = true, .allow_auto_repeat = true},
- { "expand-text", cmd_expand_text, { OPT_STRING("text", v.s, 0) },
+ { "expand-text", cmd_expand_text, { {"text", OPT_STRING(v.s)} },
.is_noisy = true },
- { "expand-path", cmd_expand_path, { OPT_STRING("text", v.s, 0) },
+ { "expand-path", cmd_expand_path, { {"text", OPT_STRING(v.s)} },
.is_noisy = true },
{ "show-progress", cmd_show_progress, .allow_auto_repeat = true,
.is_noisy = true },
{ "sub-add", cmd_track_add,
{
- OPT_STRING("url", v.s, 0),
- OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
- ({"select", 0}, {"auto", 1}, {"cached", 2})),
- OPT_STRING("title", v.s, MP_CMD_OPT_ARG),
- OPT_STRING("lang", v.s, MP_CMD_OPT_ARG),
+ {"url", OPT_STRING(v.s)},
+ {"flags", OPT_CHOICE(v.i,
+ {"select", 0}, {"auto", 1}, {"cached", 2}),
+ .flags = MP_CMD_OPT_ARG},
+ {"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
+ {"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){STREAM_SUB},
.spawn_thread = true,
@@ -5669,11 +5679,12 @@ const struct mp_cmd_def mp_cmds[] = {
},
{ "audio-add", cmd_track_add,
{
- OPT_STRING("url", v.s, 0),
- OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
- ({"select", 0}, {"auto", 1}, {"cached", 2})),
- OPT_STRING("title", v.s, MP_CMD_OPT_ARG),
- OPT_STRING("lang", v.s, MP_CMD_OPT_ARG),
+ {"url", OPT_STRING(v.s)},
+ {"flags", OPT_CHOICE(v.i,
+ {"select", 0}, {"auto", 1}, {"cached", 2}),
+ .flags = MP_CMD_OPT_ARG},
+ {"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
+ {"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){STREAM_AUDIO},
.spawn_thread = true,
@@ -5682,11 +5693,11 @@ const struct mp_cmd_def mp_cmds[] = {
},
{ "video-add", cmd_track_add,
{
- OPT_STRING("url", v.s, 0),
- OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
- ({"select", 0}, {"auto", 1}, {"cached", 2})),
- OPT_STRING("title", v.s, MP_CMD_OPT_ARG),
- OPT_STRING("lang", v.s, MP_CMD_OPT_ARG),
+ {"url", OPT_STRING(v.s)},
+ {"flags", OPT_CHOICE(v.i, {"select", 0}, {"auto", 1}, {"cached", 2}),
+ .flags = MP_CMD_OPT_ARG},
+ {"title", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
+ {"lang", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG},
},
.priv = &(const int){STREAM_VIDEO},
.spawn_thread = true,
@@ -5694,26 +5705,26 @@ const struct mp_cmd_def mp_cmds[] = {
.abort_on_playback_end = true,
},
- { "sub-remove", cmd_track_remove, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
+ { "sub-remove", cmd_track_remove, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_SUB}, },
- { "audio-remove", cmd_track_remove, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
+ { "audio-remove", cmd_track_remove, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_AUDIO}, },
- { "video-remove", cmd_track_remove, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
+ { "video-remove", cmd_track_remove, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_VIDEO}, },
- { "sub-reload", cmd_track_reload, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
+ { "sub-reload", cmd_track_reload, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_SUB},
.spawn_thread = true,
.can_abort = true,
.abort_on_playback_end = true,
},
- { "audio-reload", cmd_track_reload, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
+ { "audio-reload", cmd_track_reload, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_AUDIO},
.spawn_thread = true,
.can_abort = true,
.abort_on_playback_end = true,
},
- { "video-reload", cmd_track_reload, { OPT_INT("id", v.i, 0, OPTDEF_INT(-1)) },
+ { "video-reload", cmd_track_reload, { {"id", OPT_INT(v.i), OPTDEF_INT(-1)} },
.priv = &(const int){STREAM_VIDEO},
.spawn_thread = true,
.can_abort = true,
@@ -5722,9 +5733,10 @@ const struct mp_cmd_def mp_cmds[] = {
{ "rescan-external-files", cmd_rescan_external_files,
{
- OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
- ({"keep-selection", 1},
- {"reselect", 0})),
+ {"flags", OPT_CHOICE(v.i,
+ {"keep-selection", 1},
+ {"reselect", 0}),
+ .flags = MP_CMD_OPT_ARG},
},
.spawn_thread = true,
.can_abort = true,
@@ -5733,121 +5745,126 @@ const struct mp_cmd_def mp_cmds[] = {
{ "screenshot", cmd_screenshot,
{
- OPT_FLAGS("flags", v.i, 0,
- ({"video", 4|0}, {"-", 4|0},
- {"window", 4|1},
- {"subtitles", 4|2},
- {"each-frame", 8}),
- OPTDEF_INT(4|2)),
+ {"flags", OPT_FLAGS(v.i,
+ {"video", 4|0}, {"-", 4|0},
+ {"window", 4|1},
+ {"subtitles", 4|2},
+ {"each-frame", 8}),
+ OPTDEF_INT(4|2)},
// backwards compatibility
- OPT_CHOICE("legacy", v.i, MP_CMD_OPT_ARG,
- ({"unused", 0}, {"single", 0},
- {"each-frame", 8})),
+ {"legacy", OPT_CHOICE(v.i,
+ {"unused", 0}, {"single", 0},
+ {"each-frame", 8}),
+ .flags = MP_CMD_OPT_ARG},
},
.spawn_thread = true,
},
{ "screenshot-to-file", cmd_screenshot_to_file,
{
- OPT_STRING("filename", v.s, 0),
- OPT_CHOICE("flags", v.i, 0,
- ({"video", 0},
- {"window", 1},
- {"subtitles", 2}),
- OPTDEF_INT(2)),
+ {"filename", OPT_STRING(v.s)},
+ {"flags", OPT_CHOICE(v.i,
+ {"video", 0},
+ {"window", 1},
+ {"subtitles", 2}),
+ OPTDEF_INT(2)},
},
.spawn_thread = true,
},
{ "screenshot-raw", cmd_screenshot_raw,
{
- OPT_CHOICE("flags", v.i, 0,
- ({"video", 0},
- {"window", 1},
- {"subtitles", 2}),
- OPTDEF_INT(2)),
+ {"flags", OPT_CHOICE(v.i,
+ {"video", 0},
+ {"window", 1},
+ {"subtitles", 2}),
+ OPTDEF_INT(2)},
},
},
{ "loadfile", cmd_loadfile,
{
- OPT_STRING("url", v.s, 0),
- OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
- ({"replace", 0},
- {"append", 1},
- {"append-play", 2})),
- OPT_KEYVALUELIST("options", v.str_list, MP_CMD_OPT_ARG),
+ {"url", OPT_STRING(v.s)},
+ {"flags", OPT_CHOICE(v.i,
+ {"replace", 0},
+ {"append", 1},
+ {"append-play", 2}),
+ .flags = MP_CMD_OPT_ARG},
+ {"options", OPT_KEYVALUELIST(v.str_list), .flags = MP_CMD_OPT_ARG},
},
},
- { "loadlist", cmd_loadlist, { OPT_STRING("url", v.s, 0),
- OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
- ({"replace", 0}, {"append", 1})), },
+ { "loadlist", cmd_loadlist,
+ {
+ {"url", OPT_STRING(v.s)},
+ {"flags", OPT_CHOICE(v.i, {"replace", 0}, {"append", 1}),
+ .flags = MP_CMD_OPT_ARG},
+ },
.spawn_thread = true,
.can_abort = true,
},
{ "playlist-clear", cmd_playlist_clear },
- { "playlist-remove", cmd_playlist_remove,
- {OPT_CHOICE_OR_INT("index", v.i, MP_CMD_OPT_ARG, 0, INT_MAX,
- ({"current", -1}))},
- },
- { "playlist-move", cmd_playlist_move, { OPT_INT("index1", v.i, 0),
- OPT_INT("index2", v.i, 0), }},
- { "run", cmd_run, { OPT_STRING("command", v.s, 0),
- OPT_STRING("args", v.s, 0), },
+ { "playlist-remove", cmd_playlist_remove, {
+ {"index", OPT_CHOICE(v.i, {"current", -1}),
+ .flags = MP_CMD_OPT_ARG, M_RANGE(0, INT_MAX)}, }},
+ { "playlist-move", cmd_playlist_move, { {"index1", OPT_INT(v.i)},
+ {"index2", OPT_INT(v.i)}, }},
+ { "run", cmd_run, { {"command", OPT_STRING(v.s)},
+ {"args", OPT_STRING(v.s)}, },
.vararg = true,
},
{ "subprocess", cmd_subprocess,
{
- OPT_STRINGLIST("args", v.str_list, 0),
- OPT_FLAG("playback_only", v.i, 0, OPTDEF_INT(1)),
- OPT_BYTE_SIZE("capture_size", v.i64, 0, 0, INT_MAX,
- OPTDEF_INT64(64 * 1024 * 1024)),
- OPT_FLAG("capture_stdout", v.i, MP_CMD_OPT_ARG),
- OPT_FLAG("capture_stderr", v.i, MP_CMD_OPT_ARG),
+ {"args", OPT_STRINGLIST(v.str_list)},
+ {"playback_only", OPT_FLAG(v.i), OPTDEF_INT(1)},
+ {"capture_size", OPT_BYTE_SIZE(v.i64), M_RANGE(0, INT_MAX),
+ OPTDEF_INT64(64 * 1024 * 1024)},
+ {"capture_stdout", OPT_FLAG(v.i), .flags = MP_CMD_OPT_ARG},
+ {"capture_stderr", OPT_FLAG(v.i), .flags = MP_CMD_OPT_ARG},
},
.spawn_thread = true,
.can_abort = true,
},
- { "set", cmd_set, {OPT_STRING("name", v.s, 0), OPT_STRING("value", v.s, 0)}},
- { "change-list", cmd_change_list, { OPT_STRING("name", v.s, 0),
- OPT_STRING("operation", v.s, 0),
- OPT_STRING("value", v.s, 0) }},
- { "add", cmd_add_cycle, { OPT_STRING("name", v.s, 0),
- OPT_DOUBLE("value", v.d, 0, OPTDEF_DOUBLE(1)), },
+ { "set", cmd_set, {{"name", OPT_STRING(v.s)}, {"value", OPT_STRING(v.s)}}},
+ { "change-list", cmd_change_list, { {"name", OPT_STRING(v.s)},
+ {"operation", OPT_STRING(v.s)},
+ {"value", OPT_STRING(v.s)} }},
+ { "add", cmd_add_cycle, { {"name", OPT_STRING(v.s)},
+ {"value", OPT_DOUBLE(v.d), OPTDEF_DOUBLE(1)}, },
.allow_auto_repeat = true,
.scalable = true,
},
- { "cycle", cmd_add_cycle, { OPT_STRING("name", v.s, 0),
- OPT_CYCLEDIR("value", v.d, 0, OPTDEF_DOUBLE(1)), },
+ { "cycle", cmd_add_cycle, { {"name", OPT_STRING(v.s)},
+ {"value", OPT_CYCLEDIR(v.d), OPTDEF_DOUBLE(1)}, },
.allow_auto_repeat = true,
.scalable = true,
.priv = "",
},
- { "multiply", cmd_multiply, { OPT_STRING("name", v.s, 0),
- OPT_DOUBLE("value", v.d, 0)},
+ { "multiply", cmd_multiply, { {"name", OPT_STRING(v.s)},
+ {"value", OPT_DOUBLE(v.d)}},
.allow_auto_repeat = true},
- { "cycle-values", cmd_cycle_values, { OPT_STRING("arg0", v.s, 0),
- OPT_STRING("arg1", v.s, 0),
- OPT_STRING("argN", v.s, 0), },
+ { "cycle-values", cmd_cycle_values, { {"arg0", OPT_STRING(v.s)},
+ {"arg1", OPT_STRING(v.s)},
+ {"argN", OPT_STRING(v.s)}, },
.vararg = true},
{ "enable-section", cmd_enable_input_section,
{
- OPT_STRING("name", v.s, 0),
- OPT_FLAGS("flags", v.i, MP_CMD_OPT_ARG,
- ({"default", 0},
- {"exclusive", MP_INPUT_EXCLUSIVE},
- {"allow-hide-cursor", MP_INPUT_ALLOW_HIDE_CURSOR},
- {"allow-vo-dragging", MP_INPUT_ALLOW_VO_DRAGGING})),
+ {"name", OPT_STRING(v.s)},
+ {"flags", OPT_FLAGS(v.i,
+ {"default", 0},
+ {"exclusive", MP_INPUT_EXCLUSIVE},
+ {"allow-hide-cursor", MP_INPUT_ALLOW_HIDE_CURSOR},
+ {"allow-vo-dragging", MP_INPUT_ALLOW_VO_DRAGGING}),
+ .flags = MP_CMD_OPT_ARG},
}
},
{ "disable-section", cmd_disable_input_section,
- {OPT_STRING("name", v.s, 0) }},
+ {{"name", OPT_STRING(v.s)} }},
{ "define-section", cmd_define_input_section,
{
- OPT_STRING("name", v.s, 0),
- OPT_STRING("contents", v.s, 0),
- OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG,
- ({"default", 0}, {"force", 1})),
+ {"name", OPT_STRING(v.s)},
+ {"contents", OPT_STRING(v.s)},
+ {"flags", OPT_CHOICE(v.i, {"default", 0}, {"force", 1}),
+ .flags = MP_CMD_OPT_ARG},
},
},
@@ -5855,89 +5872,87 @@ const struct mp_cmd_def mp_cmds[] = {
{ "drop-buffers", cmd_drop_buffers, },
- { "af", cmd_filter, { OPT_STRING("operation", v.s, 0),
- OPT_STRING("value", v.s, 0), },
+ { "af", cmd_filter, { {"operation", OPT_STRING(v.s)},
+ {"value", OPT_STRING(v.s)}, },
.priv = &(const int){STREAM_AUDIO} },
- { "vf", cmd_filter, { OPT_STRING("operation", v.s, 0),
- OPT_STRING("value", v.s, 0), },
+ { "vf", cmd_filter, { {"operation", OPT_STRING(v.s)},
+ {"value", OPT_STRING(v.s)}, },
.priv = &(const int){STREAM_VIDEO} },
- { "af-command", cmd_filter_command, { OPT_STRING("label", v.s, 0),
- OPT_STRING("command", v.s, 0),
- OPT_STRING("argument", v.s, 0), },
+ { "af-command", cmd_filter_command, { {"label", OPT_STRING(v.s)},
+ {"command", OPT_STRING(v.s)},
+ {"argument", OPT_STRING(v.s)}, },
.priv = &(const int){STREAM_AUDIO} },
- { "vf-command", cmd_filter_command, { OPT_STRING("label", v.s, 0),
- OPT_STRING("command", v.s, 0),
- OPT_STRING("argument", v.s, 0), },
+ { "vf-command", cmd_filter_command, { {"label", OPT_STRING(v.s)},
+ {"command", OPT_STRING(v.s)},
+ {"argument", OPT_STRING(v.s)}, },
.priv = &(const int){STREAM_VIDEO} },
{ "ao-reload", cmd_ao_reload },
- { "script-binding", cmd_script_binding, { OPT_STRING("name", v.s, 0) },
+ { "script-binding", cmd_script_binding, { {"name", OPT_STRING(v.s)} },
.allow_auto_repeat = true, .on_updown = true},
- { "script-message", cmd_script_message, { OPT_STRING("args", v.s, 0) },
+ { "script-message", cmd_script_message, { {"args", OPT_STRING(v.s)} },
.vararg = true },
- { "script-message-to", cmd_script_message_to, { OPT_STRING("target", v.s, 0),
- OPT_STRING("args", v.s, 0) },
+ { "script-message-to", cmd_script_message_to, { {"target", OPT_STRING(v.s)},
+ {"args", OPT_STRING(v.s)} },
.vararg = true },
- { "overlay-add", cmd_overlay_add, { OPT_INT("id", v.i, 0),
- OPT_INT("x", v.i, 0),
- OPT_INT("y", v.i, 0),
- OPT_STRING("file", v.s, 0),
- OPT_INT("offset", v.i, 0),
- OPT_STRING("fmt", v.s, 0),
- OPT_INT("w", v.i, 0),
- OPT_INT("h", v.i, 0),
- OPT_INT("stride", v.i, 0), }},
- { "overlay-remove", cmd_overlay_remove, { OPT_INT("id", v.i, 0) } },
+ { "overlay-add", cmd_overlay_add, { {"id", OPT_INT(v.i)},
+ {"x", OPT_INT(v.i)},
+ {"y", OPT_INT(v.i)},
+ {"file", OPT_STRING(v.s)},
+ {"offset", OPT_INT(v.i)},
+ {"fmt", OPT_STRING(v.s)},
+ {"w", OPT_INT(v.i)},
+ {"h", OPT_INT(v.i)},
+ {"stride", OPT_INT(v.i)}, }},
+ { "overlay-remove", cmd_overlay_remove, { {"id", OPT_INT(v.i)} } },
{ "osd-overlay", cmd_osd_overlay,
{
- OPT_INT64("id", v.i64, 0),
- OPT_CHOICE("format", v.i, 0, ({"none", 0},
- {"ass-events", 1})),
- OPT_STRING("data", v.s, 0),
- OPT_INT("res_x", v.i, 0, OPTDEF_INT(0)),
- OPT_INT("res_y", v.i, 0, OPTDEF_INT(720)),
- OPT_INT("z", v.i, 0, OPTDEF_INT(0)),
- OPT_FLAG("hidden", v.i, 0, OPTDEF_INT(0)),
- OPT_FLAG("compute_bounds", v.i, 0, OPTDEF_INT(0)),
+ {"id", OPT_INT64(v.i64)},
+ {"format", OPT_CHOICE(v.i, {"none", 0}, {"ass-events", 1})},
+ {"data", OPT_STRING(v.s)},
+ {"res_x", OPT_INT(v.i), OPTDEF_INT(0)},
+ {"res_y", OPT_INT(v.i), OPTDEF_INT(720)},
+ {"z", OPT_INT(v.i), OPTDEF_INT(0)},
+ {"hidden", OPT_FLAG(v.i), OPTDEF_INT(0)},
+ {"compute_bounds", OPT_FLAG(v.i), OPTDEF_INT(0)},
},
.is_noisy = true,
},
{ "write-watch-later-config", cmd_write_watch_later_config },
- { "mouse", cmd_mouse, { OPT_INT("x", v.i, 0),
- OPT_INT("y", v.i, 0),
- OPT_INT("button", v.i, 0, OPTDEF_INT(-1)),
- OPT_CHOICE("mode", v.i, MP_CMD_OPT_ARG,
- ({"single", 0}, {"double", 1})), }},
- { "keybind", cmd_key_bind, { OPT_STRING("name", v.s, 0),
- OPT_STRING("cmd", v.s, 0) }},
- { "keypress", cmd_key, { OPT_STRING("name", v.s, 0) },
+ { "mouse", cmd_mouse, { {"x", OPT_INT(v.i)},
+ {"y", OPT_INT(v.i)},
+ {"button", OPT_INT(v.i), OPTDEF_INT(-1)},
+ {"mode", OPT_CHOICE(v.i,
+ {"single", 0}, {"double", 1}),
+ .flags = MP_CMD_OPT_ARG}}},
+ { "keybind", cmd_key_bind, { {"name", OPT_STRING(v.s)},
+ {"cmd", OPT_STRING(v.s)} }},
+ { "keypress", cmd_key, { {"name", OPT_STRING(v.s)} },
.priv = &(const int){0}},
- { "keydown", cmd_key, { OPT_STRING("name", v.s, 0) },
+ { "keydown", cmd_key, { {"name", OPT_STRING(v.s)} },
.priv = &(const int){MP_KEY_STATE_DOWN}},
- { "keyup", cmd_key, { OPT_STRING("name", v.s, MP_CMD_OPT_ARG) },
+ { "keyup", cmd_key, { {"name", OPT_STRING(v.s), .flags = MP_CMD_OPT_ARG} },
.priv = &(const int){MP_KEY_STATE_UP}},
- { "apply-profile", cmd_apply_profile, {OPT_STRING("name", v.s, 0)} },
+ { "apply-profile", cmd_apply_profile, {{"name", OPT_STRING(v.s)}} },
- { "load-script", cmd_load_script, {OPT_STRING("filename", v.s, 0)} },
+ { "load-script", cmd_load_script, {{"filename", OPT_STRING(v.s)}} },
- { "dump-cache", cmd_dump_cache, { OPT_TIME("start", v.d, 0,
- .min = MP_NOPTS_VALUE),
- OPT_TIME("end", v.d, 0,
- .min = MP_NOPTS_VALUE),
- OPT_STRING("filename", v.s, 0) },
+ { "dump-cache", cmd_dump_cache, { {"start", OPT_TIME(v.d), .min = MP_NOPTS_VALUE},
+ {"end", OPT_TIME(v.d), .min = MP_NOPTS_VALUE},
+ {"filename", OPT_STRING(v.s)} },
.exec_async = true,
.can_abort = true,
},
- { "ab-loop-dump-cache", cmd_dump_cache_ab, { OPT_STRING("filename", v.s, 0) },
+ { "ab-loop-dump-cache", cmd_dump_cache_ab, { {"filename", OPT_STRING(v.s)} },
.exec_async = true,
.can_abort = true,
},