From d302ac285f9c5ada104c23ba5c31ddc24f5ab560 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 3 Feb 2013 19:27:52 +0100 Subject: mplayer: reset audio/video delay if there's no next video frame mpctx->delay is used to control audio/video sync. If more audio than video has been played, it grows larger, meaning A/V desync is happening. This logic is a bit broken when video has ended, and audio is still playing. In that case, it tries to read additional video frames from the video decoder (because even if you don't feed new packets to the decoder, it could still return delayed frames). For that, the code to determine whether frames should be dropped is invoked (check_framedrop()). This function detects that video is behind audio (mpctx- >delay growing big), and attempts to issue a framedrop. Reset mpctx->delay if there's no more video. This fixes the the frame drop display "counting up" on each playloop iteration when playing audio files with cover art. These files are basically audio+video files with a single video frame. When playing these files the the corner case of having run out of video while audio is still playing is the normal case. Also reset mpctx->last_av_difference. This is not updated anymore if video ends (since update_avsync() sets it, but it's not called if video_left is false). This removes the "stuck" A/V sync value when video ends. With audio files containing cover art we would display a meaningless value over the duration of the whole file otherwise. --- core/mplayer.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'core') diff --git a/core/mplayer.c b/core/mplayer.c index a7761b4da5..6d0405620b 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -3264,6 +3264,10 @@ static void run_playloop(struct MPContext *mpctx) mpctx->time_frame += frame_time / opts->playback_speed; adjust_sync(mpctx, frame_time); } + if (!video_left) { + mpctx->delay = 0; + mpctx->last_av_difference = 0; + } } if (endpts != MP_NOPTS_VALUE) -- cgit v1.2.3