summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/input.rst13
-rw-r--r--input/cmd_list.c4
-rw-r--r--player/command.c12
3 files changed, 24 insertions, 5 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 5bfa7c3150..9f1f6fc582 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -109,11 +109,20 @@ List of Input Commands
keyframes
Always restart playback at keyframe boundaries (fast).
-``revert_seek``
+``revert_seek [mode]``
Undoes the ``seek`` command, and some other commands that seek (but not
necessarily all of them). Calling this command once will jump to the
playback position before the seek. Calling it a second time undoes the
- ``revert_seek`` command itself.
+ ``revert_seek`` command itself. This only works within a single file.
+
+ The first argument is optional, and can change the behavior:
+
+ mark
+ Mark the current time position. The next normal ``revert_seek`` command
+ will seek back to this point, no matter how many seeks happened since
+ last time.
+
+ Using it without any arguments gives you the default behavior.
``frame_step``
Play one frame, then pause. Does nothing with audio-only playback.
diff --git a/input/cmd_list.c b/input/cmd_list.c
index 844a833092..fc0ef17ed5 100644
--- a/input/cmd_list.c
+++ b/input/cmd_list.c
@@ -69,7 +69,9 @@ const struct mp_cmd_def mp_cmds[] = {
},
.allow_auto_repeat = true,
},
- { MP_CMD_REVERT_SEEK, "revert_seek", },
+ { MP_CMD_REVERT_SEEK, "revert_seek", {
+ OARG_CHOICE(0, ({"-", 0}, {"mark", 1})),
+ }},
{ MP_CMD_QUIT, "quit", { OARG_INT(0) } },
{ MP_CMD_QUIT_WATCH_LATER, "quit_watch_later", { OARG_INT(0) } },
{ MP_CMD_STOP, "stop", },
diff --git a/player/command.c b/player/command.c
index dc26c354ae..52eebe12ec 100644
--- a/player/command.c
+++ b/player/command.c
@@ -76,6 +76,7 @@ struct command_ctx {
double last_seek_time;
double last_seek_pts;
+ double marked_pts;
double prev_pts;
@@ -4054,8 +4055,13 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
if (!mpctx->num_sources)
return -1;
double oldpts = cmdctx->last_seek_pts;
- if (oldpts != MP_NOPTS_VALUE) {
+ if (cmdctx->marked_pts != MP_NOPTS_VALUE)
+ oldpts = cmdctx->marked_pts;
+ if (cmd->args[0].v.i == 1) {
+ cmdctx->marked_pts = get_current_time(mpctx);
+ } else if (oldpts != MP_NOPTS_VALUE) {
cmdctx->last_seek_pts = get_current_time(mpctx);
+ cmdctx->marked_pts = MP_NOPTS_VALUE;
queue_seek(mpctx, MPSEEK_ABSOLUTE, oldpts, 1, false);
set_osd_function(mpctx, OSD_REW);
if (bar_osd)
@@ -4685,8 +4691,10 @@ static void command_event(struct MPContext *mpctx, int event, void *arg)
struct command_ctx *ctx = mpctx->command_ctx;
struct MPOpts *opts = mpctx->opts;
- if (event == MPV_EVENT_START_FILE)
+ if (event == MPV_EVENT_START_FILE) {
ctx->last_seek_pts = MP_NOPTS_VALUE;
+ ctx->marked_pts = MP_NOPTS_VALUE;
+ }
if (event == MPV_EVENT_TICK) {
double now =