summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-02-24 21:16:23 +0100
committerwm4 <wm4@nowhere>2013-02-26 01:55:52 +0100
commit2254416a5d58ba38bee21f11083f135aabe4e926 (patch)
tree5743108827d3b075d8fd1b2ae8a7c2a9d1e4318b /core
parent7af2bc66079a0d427946e10ec7869fa042a6ae8a (diff)
downloadmpv-2254416a5d58ba38bee21f11083f135aabe4e926.tar.bz2
mpv-2254416a5d58ba38bee21f11083f135aabe4e926.tar.xz
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.
Diffstat (limited to 'core')
-rw-r--r--core/command.c2
-rw-r--r--core/input/input.c3
-rw-r--r--core/input/input.h1
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;
};