summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-28 19:38:49 +0100
committerwm4 <wm4@nowhere>2015-01-28 19:40:12 +0100
commit7b3feecbc23e3e0b0d9cf66f02af53d127a0b681 (patch)
treec354aea981d03c7e754d45069556fe0d42c6fff1
parent7f7340ce7627135a5f858ae538fd9a9f140b1ed1 (diff)
downloadmpv-7b3feecbc23e3e0b0d9cf66f02af53d127a0b681.tar.bz2
mpv-7b3feecbc23e3e0b0d9cf66f02af53d127a0b681.tar.xz
player: allow seeking audio between video frames
This allows seeking audio between two video frames that are relatively far away. The implementation of this is a bit subtle. It pretend the audio position is different, and the actual PTS adjustment happens in audio.c with this line: sync_pts -= mpctx->audio_delay - mpctx->delay; Effectively this is the same as setting sync_pts to hrseek_pts after this line, though. (I'm actually not sure if this could be written in a more straightforward way; probably yes.)
-rw-r--r--player/video.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/player/video.c b/player/video.c
index d70b53bfec..e0424eab4e 100644
--- a/player/video.c
+++ b/player/video.c
@@ -588,8 +588,16 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
frame_time = 0;
}
mpctx->video_next_pts = pts;
- if (mpctx->d_audio)
+ if (mpctx->d_audio) {
mpctx->delay -= frame_time;
+ // When resuming after a hr-seek, let audio advance the position to
+ // the actual seek target.
+ if (mpctx->video_status == STATUS_SYNCING && mpctx->hrseek_active &&
+ pts != MP_NOPTS_VALUE)
+ {
+ mpctx->delay -= mpctx->hrseek_pts - pts;
+ }
+ }
if (mpctx->video_status >= STATUS_READY) {
mpctx->time_frame += frame_time / mpctx->opts->playback_speed;
adjust_sync(mpctx, pts, frame_time);