summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-28 17:15:07 +0100
committerwm4 <wm4@nowhere>2020-02-28 17:15:07 +0100
commit679e4108f29db061e85687af18f0e013c067f59b (patch)
treec5ade054525ba1e7832f5997ebf7f4d234bc81e2 /player/playloop.c
parent85576f31a9cc25ca75ac7d265aaaf211f76a4842 (diff)
downloadmpv-679e4108f29db061e85687af18f0e013c067f59b.tar.bz2
mpv-679e4108f29db061e85687af18f0e013c067f59b.tar.xz
player: dumb seeking related stuff, make audio hr-seek default
Try to deal with various corner cases. But when I fix one thing, another thing breaks. (And it's 50/50 whether I find the breakage immediately or a few months later.) So results may vary. The default for--hr-seek is changed to "default" (not creative enough to find a better name). In this mode, audio seeking is exact if there is no video, or if the video has only a single frame. This change is actually pretty dumb, since audio frames are usually small enough that exact seeking does not really add much. But it gets rid of some weird special cases. Internally, the most important change is that is_coverart and is_sparse handling is merged. is_sparse was originally just a special case for weird .ts streams that have the corresponding low-level flag set. The idea is that they're pretty similar anyway, so this would reduce the number of corner cases. But I'm not sure if this doesn't break the original intended use case for it (I don't have a sample anyway). This changes last-frame handling, and respects the duration of the last frame only if audio is disabled. This is mostly "coincidental" due to the need to make seeking past EOF trigger player exit, and is caused by setting STATUS_EOF early. On the other hand, this might have been this way before (see removed chunk close to it).
Diffstat (limited to 'player/playloop.c')
-rw-r--r--player/playloop.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/player/playloop.c b/player/playloop.c
index 6c390a76e2..597bcd3981 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -290,10 +290,11 @@ static void mp_seek(MPContext *mpctx, struct seek_params seek)
double demux_pts = seek_pts;
- bool hr_seek = opts->correct_pts && seek.exact != MPSEEK_KEYFRAME &&
- ((opts->hr_seek == 0 && seek.type == MPSEEK_ABSOLUTE) ||
- opts->hr_seek > 0 || seek.exact >= MPSEEK_EXACT) &&
- seek_pts != MP_NOPTS_VALUE;
+ bool hr_seek = (opts->correct_pts && seek.exact != MPSEEK_KEYFRAME &&
+ seek_pts != MP_NOPTS_VALUE) &&
+ (seek.exact >= MPSEEK_EXACT || opts->hr_seek == 1 ||
+ (opts->hr_seek >= 0 && seek.type == MPSEEK_ABSOLUTE) ||
+ (opts->hr_seek == 2 && (!mpctx->vo_chain || mpctx->vo_chain->is_sparse)));
if (seek.type == MPSEEK_FACTOR || seek.amount < 0 ||
(seek.type == MPSEEK_ABSOLUTE && seek.amount < mpctx->last_chapter_pts))
@@ -661,7 +662,7 @@ static void handle_osd_redraw(struct MPContext *mpctx)
return;
}
// Don't redraw immediately during a seek (makes it significantly slower).
- bool use_video = mpctx->vo_chain && !mpctx->vo_chain->is_coverart;
+ bool use_video = mpctx->vo_chain && !mpctx->vo_chain->is_sparse;
if (use_video && mp_time_sec() - mpctx->start_timestamp < 0.1) {
mp_set_timeout(mpctx, 0.1);
return;
@@ -1110,13 +1111,6 @@ static void handle_playback_restart(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
- // Do not wait for video stream if it only has sparse frames.
- if (mpctx->vo_chain && mpctx->vo_chain->is_sparse &&
- mpctx->video_status < STATUS_READY)
- {
- mpctx->video_status = STATUS_READY;
- }
-
if (mpctx->audio_status < STATUS_READY ||
mpctx->video_status < STATUS_READY)
return;
@@ -1127,6 +1121,7 @@ static void handle_playback_restart(struct MPContext *mpctx)
mpctx->video_status = STATUS_PLAYING;
get_relative_time(mpctx);
mp_wakeup_core(mpctx);
+ MP_DBG(mpctx, "starting video playback\n");
}
if (mpctx->audio_status == STATUS_READY) {
@@ -1139,14 +1134,7 @@ static void handle_playback_restart(struct MPContext *mpctx)
return;
}
- // Video needed, but not started yet -> wait.
- if (mpctx->vo_chain &&
- !mpctx->vo_chain->is_coverart &&
- !mpctx->vo_chain->is_sparse &&
- mpctx->video_status <= STATUS_READY)
- return;
-
- MP_VERBOSE(mpctx, "starting audio playback\n");
+ MP_DBG(mpctx, "starting audio playback\n");
mpctx->audio_status = STATUS_PLAYING;
fill_audio_out_buffers(mpctx); // actually play prepared buffer
mp_wakeup_core(mpctx);
@@ -1178,7 +1166,9 @@ static void handle_playback_restart(struct MPContext *mpctx)
mpctx->playing_msg_shown = true;
mp_wakeup_core(mpctx);
update_ab_loop_clip(mpctx);
- MP_VERBOSE(mpctx, "playback restart complete @ %f\n", mpctx->playback_pts);
+ MP_VERBOSE(mpctx, "playback restart complete @ %f, audio=%s, video=%s\n",
+ mpctx->playback_pts, mp_status_str(mpctx->video_status),
+ mp_status_str(mpctx->audio_status));
// Continuous seeks past EOF => treat as EOF instead of repeating seek.
if (mpctx->seek.type == MPSEEK_RELATIVE && mpctx->seek.amount > 0 &&