summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--player/audio.c2
-rw-r--r--player/command.c26
-rw-r--r--player/core.h8
-rw-r--r--player/loadfile.c2
-rw-r--r--player/playloop.c15
-rw-r--r--player/video.c2
6 files changed, 31 insertions, 24 deletions
diff --git a/player/audio.c b/player/audio.c
index 5b52eceb11..9fe7eb802a 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -229,7 +229,7 @@ int reinit_audio_filters(struct MPContext *mpctx)
mpctx->playback_pts != MP_NOPTS_VALUE && delay > 0.2)
{
queue_seek(mpctx, MPSEEK_ABSOLUTE, mpctx->playback_pts,
- MPSEEK_EXACT, true);
+ MPSEEK_EXACT, 0);
}
return 1;
}
diff --git a/player/command.c b/player/command.c
index ac97e1022d..f941e864dc 100644
--- a/player/command.c
+++ b/player/command.c
@@ -649,7 +649,7 @@ static int mp_property_percent_pos(void *ctx, struct m_property *prop,
switch (action) {
case M_PROPERTY_SET: {
double pos = *(double *)arg;
- queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, MPSEEK_DEFAULT, true);
+ queue_seek(mpctx, MPSEEK_FACTOR, pos / 100.0, MPSEEK_DEFAULT, 0);
return M_PROPERTY_OK;
}
case M_PROPERTY_GET: {
@@ -694,7 +694,7 @@ static int mp_property_time_pos(void *ctx, struct m_property *prop,
return M_PROPERTY_UNAVAILABLE;
if (action == M_PROPERTY_SET) {
- queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, MPSEEK_DEFAULT, true);
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, MPSEEK_DEFAULT, 0);
return M_PROPERTY_OK;
}
return property_time(action, arg, get_current_time(mpctx));
@@ -743,7 +743,7 @@ static int mp_property_playback_time(void *ctx, struct m_property *prop,
return M_PROPERTY_UNAVAILABLE;
if (action == M_PROPERTY_SET) {
- queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, MPSEEK_DEFAULT, true);
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, *(double *)arg, MPSEEK_DEFAULT, 0);
return M_PROPERTY_OK;
}
return property_time(action, arg, get_playback_time(mpctx));
@@ -844,7 +844,7 @@ static int mp_property_chapter(void *ctx, struct m_property *prop,
} else {
double pts = chapter_start_time(mpctx, chapter);
if (pts != MP_NOPTS_VALUE) {
- queue_seek(mpctx, MPSEEK_ABSOLUTE, pts, MPSEEK_DEFAULT, true);
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, pts, MPSEEK_DEFAULT, 0);
mpctx->last_chapter_seek = chapter;
mpctx->last_chapter_pts = pts;
}
@@ -2210,7 +2210,7 @@ static int mp_property_hwdec(void *ctx, struct m_property *prop,
video_vd_control(vd, VDCTRL_REINIT, NULL);
double last_pts = mpctx->last_vo_pts;
if (last_pts != MP_NOPTS_VALUE)
- queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, true);
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, 0);
}
return M_PROPERTY_OK;
}
@@ -4622,19 +4622,19 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
mark_seek(mpctx);
switch (abs) {
case 0: { // Relative seek
- queue_seek(mpctx, MPSEEK_RELATIVE, v, precision, false);
+ queue_seek(mpctx, MPSEEK_RELATIVE, v, precision, MPSEEK_FLAG_DELAY);
set_osd_function(mpctx, (v > 0) ? OSD_FFW : OSD_REW);
break;
}
case 1: { // Absolute seek by percentage
double ratio = v / 100.0;
double cur_pos = get_current_pos_ratio(mpctx, false);
- queue_seek(mpctx, MPSEEK_FACTOR, ratio, precision, false);
+ queue_seek(mpctx, MPSEEK_FACTOR, ratio, precision, MPSEEK_FLAG_DELAY);
set_osd_function(mpctx, cur_pos < ratio ? OSD_FFW : OSD_REW);
break;
}
case 2: { // Absolute seek to a timestamp in seconds
- queue_seek(mpctx, MPSEEK_ABSOLUTE, v, precision, false);
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, v, precision, MPSEEK_FLAG_DELAY);
set_osd_function(mpctx,
v > get_current_time(mpctx) ? OSD_FFW : OSD_REW);
break;
@@ -4642,7 +4642,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
case 3: { // Relative seek by percentage
queue_seek(mpctx, MPSEEK_FACTOR,
get_current_pos_ratio(mpctx, false) + v / 100.0,
- precision, false);
+ precision, MPSEEK_FLAG_DELAY);
set_osd_function(mpctx, v > 0 ? OSD_FFW : OSD_REW);
break;
}}
@@ -4664,7 +4664,8 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
} 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, MPSEEK_EXACT, false);
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, oldpts, MPSEEK_EXACT,
+ MPSEEK_FLAG_DELAY);
set_osd_function(mpctx, OSD_REW);
if (bar_osd)
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
@@ -4850,7 +4851,8 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re
// rounding for the mess of it.
a[0] += 0.01 * (a[1] >= 0 ? 1 : -1);
mark_seek(mpctx);
- queue_seek(mpctx, MPSEEK_RELATIVE, a[0], MPSEEK_EXACT, false);
+ queue_seek(mpctx, MPSEEK_RELATIVE, a[0], MPSEEK_EXACT,
+ MPSEEK_FLAG_DELAY);
set_osd_function(mpctx, (a[0] > 0) ? OSD_FFW : OSD_REW);
if (bar_osd)
mpctx->add_osd_seek_info |= OSD_SEEK_INFO_BAR;
@@ -5421,7 +5423,7 @@ void handle_ab_loop(struct MPContext *mpctx)
{
mark_seek(mpctx);
queue_seek(mpctx, MPSEEK_ABSOLUTE, start,
- MPSEEK_EXACT, false);
+ MPSEEK_EXACT, MPSEEK_FLAG_DELAY);
}
}
ctx->prev_pts = now;
diff --git a/player/core.h b/player/core.h
index 8f90a1903f..94bfe4aada 100644
--- a/player/core.h
+++ b/player/core.h
@@ -80,6 +80,10 @@ enum seek_precision {
MPSEEK_VERY_EXACT,
};
+enum seek_flags {
+ MPSEEK_FLAG_DELAY = 1 << 0, // give player chance to coalesce multiple seeks
+};
+
enum video_sync {
VS_DEFAULT = 0,
VS_DISP_RESAMPLE,
@@ -380,7 +384,7 @@ typedef struct MPContext {
enum seek_type type;
enum seek_precision exact;
double amount;
- bool immediate; // disable seek delay logic
+ unsigned flags; // MPSEEK_FLAG_*
} seek;
// Allow audio to issue a second seek if audio is too far ahead (for non-hr
@@ -512,7 +516,7 @@ void pause_player(struct MPContext *mpctx);
void unpause_player(struct MPContext *mpctx);
void add_step_frame(struct MPContext *mpctx, int dir);
void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
- enum seek_precision exact, bool immediate);
+ enum seek_precision exact, int flags);
double get_time_length(struct MPContext *mpctx);
double get_current_time(struct MPContext *mpctx);
double get_playback_time(struct MPContext *mpctx);
diff --git a/player/loadfile.c b/player/loadfile.c
index 590839c799..c41ff4367a 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1140,7 +1140,7 @@ reopen_file:
startpos = start;
}
if (startpos != MP_NOPTS_VALUE) {
- queue_seek(mpctx, MPSEEK_ABSOLUTE, startpos, 0, true);
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, startpos, MPSEEK_DEFAULT, 0);
execute_queued_seek(mpctx);
}
diff --git a/player/playloop.c b/player/playloop.c
index 9b15ac3f50..abba107dc5 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -141,7 +141,7 @@ void add_step_frame(struct MPContext *mpctx, int dir)
unpause_player(mpctx);
} else if (dir < 0) {
if (!mpctx->hrseek_active) {
- queue_seek(mpctx, MPSEEK_BACKSTEP, 0, MPSEEK_VERY_EXACT, true);
+ queue_seek(mpctx, MPSEEK_BACKSTEP, 0, MPSEEK_VERY_EXACT, 0);
pause_player(mpctx);
}
}
@@ -305,7 +305,7 @@ static void mp_seek(MPContext *mpctx, struct seek_params seek)
// This combines consecutive seek requests.
void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
- enum seek_precision exact, bool immediate)
+ enum seek_precision exact, int flags)
{
struct seek_params *seek = &mpctx->seek;
@@ -314,7 +314,7 @@ void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
switch (type) {
case MPSEEK_RELATIVE:
- seek->immediate |= immediate;
+ seek->flags |= flags;
if (seek->type == MPSEEK_FACTOR)
return; // Well... not common enough to bother doing better
seek->amount += amount;
@@ -332,7 +332,7 @@ void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
.type = type,
.amount = amount,
.exact = exact,
- .immediate = immediate,
+ .flags = flags,
};
return;
case MPSEEK_NONE:
@@ -351,7 +351,8 @@ void execute_queued_seek(struct MPContext *mpctx)
/* If the user seeks continuously (keeps arrow key down)
* try to finish showing a frame from one location before doing
* another seek (which could lead to unchanging display). */
- if (!mpctx->seek.immediate && mpctx->video_status < STATUS_PLAYING &&
+ bool delay = mpctx->seek.flags & MPSEEK_FLAG_DELAY;
+ if (delay && mpctx->video_status < STATUS_PLAYING &&
mp_time_sec() - mpctx->start_timestamp < 0.3)
return;
mp_seek(mpctx, mpctx->seek);
@@ -682,7 +683,7 @@ static void handle_sstep(struct MPContext *mpctx)
if (opts->step_sec > 0 && !mpctx->paused) {
set_osd_function(mpctx, OSD_FFW);
- queue_seek(mpctx, MPSEEK_RELATIVE, opts->step_sec, MPSEEK_DEFAULT, true);
+ queue_seek(mpctx, MPSEEK_RELATIVE, opts->step_sec, MPSEEK_DEFAULT, 0);
}
if (mpctx->video_status >= STATUS_EOF) {
@@ -699,7 +700,7 @@ static void handle_loop_file(struct MPContext *mpctx)
if (opts->loop_file && mpctx->stop_play == AT_END_OF_FILE) {
mpctx->stop_play = KEEP_PLAYING;
set_osd_function(mpctx, OSD_FFW);
- queue_seek(mpctx, MPSEEK_ABSOLUTE, 0, MPSEEK_DEFAULT, true);
+ queue_seek(mpctx, MPSEEK_ABSOLUTE, 0, MPSEEK_DEFAULT, 0);
if (opts->loop_file > 0)
opts->loop_file--;
}
diff --git a/player/video.c b/player/video.c
index 9790f34966..e18f8cba70 100644
--- a/player/video.c
+++ b/player/video.c
@@ -543,7 +543,7 @@ void mp_force_video_refresh(struct MPContext *mpctx)
mpctx->last_vo_pts != MP_NOPTS_VALUE)
{
queue_seek(mpctx, MPSEEK_ABSOLUTE, mpctx->last_vo_pts,
- MPSEEK_VERY_EXACT, true);
+ MPSEEK_VERY_EXACT, 0);
}
}