From 2254416a5d58ba38bee21f11083f135aabe4e926 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 24 Feb 2013 21:16:23 +0100 Subject: commands: parse seek time arguments like time options This means a commands like "seek 13:00 absolute" actually behaves like "--start=13:00", instead of interpreting the argument as fraction as with normal float options. This is probably slightly closer to what you'd expect. As a consequence, the seek argument's type changes from float to double internally. --- core/command.c | 2 +- core/input/input.c | 3 ++- core/input/input.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/command.c b/core/command.c index 35083f4aa3..cb6843eab4 100644 --- a/core/command.c +++ b/core/command.c @@ -1723,7 +1723,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) int osdl = msg_osd ? 1 : OSD_LEVEL_INVISIBLE; switch (cmd->id) { case MP_CMD_SEEK: { - float v = cmd->args[0].v.f; + double v = cmd->args[0].v.d; int abs = cmd->args[1].v.i; int exact = cmd->args[2].v.i; if (abs == 2) { // Absolute seek to a timestamp in seconds diff --git a/core/input/input.c b/core/input/input.c index 4496537317..5d5e3f3a67 100644 --- a/core/input/input.c +++ b/core/input/input.c @@ -92,6 +92,7 @@ struct key_name { #define ARG_STRING { .type = {"", NULL, &m_option_type_string} } #define ARG_CHOICE(c) { .type = {"", NULL, &m_option_type_choice, \ M_CHOICES(c)} } +#define ARG_TIME { .type = {"", NULL, &m_option_type_time} } #define OARG_FLOAT(def) { .type = {"", NULL, &m_option_type_float}, \ .optional = true, .v.f = def } @@ -117,7 +118,7 @@ static const mp_cmd_t mp_cmds[] = { { MP_CMD_RADIO_STEP_FREQ, "radio_step_freq", {ARG_FLOAT } }, { MP_CMD_SEEK, "seek", { - ARG_FLOAT, + ARG_TIME, OARG_CHOICE(0, ({"relative", 0}, {"0", 0}, {"absolute-percent", 1}, {"1", 1}, {"absolute", 2}, {"2", 2})), diff --git a/core/input/input.h b/core/input/input.h index 14d100e152..30cc2ce9ed 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -121,6 +121,7 @@ struct mp_cmd_arg { union { int i; float f; + double d; char *s; } v; }; -- cgit v1.2.3