From ab6c760b3b58ec5b95b7d3af4fda941e8532dd70 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 23 Apr 2012 22:18:44 +0300 Subject: core: change initial sync with --delay, video stream switch Make A/V sync at the start of playback with nonzero --delay behave the same way as it does when seeking to the beginning later, meaning video plays from the start and audio is truncated or padded with silence to match timing. This was already the default behavior in case the streams in the file started at different times, but not if the mismatch was due to --delay. Trigger similar audio synchronization when switching to a new video stream. Previously, switching a video stream on after playing for some time in audio-only mode was buggy and caused initial desync equal to the duration of prior audio-only playback. --- mplayer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index 0f63907df8..aecbce8275 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2712,6 +2712,8 @@ int reinit_video_chain(struct MPContext *mpctx) sh_video->last_pts = MP_NOPTS_VALUE; sh_video->num_buffered_pts = 0; sh_video->next_frame_time = 0; + mpctx->restart_playback = true; + mpctx->delay = 0; if (opts->auto_quality > 0) { // Auto quality option enabled @@ -4837,7 +4839,6 @@ goto_enable_cache: mixer_setvolume(&mpctx->mixer, start_volume, start_volume); if (!ignore_start) audio_delay -= mpctx->sh_audio->stream_delay; - mpctx->delay = -audio_delay; } if (!mpctx->sh_audio) { -- cgit v1.2.3